@Test public void shouldCreateEntity() throws ActionHandlerException { ArgumentCaptor<TestEntity> testEntityCaptor = ArgumentCaptor.forClass(TestEntity.class); String string = "hello"; Integer integer = 42; Date date = new Date(2014, 12, 1); Locale locale = Locale.US; List list = asList("pig", "cat"); Map map = new HashMap(); map.put("dog", "good"); map.put("cat", "bad"); Map<String, Object> parameters = createTestEntityParameters(string, integer, date, locale, list, map); actionHandlerService.create(parameters); verify(testEntityDataService).create(testEntityCaptor.capture()); TestEntity expectedTestEntity = new TestEntity(string, integer, date, locale, list, map); assertEquals(expectedTestEntity, testEntityCaptor.getValue()); }
@Override public void create(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action CREATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Object instance = createEntityInstance(dataService); setInstanceProperties(instance, entity.getFields(), parameters); dataService.create(instance); }
ActionHandlerServiceImpl implements ActionHandlerService { @Override public void create(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action CREATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Object instance = createEntityInstance(dataService); setInstanceProperties(instance, entity.getFields(), parameters); dataService.create(instance); } }
ActionHandlerServiceImpl implements ActionHandlerService { @Override public void create(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action CREATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Object instance = createEntityInstance(dataService); setInstanceProperties(instance, entity.getFields(), parameters); dataService.create(instance); }  }
ActionHandlerServiceImpl implements ActionHandlerService { @Override public void create(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action CREATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Object instance = createEntityInstance(dataService); setInstanceProperties(instance, entity.getFields(), parameters); dataService.create(instance); }  @Override void create(Map<String, Object> parameters); @Override void update(Map<String, Object> parameters); @Override void createOrUpdate(Map<String, Object> parameters); @Override void queryAndUpdate(Map<String, Object> parameters); @Override void delete(Map<String, Object> parameters); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setAllEntities(AllEntities allEntities); }
ActionHandlerServiceImpl implements ActionHandlerService { @Override public void create(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action CREATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Object instance = createEntityInstance(dataService); setInstanceProperties(instance, entity.getFields(), parameters); dataService.create(instance); }  @Override void create(Map<String, Object> parameters); @Override void update(Map<String, Object> parameters); @Override void createOrUpdate(Map<String, Object> parameters); @Override void queryAndUpdate(Map<String, Object> parameters); @Override void delete(Map<String, Object> parameters); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setAllEntities(AllEntities allEntities);  }