@Test public void sortFeaturesWithSections() throws Exception { ConversionHelpers helpers = new ConversionHelpers(); ConversionHelpers helpersSpy = spy(helpers); Feature featureOne = mock(Feature.class); Feature featureTwo = mock(Feature.class); Feature featureThree = mock(Feature.class); Feature featureFour = mock(Feature.class); VocabularyTerm termOne = mock(VocabularyTerm.class); VocabularyTerm termTwo = mock(VocabularyTerm.class); VocabularyTerm termThree = mock(VocabularyTerm.class); VocabularyTerm termFour = mock(VocabularyTerm.class); Set<Feature> features = new HashSet<>(); List<String> mappingIdsOne = new LinkedList<>(); List<String> mappingIdsTwo = new LinkedList<>(); Map<String, List<String>> mapping = new HashMap<>(); features.add(featureOne); features.add(featureTwo); features.add(featureThree); features.add(featureFour); mappingIdsOne.add("id1"); mappingIdsOne.add("id3"); mappingIdsTwo.add("id2"); mapping.put("sectionOne", mappingIdsOne); mapping.put("sectionTwo", mappingIdsTwo); ComponentManager componentManager = mock(ComponentManager.class); Vocabulary ontologyService = mock(Vocabulary.class); List<Map<String, List<String>>> mappingObj = new LinkedList<>(); List<Map<String, List<String>>> mappingObjSpy = spy(mappingObj); PhenotypeMappingService phenotypeMappingService = mock(PhenotypeMappingService.class); doReturn(componentManager).when(helpersSpy).getComponentManager(); doReturn(ontologyService).when(componentManager).getInstance(eq(Vocabulary.class), eq("hpo")); doReturn(phenotypeMappingService).when(componentManager) .getInstance(eq(ScriptService.class), eq("phenotypeMapping")); doReturn(mappingObjSpy).when(phenotypeMappingService).get(anyString()); doReturn(mapping).when(helpersSpy).getCategoryMapping(); doReturn(true).when(featureOne).isPresent(); doReturn(false).when(featureTwo).isPresent(); doReturn(false).when(featureThree).isPresent(); doReturn(true).when(featureFour).isPresent(); doReturn(termOne).when(ontologyService).getTerm("id1"); doReturn(termTwo).when(ontologyService).getTerm("id2"); doReturn(termThree).when(ontologyService).getTerm("id3"); doReturn(mappingIdsOne).when(termOne).get(anyString()); doReturn(mappingIdsOne).when(termThree).get(anyString()); doReturn(mappingIdsTwo).when(termTwo).get(anyString()); doReturn(new LinkedList<String>()).when(termFour).get(anyString()); doReturn("id1").when(featureOne).getId(); doReturn("id2").when(featureTwo).getId(); doReturn("id3").when(featureThree).getId(); doReturn("id4").when(featureFour).getId(); helpersSpy.featureSetUp(true); List<Feature> sorted = helpersSpy.sortFeaturesWithSections(features); Assert.assertTrue(sorted.contains(featureOne)); Assert.assertTrue(sorted.contains(featureTwo)); Assert.assertTrue(sorted.contains(featureThree)); Assert.assertTrue(sorted.contains(featureFour)); Assert.assertTrue(helpersSpy.getSectionFeatureTree().containsKey("id4")); }
public List<Feature> sortFeaturesWithSections(Set<? extends Feature> features) { this.sectionFeatureTree = new HashMap<>(); List<Feature> positiveList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, true)); List<Feature> negativeList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, false)); positiveList.addAll(negativeList); return positiveList; }
ConversionHelpers { public List<Feature> sortFeaturesWithSections(Set<? extends Feature> features) { this.sectionFeatureTree = new HashMap<>(); List<Feature> positiveList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, true)); List<Feature> negativeList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, false)); positiveList.addAll(negativeList); return positiveList; } }
ConversionHelpers { public List<Feature> sortFeaturesWithSections(Set<? extends Feature> features) { this.sectionFeatureTree = new HashMap<>(); List<Feature> positiveList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, true)); List<Feature> negativeList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, false)); positiveList.addAll(negativeList); return positiveList; }  }
ConversionHelpers { public List<Feature> sortFeaturesWithSections(Set<? extends Feature> features) { this.sectionFeatureTree = new HashMap<>(); List<Feature> positiveList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, true)); List<Feature> negativeList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, false)); positiveList.addAll(negativeList); return positiveList; }  @SuppressWarnings("unchecked") void featureSetUp(boolean mapCategories); List<Feature> sortFeaturesSimple(@Nonnull Set<? extends Feature> features); List<Feature> sortFeaturesWithSections(Set<? extends Feature> features); Set<Feature> filterFeaturesByPrenatal(Set<? extends Feature> features, Boolean prenatal); Map<String, List<String>> getCategoryMapping(); Map<String, String> getSectionFeatureTree(); static String strIntegerToStrBool(String strInt); static String integerToStrBool(Integer integer); static List<DataCell> preventOverflow(String value, int x, int y); }
ConversionHelpers { public List<Feature> sortFeaturesWithSections(Set<? extends Feature> features) { this.sectionFeatureTree = new HashMap<>(); List<Feature> positiveList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, true)); List<Feature> negativeList = sortFeaturesBySection(filterFeaturesByPresentStatus(features, false)); positiveList.addAll(negativeList); return positiveList; }  @SuppressWarnings("unchecked") void featureSetUp(boolean mapCategories); List<Feature> sortFeaturesSimple(@Nonnull Set<? extends Feature> features); List<Feature> sortFeaturesWithSections(Set<? extends Feature> features); Set<Feature> filterFeaturesByPrenatal(Set<? extends Feature> features, Boolean prenatal); Map<String, List<String>> getCategoryMapping(); Map<String, String> getSectionFeatureTree(); static String strIntegerToStrBool(String strInt); static String integerToStrBool(Integer integer); static List<DataCell> preventOverflow(String value, int x, int y);  }