@Override public void handleGet(Operation op) { ServiceDocument state = new ServiceDocument(); state.documentSelfLink = SELF_LINK; op.setBody(state).complete(); } }
@Test public void toJsonHtml() { ServiceDocument doc = new ServiceDocument(); String json = Utils.toJsonHtml(doc); assertTrue(json.contains(" ")); }
@Test public void toJsonHtml() { ServiceDocument doc = new ServiceDocument(); String json = Utils.toJsonHtml(doc); assertTrue(json.contains(" ")); }
@Override public void handlePut(Operation op) { ServiceDocument body = new ServiceDocument(); body.documentSelfLink = getSelfLink(); op.setBody(body); validateAndComplete(op); }
private void sendSynchRequest(URI parentUri, String documentSelfLink, CompletionHandler ch) { ServiceDocument synchState = new ServiceDocument(); synchState.documentSelfLink = documentSelfLink; Operation synchOp = Operation .createPost(this.host, parentUri.getPath()) .setBody(synchState) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_SYNCH_OWNER) .setReferer(this.host.getUri()) .setExpiration(Utils.fromNowMicrosUtc(NodeGroupService.PEER_REQUEST_TIMEOUT_MICROS)) .setCompletion((o, e) -> ch.handle(o, e)); this.host.handleRequest(null, synchOp); }
@Override public void handlePut(Operation op) { ServiceDocument body = new ServiceDocument(); body.documentSelfLink = getSelfLink(); op.setBody(body); validateAndComplete(op); }
@Test public void testHostWithoutNetworks() throws Throwable { List<String> tenantLinks = new ArrayList<String>(); tenantLinks.add("project1"); ComputeState cs = createComputeState("TestID1", tenantLinks); cs = doPost(cs, ComputeService.FACTORY_LINK); List<String> links = getDocumentLinksOfType(ContainerNetworkState.class); Assert.assertTrue(links.isEmpty()); doOperation(new ServiceDocument(), UriUtils.buildUri(host, ContainerNetworksTransformationService.SELF_LINK), false, Service.Action.POST); }
@Test public void testHostWithoutVolumes() throws Throwable { List<String> tenantLinks = new ArrayList<String>(); tenantLinks.add("project1"); ComputeState cs = createComputeState("TestID1", tenantLinks); cs = doPost(cs, ComputeService.FACTORY_LINK); List<String> links = getDocumentLinksOfType(ContainerVolumeState.class); Assert.assertTrue(links.isEmpty()); doOperation(new ServiceDocument(), UriUtils.buildUri(host, ContainerVolumesTransformationService.SELF_LINK), false, Service.Action.POST); }
@Test public void testHostwithoutContainers() throws Throwable { List<String> tenantLinks = new ArrayList<String>(); tenantLinks.add("project1"); ComputeState cs = createComputeState("TestID1", tenantLinks); cs = doPost(cs, ComputeService.FACTORY_LINK); List<String> links = getDocumentLinksOfType(ContainerState.class); Assert.assertTrue(links.isEmpty()); doOperation(new ServiceDocument(), UriUtils.buildUri(host, ContainersTransformationService.SELF_LINK), false, Service.Action.POST); }
@Test public void testNoNetworksNoHosts() throws Throwable { List<String> links = getDocumentLinksOfType(ComputeState.class); Assert.assertTrue(links.isEmpty()); doOperation(new ServiceDocument(), UriUtils.buildUri(host, ContainerNetworksTransformationService.SELF_LINK), false, Service.Action.POST); }
@Test public void testStartServices() throws Throwable { MockCommonInitialBootService mockCommonInitialBootService = new MockCommonInitialBootService(); host.startServiceAndWait(mockCommonInitialBootService, MockCommonInitialBootService.SELF_LINK, new ServiceDocument()); mockCommonInitialBootService.behaviour = 0; HostInitCommonServiceConfig.startServices(host); }
@Test public void testNoHosts() throws Throwable { List<String> links = getDocumentLinksOfType(GroupResourcePlacementState.class); Assert.assertFalse(links.isEmpty()); List<String> hostLinks = getDocumentLinksOfType(ComputeState.class); Assert.assertTrue(hostLinks.isEmpty()); doOperation(new ServiceDocument(), UriUtils.buildUri(host, ComputePlacementPoolRelationTransformationService.SELF_LINK), false, Service.Action.POST); }
@Test public void hasResults() { assertFalse(QueryResultsProcessor.create(new QueryTask()).hasResults()); QueryTask task = new QueryTask(); task.results = new ServiceDocumentQueryResult(); task.results.documents = new HashMap<>(); task.results.documentCount = 1L; task.results.documents.put("link", new ServiceDocument()); assertTrue(QueryResultsProcessor.create(task).hasResults()); }
@Override public void handleGet(Operation get) { ServiceDocument doc = new ServiceDocument(); doc.documentOwner = this.getHost().getId(); doc.documentSelfLink = this.getSelfLink(); get.setBody(doc); get.complete(); } }
@Before public void setup() throws Throwable { this.host = VerificationHost.create(0); this.host.start(); this.host.startServiceAndWait(new NsOwner(), NsOwner.SELF_LINK, new ServiceDocument()); }
private void deleteServices(List<URI> targetServiceURIs) throws Throwable { this.host.testStart(targetServiceURIs.size()); for (URI u : targetServiceURIs) { this.host.send(Operation.createDelete(u) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion())); } this.host.testWait(); }
@Override public void handleGet(Operation get) { ServiceDocument doc = new ServiceDocument(); doc.documentOwner = this.getHost().getId(); doc.documentSelfLink = this.getSelfLink(); get.setBody(doc); get.complete(); } }
private void deleteServices(List<URI> targetServiceURIs) throws Throwable { this.host.testStart(targetServiceURIs.size()); for (URI u : targetServiceURIs) { this.host.send(Operation.createDelete(u) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion())); } this.host.testWait(); }
@Before public void setup() throws Throwable { this.host = VerificationHost.create(0); this.host.start(); this.host.startServiceAndWait(new NsOwner(), NsOwner.SELF_LINK, new ServiceDocument()); }
private void delete(URI uri) throws Throwable { this.host.testStart(1); this.host.sendRequest(Operation .createDelete(uri) .setBody(new ServiceDocument()) .setCompletion(this.host.getCompletion()) .setReferer(this.host.getUri())); this.host.testWait(); }