WorkflowSequenceService extends AbstractService implements
    ServiceParent, ServiceStateChangeListener { @Override public synchronized void addService(Service service) { Preconditions.checkArgument(service != null, "null service argument"); LOG.debug("Adding service {} ", service.getName()); synchronized (serviceList) { serviceList.add(service); } } WorkflowSequenceService(String name);  WorkflowSequenceService();  WorkflowSequenceService(String name, Service... children);  WorkflowSequenceService(String name, List<Service> children); Service getActiveService(); Service getPreviousService(); synchronized boolean startNextService(); @Override void stateChanged(Service service); @Override synchronized void addService(Service service); @Override //Parent synchronized List<Service> getServices(); @Override // Object synchronized String toString();  }
@Test public void testAddChild() throws Throwable { MockService one = new MockService("one", false, 5000); MockService two = new MockService("two", false, 100); ServiceParent parent = startService(one, two); CallableHandler handler = new CallableHandler("hello"); WorkflowCallbackService<String> ens = new WorkflowCallbackService<String>("handler", handler, 100, true); parent.addService(ens); waitForParentToStop(parent, 10000); assertStopped(one); assertStopped(two); assertStopped(ens); assertStopped(two); assertEquals("hello", ens.getScheduledFuture().get()); }