@Test public void registersServiceToRepository() throws Exception { long expectedId = 42; ServiceRegistrator tested = new ServiceRegistrator(); mockStatic(IdGenerator.class); expect(IdGenerator.generateNewId()).andReturn(expectedId); replay(IdGenerator.class); long actualId = tested.registerService(new Object()); verify(IdGenerator.class); assertEquals(expectedId, actualId); }
public long registerService(Object service) { final long id = IdGenerator.generateNewId(); serviceRegistry.put(id, service); return id; }
ServiceRegistrator { public long registerService(Object service) { final long id = IdGenerator.generateNewId(); serviceRegistry.put(id, service); return id; } }
ServiceRegistrator { public long registerService(Object service) { final long id = IdGenerator.generateNewId(); serviceRegistry.put(id, service); return id; }  }
ServiceRegistrator { public long registerService(Object service) { final long id = IdGenerator.generateNewId(); serviceRegistry.put(id, service); return id; }  long registerService(Object service); }
ServiceRegistrator { public long registerService(Object service) { final long id = IdGenerator.generateNewId(); serviceRegistry.put(id, service); return id; }  long registerService(Object service);  }