@Test public void testFetchGenesOnRegion() throws IOException, ExternalDbUnavailableException, InterruptedException { String fetchRes = readFile("ensembl_overlap_gene.json"); Mockito.when( httpDataManager.fetchData(Mockito.any(), Mockito.any(ParameterNameValue[].class)) ).thenReturn(fetchRes); List<EnsemblEntryVO> ensemblGeneList = ensemblDataManager.fetchVariationsOnRegion("human", "140424943", "140624564", "7"); Assert.assertNotNull(ensemblGeneList); Assert.assertEquals(6, ensemblGeneList.size()); EnsemblEntryVO ensemblEntryVO = ensemblGeneList.get(0); Assert.assertNotNull(ensemblEntryVO); Assert.assertTrue(ensemblEntryVO.getStart().equals(START_ENTRY)); Assert.assertTrue(ensemblEntryVO.getEnd().equals(END_ENTRY)); }
public List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome, String start, String finish) throws ExternalDbUnavailableException { ParameterNameValue[] params = new ParameterNameValue[]{ new ParameterNameValue("feature", ENSEMBL_VARIATION_TOOL), new ParameterNameValue(CONTENT_TYPE, APPLICATION_JSON)}; String location = String.format("%s%s/%s/%s", ENSEMBL_SERVER, ENSEMBL_OVERLAP_TOOL, species, chromosome + ":" + start + "-" + finish + "?"); String variationData = httpDataManager.fetchData(location, params); List<EnsemblEntryVO> variationEntryVOList = Collections.emptyList(); if (StringUtils.isNotEmpty(variationData)) { try { variationEntryVOList = objectMapper.readValue(variationData, objectMapper.getTypeFactory().constructCollectionType(List.class, EnsemblEntryVO.class)); } catch (IOException e) { throw new ExternalDbUnavailableException(MessageHelper.getMessage(MessagesConstants .ERROR_NO_DATA_FOR_URL, location), e); } } return variationEntryVOList; }
EnsemblDataManager { public List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome, String start, String finish) throws ExternalDbUnavailableException { ParameterNameValue[] params = new ParameterNameValue[]{ new ParameterNameValue("feature", ENSEMBL_VARIATION_TOOL), new ParameterNameValue(CONTENT_TYPE, APPLICATION_JSON)}; String location = String.format("%s%s/%s/%s", ENSEMBL_SERVER, ENSEMBL_OVERLAP_TOOL, species, chromosome + ":" + start + "-" + finish + "?"); String variationData = httpDataManager.fetchData(location, params); List<EnsemblEntryVO> variationEntryVOList = Collections.emptyList(); if (StringUtils.isNotEmpty(variationData)) { try { variationEntryVOList = objectMapper.readValue(variationData, objectMapper.getTypeFactory().constructCollectionType(List.class, EnsemblEntryVO.class)); } catch (IOException e) { throw new ExternalDbUnavailableException(MessageHelper.getMessage(MessagesConstants .ERROR_NO_DATA_FOR_URL, location), e); } } return variationEntryVOList; } }
EnsemblDataManager { public List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome, String start, String finish) throws ExternalDbUnavailableException { ParameterNameValue[] params = new ParameterNameValue[]{ new ParameterNameValue("feature", ENSEMBL_VARIATION_TOOL), new ParameterNameValue(CONTENT_TYPE, APPLICATION_JSON)}; String location = String.format("%s%s/%s/%s", ENSEMBL_SERVER, ENSEMBL_OVERLAP_TOOL, species, chromosome + ":" + start + "-" + finish + "?"); String variationData = httpDataManager.fetchData(location, params); List<EnsemblEntryVO> variationEntryVOList = Collections.emptyList(); if (StringUtils.isNotEmpty(variationData)) { try { variationEntryVOList = objectMapper.readValue(variationData, objectMapper.getTypeFactory().constructCollectionType(List.class, EnsemblEntryVO.class)); } catch (IOException e) { throw new ExternalDbUnavailableException(MessageHelper.getMessage(MessagesConstants .ERROR_NO_DATA_FOR_URL, location), e); } } return variationEntryVOList; }  }
EnsemblDataManager { public List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome, String start, String finish) throws ExternalDbUnavailableException { ParameterNameValue[] params = new ParameterNameValue[]{ new ParameterNameValue("feature", ENSEMBL_VARIATION_TOOL), new ParameterNameValue(CONTENT_TYPE, APPLICATION_JSON)}; String location = String.format("%s%s/%s/%s", ENSEMBL_SERVER, ENSEMBL_OVERLAP_TOOL, species, chromosome + ":" + start + "-" + finish + "?"); String variationData = httpDataManager.fetchData(location, params); List<EnsemblEntryVO> variationEntryVOList = Collections.emptyList(); if (StringUtils.isNotEmpty(variationData)) { try { variationEntryVOList = objectMapper.readValue(variationData, objectMapper.getTypeFactory().constructCollectionType(List.class, EnsemblEntryVO.class)); } catch (IOException e) { throw new ExternalDbUnavailableException(MessageHelper.getMessage(MessagesConstants .ERROR_NO_DATA_FOR_URL, location), e); } } return variationEntryVOList; }  EnsemblEntryVO fetchEnsemblEntry(String geneId); EnsemblVariationEntryVO fetchVariationEntry(String variationId, String species); List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome,
                                                        String start, String finish); }
EnsemblDataManager { public List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome, String start, String finish) throws ExternalDbUnavailableException { ParameterNameValue[] params = new ParameterNameValue[]{ new ParameterNameValue("feature", ENSEMBL_VARIATION_TOOL), new ParameterNameValue(CONTENT_TYPE, APPLICATION_JSON)}; String location = String.format("%s%s/%s/%s", ENSEMBL_SERVER, ENSEMBL_OVERLAP_TOOL, species, chromosome + ":" + start + "-" + finish + "?"); String variationData = httpDataManager.fetchData(location, params); List<EnsemblEntryVO> variationEntryVOList = Collections.emptyList(); if (StringUtils.isNotEmpty(variationData)) { try { variationEntryVOList = objectMapper.readValue(variationData, objectMapper.getTypeFactory().constructCollectionType(List.class, EnsemblEntryVO.class)); } catch (IOException e) { throw new ExternalDbUnavailableException(MessageHelper.getMessage(MessagesConstants .ERROR_NO_DATA_FOR_URL, location), e); } } return variationEntryVOList; }  EnsemblEntryVO fetchEnsemblEntry(String geneId); EnsemblVariationEntryVO fetchVariationEntry(String variationId, String species); List<EnsemblEntryVO> fetchVariationsOnRegion(String species, String chromosome,
                                                        String start, String finish);  }