@Test public void loadReturnsCorrectDataWhenReadingFromSourceWithNonEnglishChars() { final Collection<SolrInputDocument> data = this.oncoTree.load(this.url); Assert.assertEquals(8, data.size()); for (final SolrInputDocument datum : data) { switch ((String) datum.getFieldValue(ID)) { case PREFIX + ACA_LABEL: Assert.assertEquals(7, datum.size()); Assert.assertEquals(ADRENAL_GLAND_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(ACA_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(ADRENOCORTICAL_CARCINOMA_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(PURPLE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C9003", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C0206667", datum.getFieldValue(UMLS_ID)); break; case PREFIX + EGC_LABEL: Assert.assertEquals(7, datum.size()); Assert.assertEquals(ESOPHAGUS_STOMACH_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(EGC_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(ESOPHAGOGASTRIC_CANCER_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(BLUE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C9296", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C1332166", datum.getFieldValue(UMLS_ID)); break; case PREFIX + STAD_LABEL: final Set<String> stadTermCategory = new HashSet<>(); stadTermCategory.add(PREFIX + EGC_LABEL); Assert.assertEquals(9, datum.size()); Assert.assertEquals(ESOPHAGUS_STOMACH_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(STAD_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(ESOPHAGOGASTRIC_CANCER_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(BLUE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C4004", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C0278701", datum.getFieldValue(UMLS_ID)); Assert.assertEquals(PREFIX + EGC_LABEL, datum.getFieldValue(IS_A)); Assert.assertEquals(stadTermCategory, datum.getFieldValues(TERM_CATEGORY)); break; case PREFIX + DSTAD_LABEL: final Set<String> dstadTermCategory = new HashSet<>(); dstadTermCategory.add(PREFIX + EGC_LABEL); dstadTermCategory.add(PREFIX + STAD_LABEL); Assert.assertEquals(9, datum.size()); Assert.assertEquals(ESOPHAGUS_STOMACH_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(DSTAD_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(ESOPHAGOGASTRIC_CANCER_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(BLUE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C9159", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C0279635", datum.getFieldValue(UMLS_ID)); Assert.assertEquals(PREFIX + STAD_LABEL, datum.getFieldValue(IS_A)); Assert.assertEquals(dstadTermCategory, datum.getFieldValues(TERM_CATEGORY)); break; case PREFIX + TET_LABEL: Assert.assertEquals(7, datum.size()); Assert.assertEquals(THYMUS_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(TET_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(THYMIC_TUMOR_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(PURPLE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C6450", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C1266101", datum.getFieldValue(UMLS_ID)); break; case PREFIX + THYC_LABEL: final Set<String> tetTermCategory = new HashSet<>(); tetTermCategory.add(PREFIX + TET_LABEL); Assert.assertEquals(9, datum.size()); Assert.assertEquals(THYMUS_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(THYC_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(THYMIC_TUMOR_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(PURPLE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("C7569", datum.getFieldValue(NCI_ID)); Assert.assertEquals("C0205969", datum.getFieldValue(UMLS_ID)); Assert.assertEquals(PREFIX + TET_LABEL, datum.getFieldValue(IS_A)); Assert.assertEquals(tetTermCategory, datum.getFieldValues(TERM_CATEGORY)); break; case PREFIX + TNET_LABEL: Assert.assertEquals(6, datum.size()); Assert.assertEquals(THYMUS_LABEL, datum.getFieldValue(TISSUE)); Assert.assertEquals(TNET_NAME_LABEL, datum.getFieldValue(NAME)); Assert.assertEquals(THYMIC_TUMOR_LABEL, datum.getFieldValue(TERM_GROUP)); Assert.assertEquals(PURPLE_LABEL, datum.getFieldValue(COLOUR)); Assert.assertEquals("CL511204", datum.getFieldValue(UMLS_ID)); break; case HEADER_INFO_LABEL: Assert.assertEquals(2, datum.size()); Assert.assertNotNull(datum.getFieldValue(VERSION_FIELD_NAME)); break; default: Assert.fail(); } } }
@Override protected Collection<SolrInputDocument> load(@Nonnull final URL url) { this.dataMap = new HashMap<>(); try (BufferedReader in = new BufferedReader( new InputStreamReader(getInputStream(url), StandardCharsets.UTF_8))) { final CSVFormat parser = setupCSVParser(); final CSVParser parsed = parser.parse(in); this.header = parsed.getHeaderMap().entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); for (final CSVRecord row : parsed) { processDataRow(row); } this.dataMap.put(VERSION_FIELD_NAME, getVersionDoc(url)); } catch (final IOException e) { this.logger.error("Failed to load vocabulary source: {}", e.getMessage()); } return this.dataMap.values(); }
OncoTree extends AbstractCSVSolrVocabulary { @Override protected Collection<SolrInputDocument> load(@Nonnull final URL url) { this.dataMap = new HashMap<>(); try (BufferedReader in = new BufferedReader( new InputStreamReader(getInputStream(url), StandardCharsets.UTF_8))) { final CSVFormat parser = setupCSVParser(); final CSVParser parsed = parser.parse(in); this.header = parsed.getHeaderMap().entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); for (final CSVRecord row : parsed) { processDataRow(row); } this.dataMap.put(VERSION_FIELD_NAME, getVersionDoc(url)); } catch (final IOException e) { this.logger.error("Failed to load vocabulary source: {}", e.getMessage()); } return this.dataMap.values(); } }
OncoTree extends AbstractCSVSolrVocabulary { @Override protected Collection<SolrInputDocument> load(@Nonnull final URL url) { this.dataMap = new HashMap<>(); try (BufferedReader in = new BufferedReader( new InputStreamReader(getInputStream(url), StandardCharsets.UTF_8))) { final CSVFormat parser = setupCSVParser(); final CSVParser parsed = parser.parse(in); this.header = parsed.getHeaderMap().entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); for (final CSVRecord row : parsed) { processDataRow(row); } this.dataMap.put(VERSION_FIELD_NAME, getVersionDoc(url)); } catch (final IOException e) { this.logger.error("Failed to load vocabulary source: {}", e.getMessage()); } return this.dataMap.values(); }  }
OncoTree extends AbstractCSVSolrVocabulary { @Override protected Collection<SolrInputDocument> load(@Nonnull final URL url) { this.dataMap = new HashMap<>(); try (BufferedReader in = new BufferedReader( new InputStreamReader(getInputStream(url), StandardCharsets.UTF_8))) { final CSVFormat parser = setupCSVParser(); final CSVParser parsed = parser.parse(in); this.header = parsed.getHeaderMap().entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); for (final CSVRecord row : parsed) { processDataRow(row); } this.dataMap.put(VERSION_FIELD_NAME, getVersionDoc(url)); } catch (final IOException e) { this.logger.error("Failed to load vocabulary source: {}", e.getMessage()); } return this.dataMap.values(); }  @Override String getIdentifier(); @Override String getName(); @Override Set<String> getAliases(); @Override String getDefaultSourceLocation(); @Override String getWebsite(); @Override String getCitation(); @Override List<VocabularyTerm> search(
        @Nullable final String input,
        final int maxResults,
        @Nullable final String sort,
        @Nullable final String customFilter); @Override Collection<String> getSupportedCategories(); }
OncoTree extends AbstractCSVSolrVocabulary { @Override protected Collection<SolrInputDocument> load(@Nonnull final URL url) { this.dataMap = new HashMap<>(); try (BufferedReader in = new BufferedReader( new InputStreamReader(getInputStream(url), StandardCharsets.UTF_8))) { final CSVFormat parser = setupCSVParser(); final CSVParser parsed = parser.parse(in); this.header = parsed.getHeaderMap().entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); for (final CSVRecord row : parsed) { processDataRow(row); } this.dataMap.put(VERSION_FIELD_NAME, getVersionDoc(url)); } catch (final IOException e) { this.logger.error("Failed to load vocabulary source: {}", e.getMessage()); } return this.dataMap.values(); }  @Override String getIdentifier(); @Override String getName(); @Override Set<String> getAliases(); @Override String getDefaultSourceLocation(); @Override String getWebsite(); @Override String getCitation(); @Override List<VocabularyTerm> search(
        @Nullable final String input,
        final int maxResults,
        @Nullable final String sort,
        @Nullable final String customFilter); @Override Collection<String> getSupportedCategories();  }