@Test public void shouldNotInsertExistingInterfaceDataset(){ ELMISInterface elmisInterface = new ELMISInterface(); elmisInterface.setId(123L); List<ELMISInterfaceDataSet> existingDataset = new ArrayList<>(); ELMISInterfaceDataSet dataSet = new ELMISInterfaceDataSet(); dataSet.setId(134L); dataSet.setModifiedBy(1L); existingDataset.add(dataSet); elmisInterface.setDataSets(existingDataset); when(mapper.getInterfaceDatasetById(123L)).thenReturn(existingDataset); repository.updateELMISInterfaceDataSets(elmisInterface); verify(mapper).updateDataSet(dataSet); verify(mapper, never()).insertDataSet(dataSet); verify(mapper, never()).deleteDataset(dataSet); }
public void updateELMISInterfaceDataSets(ELMISInterface elmisInterface) { List<ELMISInterfaceDataSet> previousDataSets = mapper.getInterfaceDatasetById(elmisInterface.getId()); List<ELMISInterfaceDataSet> editedDatasets = elmisInterface.getDataSets(); deleteRemovedDatasetElements(previousDataSets, editedDatasets); UpdateDatasetElements(elmisInterface); }
ELMISInterfaceRepository { public void updateELMISInterfaceDataSets(ELMISInterface elmisInterface) { List<ELMISInterfaceDataSet> previousDataSets = mapper.getInterfaceDatasetById(elmisInterface.getId()); List<ELMISInterfaceDataSet> editedDatasets = elmisInterface.getDataSets(); deleteRemovedDatasetElements(previousDataSets, editedDatasets); UpdateDatasetElements(elmisInterface); } }
ELMISInterfaceRepository { public void updateELMISInterfaceDataSets(ELMISInterface elmisInterface) { List<ELMISInterfaceDataSet> previousDataSets = mapper.getInterfaceDatasetById(elmisInterface.getId()); List<ELMISInterfaceDataSet> editedDatasets = elmisInterface.getDataSets(); deleteRemovedDatasetElements(previousDataSets, editedDatasets); UpdateDatasetElements(elmisInterface); }  }
ELMISInterfaceRepository { public void updateELMISInterfaceDataSets(ELMISInterface elmisInterface) { List<ELMISInterfaceDataSet> previousDataSets = mapper.getInterfaceDatasetById(elmisInterface.getId()); List<ELMISInterfaceDataSet> editedDatasets = elmisInterface.getDataSets(); deleteRemovedDatasetElements(previousDataSets, editedDatasets); UpdateDatasetElements(elmisInterface); }  ELMISInterface get(long interfaceId); void insert(ELMISInterface elmisInterface); void update(ELMISInterface elmisInterface); void updateELMISInterfaceDataSets(ELMISInterface elmisInterface); List<ELMISInterface> getAllInterfaces(); List<ELMISInterfaceFacilityMapping> getInterfaceFacilityMappings(); List<ELMISInterfaceFacilityMapping> getFacilityInterfaceMappingById(Long facilityId); List<ELMISInterface> getAllActiveInterfaces(); void updateFacilityInterfaceMapping(Facility facility); }
ELMISInterfaceRepository { public void updateELMISInterfaceDataSets(ELMISInterface elmisInterface) { List<ELMISInterfaceDataSet> previousDataSets = mapper.getInterfaceDatasetById(elmisInterface.getId()); List<ELMISInterfaceDataSet> editedDatasets = elmisInterface.getDataSets(); deleteRemovedDatasetElements(previousDataSets, editedDatasets); UpdateDatasetElements(elmisInterface); }  ELMISInterface get(long interfaceId); void insert(ELMISInterface elmisInterface); void update(ELMISInterface elmisInterface); void updateELMISInterfaceDataSets(ELMISInterface elmisInterface); List<ELMISInterface> getAllInterfaces(); List<ELMISInterfaceFacilityMapping> getInterfaceFacilityMappings(); List<ELMISInterfaceFacilityMapping> getFacilityInterfaceMappingById(Long facilityId); List<ELMISInterface> getAllActiveInterfaces(); void updateFacilityInterfaceMapping(Facility facility);  }