TSnePlotService { public Set<TSnePoint> fetchTSnePlotWithExpression(String experimentAccession, int perplexity, String geneId) { return tSnePlotDao.fetchTSnePlotWithExpression(experimentAccession, perplexity, geneId).stream() .map( pointDto -> TSnePoint.create( MathUtils.round(pointDto.x(), 2), MathUtils.round(pointDto.y(), 2), pointDto.expressionLevel(), pointDto.name())) .collect(toSet()); } TSnePlotService(TSnePlotDao tSnePlotDao, CellMetadataDao cellMetadataDao); Set<TSnePoint> fetchTSnePlotWithExpression(String experimentAccession, int perplexity, String geneId); Map<Integer, Set<TSnePoint>> fetchTSnePlotWithClusters(String experimentAccession, int perplexity, int k); Map<String, Set<TSnePoint>> fetchTSnePlotWithMetadata(String experimentAccession,
                                                                 int perplexity,
                                                                 String metadataCategory);  }
@Test @DisplayName("Points DTOs retrieved by the DAO class are correctly transformed to their non-DTO counterparts") void testFetchPlotWithExpressionLevels() { String experimentAccession = RandomDataTestUtils.generateRandomExperimentAccession(); int[] perplexities = new int[] {1, 5, 10, 15, 20}; int perplexity = perplexities[ThreadLocalRandom.current().nextInt(0, perplexities.length)]; String geneId = RandomDataTestUtils.generateRandomEnsemblGeneId(); Set<TSnePoint.Dto> randomPointDtos = RandomDataTestUtils.generateRandomTSnePointDtosWithExpression(NUMBER_OF_CELLS); when(tSnePlotDaoMock.fetchTSnePlotWithExpression(experimentAccession, perplexity, geneId)) .thenReturn(ImmutableList.copyOf(randomPointDtos)); Set<TSnePoint> results = subject.fetchTSnePlotWithExpression(experimentAccession, perplexity, geneId); assertThat(results) .containsExactlyInAnyOrder( randomPointDtos.stream() .map(dto -> TSnePoint.create( MathUtils.round(dto.x(), 2), MathUtils.round(dto.y(), 2), dto.expressionLevel(), dto.name())) .toArray(TSnePoint[]::new)); }