### Question:
ServiceOperations { public static void deploy(Service service, Configuration configuration) { init(service, configuration); start(service); } private  ServiceOperations(); static void ensureCurrentState(Service.STATE state,
                                        Service.STATE expectedState); static void init(Service service, Configuration configuration); static void start(Service service); static void deploy(Service service, Configuration configuration); static void stop(Service service); static Exception stopQuietly(Service service);  }### Answer:
@Test public void testDeploy() throws Throwable { BreakableService svc = new BreakableService(); assertServiceStateCreated(svc); ServiceOperations.deploy(svc, new Configuration()); assertServiceStateStarted(svc); assertStateCount(svc, Service.STATE.INITED, 1); assertStateCount(svc, Service.STATE.STARTED, 1); ServiceOperations.stop(svc); assertServiceStateStopped(svc); assertStateCount(svc, Service.STATE.STOPPED, 1); }
@Test public void testDeployNotAtomic() throws Throwable { BreakableService svc = new BreakableService(false, true, false); try { ServiceOperations.deploy(svc, new Configuration()); fail("Expected a failure, got " + svc); } catch (BreakableService.BrokenLifecycleEvent expected) { } assertServiceStateInited(svc); assertStateCount(svc, Service.STATE.INITED, 1); assertStateCount(svc, Service.STATE.STARTED, 1); try { ServiceOperations.deploy(svc, new Configuration()); fail("Expected a failure, got " + svc); } catch (IllegalStateException e) { } }