@Test public void testMalformedTsvHeaderResult() { String url = UriComponentsBuilder .fromUriString(GSA_URL_PATTERN) .buildAndExpand(ARABIDOPSIS_SPECIES, GENE_IDS) .encode() .toUriString(); mockServer.expect(requestTo(url)) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(TSV_WITH_BAD_HEADER, MediaType.TEXT_PLAIN)); List<String> bioentityIdentifiers = Arrays.asList(GENE_IDS.split("\\W+")); Pair<Optional<Exception>, Optional<JsonArray>> result = subject.fetchEnrichedGenes(ARABIDOPSIS_SPECIES, bioentityIdentifiers); assertThat(result.getRight()).isEmpty(); assertThat(result.getLeft()).isPresent(); }
public Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName, Collection<String> bioentityIdentifiers) { try { Pair<Optional<String>, Optional<JsonArray>> errorOrResponse = formatResponse(fetchResponse(speciesName, bioentityIdentifiers)); return errorOrResponse.getLeft().isPresent() ? Pair.of(errorOrResponse.getLeft().map(RuntimeException::new), Optional.empty()) : Pair.of(Optional.empty(), errorOrResponse.getRight()); } catch (Exception e) { LOGGER.error(e.getMessage()); return Pair.of(Optional.of(e), Optional.empty()); } }
GeneSetEnrichmentClient { public Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName, Collection<String> bioentityIdentifiers) { try { Pair<Optional<String>, Optional<JsonArray>> errorOrResponse = formatResponse(fetchResponse(speciesName, bioentityIdentifiers)); return errorOrResponse.getLeft().isPresent() ? Pair.of(errorOrResponse.getLeft().map(RuntimeException::new), Optional.empty()) : Pair.of(Optional.empty(), errorOrResponse.getRight()); } catch (Exception e) { LOGGER.error(e.getMessage()); return Pair.of(Optional.of(e), Optional.empty()); } } }
GeneSetEnrichmentClient { public Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName, Collection<String> bioentityIdentifiers) { try { Pair<Optional<String>, Optional<JsonArray>> errorOrResponse = formatResponse(fetchResponse(speciesName, bioentityIdentifiers)); return errorOrResponse.getLeft().isPresent() ? Pair.of(errorOrResponse.getLeft().map(RuntimeException::new), Optional.empty()) : Pair.of(Optional.empty(), errorOrResponse.getRight()); } catch (Exception e) { LOGGER.error(e.getMessage()); return Pair.of(Optional.of(e), Optional.empty()); } } @Inject  GeneSetEnrichmentClient(RestTemplate restTemplate); }
GeneSetEnrichmentClient { public Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName, Collection<String> bioentityIdentifiers) { try { Pair<Optional<String>, Optional<JsonArray>> errorOrResponse = formatResponse(fetchResponse(speciesName, bioentityIdentifiers)); return errorOrResponse.getLeft().isPresent() ? Pair.of(errorOrResponse.getLeft().map(RuntimeException::new), Optional.empty()) : Pair.of(Optional.empty(), errorOrResponse.getRight()); } catch (Exception e) { LOGGER.error(e.getMessage()); return Pair.of(Optional.of(e), Optional.empty()); } } @Inject  GeneSetEnrichmentClient(RestTemplate restTemplate); Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName,
                                                                             Collection<String> bioentityIdentifiers); }
GeneSetEnrichmentClient { public Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName, Collection<String> bioentityIdentifiers) { try { Pair<Optional<String>, Optional<JsonArray>> errorOrResponse = formatResponse(fetchResponse(speciesName, bioentityIdentifiers)); return errorOrResponse.getLeft().isPresent() ? Pair.of(errorOrResponse.getLeft().map(RuntimeException::new), Optional.empty()) : Pair.of(Optional.empty(), errorOrResponse.getRight()); } catch (Exception e) { LOGGER.error(e.getMessage()); return Pair.of(Optional.of(e), Optional.empty()); } } @Inject  GeneSetEnrichmentClient(RestTemplate restTemplate); Pair<Optional<Exception>, Optional<JsonArray>> fetchEnrichedGenes(String speciesName,
                                                                             Collection<String> bioentityIdentifiers);  }