diff --git a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java index 8cba53b..bb817dd 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java @@ -56,22 +56,23 @@ public int compare(ClusterHierarchy a, ClusterHierarchy b) { public List findDataTypesByClusterName(String clusterName) { List dataTypesRepresented = new ArrayList<>(); - ClusterHierarchy clustersInDataTypes = clusterHierarchyRepo.findFirstByClusterOrRegion(clusterName); - if (clustersInDataTypes.getIsSingleCellCluster().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.SINGLE_CELL.getAbbreviation()); - } - if (clustersInDataTypes.getIsSingleNucCluster().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation()); - } - if (clustersInDataTypes.getIsRegionalTranscriptomics().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); - } - if (clustersInDataTypes.getIsRegionalProteomics().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); - } if (clusterName.equals("Tubulo-interstitium")) { dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); + } else { + ClusterHierarchy clustersInDataTypes = clusterHierarchyRepo.findFirstByClusterOrRegion(clusterName); + if (clustersInDataTypes.getIsSingleCellCluster().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.SINGLE_CELL.getAbbreviation()); + } + if (clustersInDataTypes.getIsSingleNucCluster().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation()); + } + if (clustersInDataTypes.getIsRegionalTranscriptomics().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); + } + if (clustersInDataTypes.getIsRegionalProteomics().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); + } } return dataTypesRepresented; } diff --git a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java index 91e58e1..a46778c 100755 --- a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java +++ b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java @@ -1,9 +1,10 @@ package org.kpmp.cellTypeSummary; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -190,4 +191,24 @@ public void testFindDataTypesByClusterNameWhenRPY() throws Exception { assertEquals(Arrays.asList("rp"), dataTypes); verify(clusterHierarchyRepo).findFirstByClusterOrRegion("cluster"); } + + @Test + public void testFindClustersByCellTypeTubulesOrInterstitium() throws Exception { + List clusterHierarchies = new ArrayList<>(); + when(clusterHierarchyRepo.findByCellType("Tubules")).thenReturn(clusterHierarchies); + when(clusterHierarchyRepo.findByCellType("Interstitium")).thenReturn(clusterHierarchies); + List clusters = service.findClustersByCellType("Tubules"); + assertEquals("Tubulo-interstitium", clusters.get(0).getStructureRegion()); + List clusters2 = service.findClustersByCellType("Interstitium"); + assertEquals("Tubulo-interstitium", clusters2.get(0).getStructureRegion()); + } + + @Test + public void testFindDataTypesByClusterNameTi() throws Exception { + List dataTypes = service.findDataTypesByClusterName("Tubulo-interstitium"); + assertTrue(dataTypes.contains(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation())); + assertTrue(dataTypes.contains(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation())); + assertFalse(dataTypes.contains(DataTypeEnum.SINGLE_CELL.getAbbreviation())); + assertFalse(dataTypes.contains(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation())); + } }