Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zwright committed Dec 21, 2023
1 parent 020b126 commit e7f3334
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
27 changes: 14 additions & 13 deletions src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ public int compare(ClusterHierarchy a, ClusterHierarchy b) {

public List<String> findDataTypesByClusterName(String clusterName) {
List<String> 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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<ClusterHierarchy> clusterHierarchies = new ArrayList<>();
when(clusterHierarchyRepo.findByCellType("Tubules")).thenReturn(clusterHierarchies);
when(clusterHierarchyRepo.findByCellType("Interstitium")).thenReturn(clusterHierarchies);
List<ClusterHierarchy> clusters = service.findClustersByCellType("Tubules");
assertEquals("Tubulo-interstitium", clusters.get(0).getStructureRegion());
List<ClusterHierarchy> clusters2 = service.findClustersByCellType("Interstitium");
assertEquals("Tubulo-interstitium", clusters2.get(0).getStructureRegion());
}

@Test
public void testFindDataTypesByClusterNameTi() throws Exception {
List<String> 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()));
}
}

0 comments on commit e7f3334

Please sign in to comment.