@Test public void makesRequestsInBatchesOfQueryMaxSize() { when(restTemplateMock.postForObject(eq(ReactomeClient.URL), anyString(), eq(String.class))).thenReturn(""); subject.getPathwayNames(SET_OF_45_STABLE_IDS); int numberOfCalls = SET_OF_45_STABLE_IDS.size() / ReactomeClient.QUERY_MAX_SIZE + 1; ArgumentCaptor<String> postData = ArgumentCaptor.forClass(String.class); verify(restTemplateMock, times(numberOfCalls)) .postForObject(eq(ReactomeClient.URL), postData.capture(), eq(String.class)); for (int i = 0; i < numberOfCalls - 1; i++) { assertThat(postData.getAllValues().get(i).split(",").length, is(ReactomeClient.QUERY_MAX_SIZE)); } assertThat( postData.getAllValues().get(numberOfCalls - 1).split(",").length, is(SET_OF_45_STABLE_IDS.size() % ReactomeClient.QUERY_MAX_SIZE)); }
public ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds) { ImmutableMap.Builder<String, String> mappedStableIdsBuilder = ImmutableMap.builder(); for (List<String> partition : getPartitions(stableIds)) { mappedStableIdsBuilder.putAll(fetchPathwayNames(partition)); } return getMappedIds(stableIds, mappedStableIdsBuilder); }
ReactomeClient { public ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds) { ImmutableMap.Builder<String, String> mappedStableIdsBuilder = ImmutableMap.builder(); for (List<String> partition : getPartitions(stableIds)) { mappedStableIdsBuilder.putAll(fetchPathwayNames(partition)); } return getMappedIds(stableIds, mappedStableIdsBuilder); } }
ReactomeClient { public ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds) { ImmutableMap.Builder<String, String> mappedStableIdsBuilder = ImmutableMap.builder(); for (List<String> partition : getPartitions(stableIds)) { mappedStableIdsBuilder.putAll(fetchPathwayNames(partition)); } return getMappedIds(stableIds, mappedStableIdsBuilder); } @Inject  ReactomeClient(RestTemplate restTemplate); }
ReactomeClient { public ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds) { ImmutableMap.Builder<String, String> mappedStableIdsBuilder = ImmutableMap.builder(); for (List<String> partition : getPartitions(stableIds)) { mappedStableIdsBuilder.putAll(fetchPathwayNames(partition)); } return getMappedIds(stableIds, mappedStableIdsBuilder); } @Inject  ReactomeClient(RestTemplate restTemplate); Optional<String> getPathwayName(String reactomeId); Optional<String> getPlantPathwayName(String reactomeId); ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds); ImmutableMap<String, String> getPlantPathwayNames(Collection<String> stableIds); }
ReactomeClient { public ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds) { ImmutableMap.Builder<String, String> mappedStableIdsBuilder = ImmutableMap.builder(); for (List<String> partition : getPartitions(stableIds)) { mappedStableIdsBuilder.putAll(fetchPathwayNames(partition)); } return getMappedIds(stableIds, mappedStableIdsBuilder); } @Inject  ReactomeClient(RestTemplate restTemplate); Optional<String> getPathwayName(String reactomeId); Optional<String> getPlantPathwayName(String reactomeId); ImmutableMap<String, String> getPathwayNames(Collection<String> stableIds); ImmutableMap<String, String> getPlantPathwayNames(Collection<String> stableIds);  }