@Test public void testIsAvailableStatAndSuffix() throws Throwable { long c = 1; URI factoryURI = UriUtils.buildFactoryUri(this.host, ExampleService.class); String name = UUID.randomUUID().toString(); ExampleServiceState s = new ExampleServiceState(); s.name = name; Consumer<Operation> bodySetter = (o) -> { o.setBody(s); }; Map<URI, ExampleServiceState> states = this.host.doFactoryChildServiceStart(null, c, ExampleServiceState.class, bodySetter, factoryURI); this.host.waitForServiceAvailable(factoryURI); TestContext ctx = testCreate(states.size()); for (URI u : states.keySet()) { Operation get = Operation.createGet(UriUtils.buildAvailableUri(u)) .setCompletion(ctx.getCompletion()); this.host.send(get); } testWait(ctx); ServiceStat body = new ServiceStat(); body.name = Service.STAT_NAME_AVAILABLE; body.latestValue = 0.0; Operation put = Operation.createPut( UriUtils.buildAvailableUri(this.host, factoryURI.getPath())) .setBody(body); this.host.sendAndWaitExpectSuccess(put); Operation get = Operation.createGet(UriUtils.buildAvailableUri(factoryURI)); this.host.sendAndWaitExpectFailure(get); ctx = testCreate(states.size()); for (URI u : states.keySet()) { put = put.clone().setUri(UriUtils.buildAvailableUri(u)) .setBody(body) .setCompletion(ctx.getCompletion()); this.host.send(put); } testWait(ctx); ctx = testCreate(states.size()); for (URI u : states.keySet()) { get = get.clone().setUri(UriUtils.buildAvailableUri(u)) .setCompletion(ctx.getExpectedFailureCompletion()); this.host.send(get); } testWait(ctx); Service service = this.host.startServiceAndWait(new SetAvailableValidationService(), UUID.randomUUID().toString(), new ExampleServiceState()); get = Operation.createGet(UriUtils.buildAvailableUri(service.getUri())); this.host.sendAndWaitExpectFailure(get); Operation patch = Operation.createPatch(service.getUri()) .setBody(new ExampleServiceState()); this.host.sendAndWaitExpectSuccess(patch); get = Operation.createGet(UriUtils.buildAvailableUri(service.getUri())); this.host.sendAndWaitExpectSuccess(get); }
@Override public URI getUri() { return null; }
UtilityService implements Service { @Override public URI getUri() { return null; } }
UtilityService implements Service { @Override public URI getUri() { return null; } UtilityService(); }
UtilityService implements Service { @Override public URI getUri() { return null; } UtilityService(); UtilityService setParent(Service parent); @Override void authorizeRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void handleStop(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); boolean hasSubscribers(); boolean hasStats(); void notifySubscribers(Operation op); void redirectGetToHtmlUiResource(Operation op, String htmlResourcePath); @Override void handleConfigurationRequest(Operation op); void handlePatchConfiguration(Operation op, ServiceConfigUpdateRequest updateBody); @Override void setStat(ServiceStat stat, double newValue); @Override void adjustStat(ServiceStat stat, double delta); @Override ServiceStat getStat(String name); @Override ServiceStats getStats(); ServiceStat getStat(String name, boolean create); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override EnumSet<ServiceOption> getOptions(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption cap, boolean enable); @Override void adjustStat(String name, double delta); @Override void setStat(String name, double newValue); @Override void handleMaintenance(Operation post); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage initialized); @Override ServiceDocument setInitialState(Object state, Long initialVersion); @Override Service getUtilityService(String uriPath, boolean allocate); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override ServiceDocument getDocumentTemplate(); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override void setState(Operation op, ServiceDocument newState); @SuppressWarnings("unchecked") @Override T getState(Operation op); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Operation dequeueRequest(); @Override Class<? extends ServiceDocument> getStateType(); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); @Override final AuthorizationContext getSystemAuthorizationContext(); }
UtilityService implements Service { @Override public URI getUri() { return null; } UtilityService(); UtilityService setParent(Service parent); @Override void authorizeRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void handleStop(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); boolean hasSubscribers(); boolean hasStats(); void notifySubscribers(Operation op); void redirectGetToHtmlUiResource(Operation op, String htmlResourcePath); @Override void handleConfigurationRequest(Operation op); void handlePatchConfiguration(Operation op, ServiceConfigUpdateRequest updateBody); @Override void setStat(ServiceStat stat, double newValue); @Override void adjustStat(ServiceStat stat, double delta); @Override ServiceStat getStat(String name); @Override ServiceStats getStats(); ServiceStat getStat(String name, boolean create); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override EnumSet<ServiceOption> getOptions(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption cap, boolean enable); @Override void adjustStat(String name, double delta); @Override void setStat(String name, double newValue); @Override void handleMaintenance(Operation post); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage initialized); @Override ServiceDocument setInitialState(Object state, Long initialVersion); @Override Service getUtilityService(String uriPath, boolean allocate); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override ServiceDocument getDocumentTemplate(); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override void setState(Operation op, ServiceDocument newState); @SuppressWarnings("unchecked") @Override T getState(Operation op); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Operation dequeueRequest(); @Override Class<? extends ServiceDocument> getStateType(); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); @Override final AuthorizationContext getSystemAuthorizationContext();  }