AwsApaRequesterImpl implements AwsApaRequester { @Override public Response<ItemLookupResponse> itemLookupAsync( ItemLookupRequest request) throws ExecutionException, InterruptedException { AWSECommerceServicePortType port = preparePort(); ItemLookup itemLookup = prepareItemLookup(request); Response<ItemLookupResponse> response = port .itemLookupAsync(itemLookup); return response; } AwsApaRequesterImpl();  AwsApaRequesterImpl(String endpoint, String accessKeyId,
                               String secretAccessKey, String associateTag); @Override ItemSearchResponse itemSearch(ItemSearchRequest request); @Override Response<ItemSearchResponse> itemSearchAsync(
            ItemSearchRequest request); T invokeWithRetry(WebServiceInvoker<T> invoker); @Override ItemLookupResponse itemLookup(ItemLookupRequest request); @Override Response<ItemLookupResponse> itemLookupAsync(
            ItemLookupRequest request); T getResponseWithRetry(final Response<T> res); int getRetryCount(); void setRetryCount(int retryCount); long getRetryInterval(); void setRetryInterval(long retryInterval);  }
@Test public void testItemLookupAsync01() throws Exception { String asin = "489471499X"; ItemLookupRequest request = new ItemLookupRequest(); request.getItemId().add(asin); request.getResponseGroup().add("Small"); Response<ItemLookupResponse> res = requester.itemLookupAsync(request); ItemLookupResponse response = res.get(); assertNotNull(response); assertNotNull(response.getItems()); assertTrue(response.getItems().size() == 1); assertNotNull(response.getItems().get(0).getItem()); assertTrue(response.getItems().get(0).getItem().size() == 1); Item item = response.getItems().get(0).getItem().get(0); assertEquals(asin, item.getASIN()); assertNotNull(item.getItemAttributes()); }
@Test public void testItemLookupAsync02() throws Exception { Response<ItemLookupResponse> res = null; { ItemLookupRequest request = new ItemLookupRequest(); request.getItemId().add("489471499X"); request.getResponseGroup().add("Small"); res = requester.itemLookupAsync(request); } Response<ItemLookupResponse> res1 = res; { ItemLookupRequest request = new ItemLookupRequest(); request.getItemId().add("4798024031"); request.getResponseGroup().add("Small"); res = requester.itemLookupAsync(request); } Response<ItemLookupResponse> res2 = res; { ItemLookupRequest request = new ItemLookupRequest(); request.getItemId().add("4797339535"); request.getResponseGroup().add("Small"); res = requester.itemLookupAsync(request); } Response<ItemLookupResponse> res3 = res; { ItemLookupResponse response = res1.get(); assertNotNull(response); assertNotNull(response.getItems()); assertTrue(response.getItems().size() == 1); assertNotNull(response.getItems().get(0).getItem()); assertTrue(response.getItems().get(0).getItem().size() == 1); Item item = response.getItems().get(0).getItem().get(0); assertEquals("489471499X", item.getASIN()); assertNotNull(item.getItemAttributes()); } { ItemLookupResponse response = res2.get(); assertNotNull(response); assertNotNull(response.getItems()); assertTrue(response.getItems().size() == 1); assertNotNull(response.getItems().get(0).getItem()); assertTrue(response.getItems().get(0).getItem().size() == 1); Item item = response.getItems().get(0).getItem().get(0); assertEquals("4798024031", item.getASIN()); assertNotNull(item.getItemAttributes()); } { ItemLookupResponse response = res3.get(); assertNotNull(response); assertNotNull(response.getItems()); assertTrue(response.getItems().size() == 1); assertNotNull(response.getItems().get(0).getItem()); assertTrue(response.getItems().get(0).getItem().size() == 1); Item item = response.getItems().get(0).getItem().get(0); assertEquals("4797339535", item.getASIN()); assertNotNull(item.getItemAttributes()); } }