FactoryManager { public Factory saveFactory(Factory factory) throws ConflictException, ServerException { requireNonNull(factory); final FactoryImpl newFactory = new FactoryImpl(factory); newFactory.setId(NameGenerator.generate("factory", 16)); if (isNullOrEmpty(newFactory.getName())) { newFactory.setName(NameGenerator.generate("f", 9)); } return factoryDao.create(newFactory); } @Inject  FactoryManager(FactoryDao factoryDao); Factory saveFactory(Factory factory); Factory updateFactory(Factory update); void removeFactory(String id); Factory getById(String id); Page<? extends Factory> getByAttribute(
      int maxItems, int skipCount, List<Pair<String, String>> attributes);  }
@Test public void shouldGenerateNameOnFactoryCreation() throws Exception { final FactoryImpl factory = FactoryImpl.builder().generateId().build(); factoryManager.saveFactory(factory); verify(factoryDao).create(factoryCaptor.capture()); assertFalse(isNullOrEmpty(factoryCaptor.getValue().getName())); }