ActionHandlerServiceImpl implements ActionHandlerService { @Override public void update(Map<String, Object> parameters) throws ActionHandlerException { LOGGER.debug("Action UPDATE: params: {}", parameters); String entityClassName = getEntityClassName(parameters); MotechDataService dataService = getEntityDataService(entityClassName); Entity entity = getEntity(entityClassName); Long instanceId = getInstanceId(parameters, true); Object instance = retrieveEntityInstance(dataService, instanceId); setInstanceProperties(instance, entity.getFields(), parameters); dataService.update(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);  }
@Test public void shouldUpdateEntity() throws ActionHandlerException { Map<String, Object> parameters = updateTestParams(); TestEntity testEntity = preUpdateTestEntity(); testEntity.setId(1L); when(testEntityDataService.findById(eq(1L))).thenReturn(testEntity); actionHandlerService.update(parameters); TestEntity expectedTestEntity = expectedPostUpdateTestEntity(); expectedTestEntity.setId(1L); ArgumentCaptor<TestEntity> testEntityCaptor = ArgumentCaptor.forClass(TestEntity.class); verify(testEntityDataService).update(testEntityCaptor.capture()); assertEquals(expectedTestEntity, testEntityCaptor.getValue()); }