ScxaExperimentDtoResultSetExtractor extends ExperimentDTOResultSetExtractor { @Override protected ExperimentDTO createExperimentDTO(ResultSet resultSet, String experimentAccession) throws SQLException { ExperimentType experimentType = ExperimentType.valueOf(resultSet.getString("type")); String species = resultSet.getString("species"); Date lastUpdate = resultSet.getTimestamp("last_update"); boolean isPrivate = resultSet.getBoolean("private"); String accessKeyUUID = resultSet.getString("access_key"); String title = StringUtils.isEmpty(resultSet.getString("title")) ? "" : resultSet.getString("title"); String pubMedIdsString = resultSet.getString("pubmed_ids"); Set<String> pubMedIds = resultSet.wasNull() || StringUtils.isBlank(pubMedIdsString)? new HashSet<>() : Sets.newHashSet(Splitter.on(", ").split(pubMedIdsString)); String doisString = resultSet.getString("dois"); Set<String> dois = resultSet.wasNull() || StringUtils.isBlank(doisString) ? new HashSet<>() : Sets.newHashSet(Splitter.on(", ").split(doisString)); return new ExperimentDTO( experimentAccession, experimentType, species, pubMedIds, dois, title, lastUpdate, isPrivate, accessKeyUUID); }    }
@Test void createsValidExperimentDTO() throws SQLException { String experimentAccession = RandomDataTestUtils.generateRandomExperimentAccession(); createMockResultSet(ExperimentType.SINGLE_CELL_RNASEQ_MRNA_BASELINE, "Homo sapiens", "123", true, currentTime, "This is a dummy title", "123, 124, 125", "10.10/abc, 12.100/abc, 13.9/abc"); ExperimentDTO result = subject.createExperimentDTO(mockResultSet, experimentAccession); assertThat(result.getExperimentAccession()).isEqualToIgnoringCase(experimentAccession); assertThat(result.getExperimentType()).isEqualByComparingTo(ExperimentType.SINGLE_CELL_RNASEQ_MRNA_BASELINE); assertThat(result.getSpecies()).isEqualToIgnoringCase("Homo sapiens"); assertThat(result.getAccessKey()).isEqualToIgnoringCase("123"); assertThat(result.isPrivate()).isTrue(); assertThat(result.getLastUpdate()).hasSameTimeAs(currentTime); assertThat(result.getTitle()).isNotEmpty(); assertThat(result.getPubmedIds()).hasSize(3); assertThat(result.getDois()).hasSize(3); }
@Test void createsExperimentDTOWithEmptyFields() throws SQLException { String experimentAccession = RandomDataTestUtils.generateRandomExperimentAccession(); createMockResultSet(ExperimentType.SINGLE_CELL_RNASEQ_MRNA_BASELINE, "Homo sapiens", "", false, currentTime, "", "", ""); ExperimentDTO result = subject.createExperimentDTO(mockResultSet, experimentAccession); assertThat(result.getTitle()).isEmpty(); assertThat(result.getAccessKey()).isEmpty(); assertThat(result.getPubmedIds()).isEmpty(); assertThat(result.getDois()).isEmpty(); }
@Test void createsExperimentDTOWithNullFields() throws SQLException { String experimentAccession = RandomDataTestUtils.generateRandomExperimentAccession(); createMockResultSet(ExperimentType.SINGLE_CELL_RNASEQ_MRNA_BASELINE, "Homo sapiens", "", false, currentTime, "", null, null); ExperimentDTO result = subject.createExperimentDTO(mockResultSet, experimentAccession); assertThat(result.getPubmedIds()).isEmpty(); assertThat(result.getDois()).isEmpty(); }