@Test public void testCreateMappingSummaryForStudyWithAssociationsWithAutomaticMapping() { Optional<Timestamp> returnLastDateMapping = Optional.of((Timestamp) LASTDATEMAPPING); when(associationRepository.findLastMappingDateByStudyId(STU_AUTO_MAPPING.getId())).thenReturn(returnLastDateMapping); MappingDetails mappingDetails = mappingDetailsService.createMappingSummary(STU_AUTO_MAPPING); verify(associationRepository, times(1)).findLastMappingDateByStudyId(STU_AUTO_MAPPING.getId()); assertThat(mappingDetails).isInstanceOf(MappingDetails.class); assertThat(mappingDetails.getMappingDate()).isInstanceOf(Date.class); assertThat(mappingDetails).hasFieldOrPropertyWithValue("performer", "automatic_mapping_process"); }
public MappingDetails createMappingSummary(Study study) { MappingDetails mappingSummary = new MappingDetails(); Optional<Timestamp> mappingDate= associationRepository.findLastMappingDateByStudyId(study.getId()); if (mappingDate.isPresent()){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date newDate = null; try { Timestamp mappingDateInfo= mappingDate.get(); newDate=new Date(mappingDateInfo.getTime()); } catch (Exception e) { e.printStackTrace(); } mappingSummary.setMappingDate(newDate); mappingSummary.setPerformer("automatic_mapping_process"); } return mappingSummary; }
MappingDetailsService { public MappingDetails createMappingSummary(Study study) { MappingDetails mappingSummary = new MappingDetails(); Optional<Timestamp> mappingDate= associationRepository.findLastMappingDateByStudyId(study.getId()); if (mappingDate.isPresent()){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date newDate = null; try { Timestamp mappingDateInfo= mappingDate.get(); newDate=new Date(mappingDateInfo.getTime()); } catch (Exception e) { e.printStackTrace(); } mappingSummary.setMappingDate(newDate); mappingSummary.setPerformer("automatic_mapping_process"); } return mappingSummary; } }
MappingDetailsService { public MappingDetails createMappingSummary(Study study) { MappingDetails mappingSummary = new MappingDetails(); Optional<Timestamp> mappingDate= associationRepository.findLastMappingDateByStudyId(study.getId()); if (mappingDate.isPresent()){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date newDate = null; try { Timestamp mappingDateInfo= mappingDate.get(); newDate=new Date(mappingDateInfo.getTime()); } catch (Exception e) { e.printStackTrace(); } mappingSummary.setMappingDate(newDate); mappingSummary.setPerformer("automatic_mapping_process"); } return mappingSummary; } @Autowired  MappingDetailsService(AssociationRepository associationRepository); }
MappingDetailsService { public MappingDetails createMappingSummary(Study study) { MappingDetails mappingSummary = new MappingDetails(); Optional<Timestamp> mappingDate= associationRepository.findLastMappingDateByStudyId(study.getId()); if (mappingDate.isPresent()){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date newDate = null; try { Timestamp mappingDateInfo= mappingDate.get(); newDate=new Date(mappingDateInfo.getTime()); } catch (Exception e) { e.printStackTrace(); } mappingSummary.setMappingDate(newDate); mappingSummary.setPerformer("automatic_mapping_process"); } return mappingSummary; } @Autowired  MappingDetailsService(AssociationRepository associationRepository); MappingDetails createMappingSummary(Study study); }
MappingDetailsService { public MappingDetails createMappingSummary(Study study) { MappingDetails mappingSummary = new MappingDetails(); Optional<Timestamp> mappingDate= associationRepository.findLastMappingDateByStudyId(study.getId()); if (mappingDate.isPresent()){ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date newDate = null; try { Timestamp mappingDateInfo= mappingDate.get(); newDate=new Date(mappingDateInfo.getTime()); } catch (Exception e) { e.printStackTrace(); } mappingSummary.setMappingDate(newDate); mappingSummary.setPerformer("automatic_mapping_process"); } return mappingSummary; } @Autowired  MappingDetailsService(AssociationRepository associationRepository); MappingDetails createMappingSummary(Study study);  }