@Test public void testRetryStopsForJsonParseError() throws Exception { String projectId = "02a70003-e864-464e-b62c-e0ede97deb8c"; final int retryAttempts = 2; final AtomicInteger sentErrorCount = new AtomicInteger(0); this.serverBootstrap.registerHandler( String.format("/%s/%s", projectId, "items/on_roasts"), (request, response, context) -> { response.setEntity(new StringEntity("Response Error!")); sentErrorCount.getAndIncrement(); }); HttpHost httpHost = this.start(); String testServerUri = httpHost.toURI(); DeliveryOptions deliveryOptions = DeliveryOptions.builder() .projectId(projectId) .productionEndpoint(testServerUri) .retryAttempts(3) .build(); deliveryOptions.setProjectId(projectId); deliveryOptions.setProductionEndpoint(testServerUri); deliveryOptions.setRetryAttempts(retryAttempts); try { DeliveryClient client = new DeliveryClient(deliveryOptions); client.getItem("on_roasts") .toCompletableFuture() .get(); Assert.fail("Expected a failure exception"); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof JsonParseException); } Assert.assertEquals(1, sentErrorCount.get()); }
@SuppressWarnings("unused") public CompletionStage<ContentItemResponse> getItem(String contentItemCodename) { return getItem(contentItemCodename, Collections.emptyList()); }
DeliveryClient { @SuppressWarnings("unused") public CompletionStage<ContentItemResponse> getItem(String contentItemCodename) { return getItem(contentItemCodename, Collections.emptyList()); } }
DeliveryClient { @SuppressWarnings("unused") public CompletionStage<ContentItemResponse> getItem(String contentItemCodename) { return getItem(contentItemCodename, Collections.emptyList()); } @SuppressWarnings("WeakerAccess")  DeliveryClient(DeliveryOptions deliveryOptions); @SuppressWarnings({"ResultOfMethodCallIgnored", "WeakerAccess"})  DeliveryClient(DeliveryOptions deliveryOptions, TemplateEngineConfig templateEngineConfig); @SuppressWarnings("unused")  DeliveryClient(String projectId); @SuppressWarnings("unused")  DeliveryClient(String projectId, String previewApiKey); }
DeliveryClient { @SuppressWarnings("unused") public CompletionStage<ContentItemResponse> getItem(String contentItemCodename) { return getItem(contentItemCodename, Collections.emptyList()); } @SuppressWarnings("WeakerAccess")  DeliveryClient(DeliveryOptions deliveryOptions); @SuppressWarnings({"ResultOfMethodCallIgnored", "WeakerAccess"})  DeliveryClient(DeliveryOptions deliveryOptions, TemplateEngineConfig templateEngineConfig); @SuppressWarnings("unused")  DeliveryClient(String projectId); @SuppressWarnings("unused")  DeliveryClient(String projectId, String previewApiKey); CompletionStage<ContentItemsListingResponse> getItems(); @SuppressWarnings("WeakerAccess") CompletionStage<ContentItemsListingResponse> getItems(List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<List<T>> getItems(Class<T> tClass, List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<ContentItemResponse> getItem(String contentItemCodename); @SuppressWarnings("unused") CompletionStage<List<T>> getItems(Class<T> tClass); @SuppressWarnings("WeakerAccess") CompletionStage<Page<T>> getPageOfItems(Class<T> tClass, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<Page<T>> getNextPage(Page<T> currentPage); @SuppressWarnings("unused") CompletionStage<T> getItem(String contentItemCodename, Class<T> tClass); @SuppressWarnings("WeakerAccess") CompletionStage<ContentItemResponse> getItem(String contentItemCodename, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<T> getItem(String contentItemCodename, Class<T> tClass, List<NameValuePair> params); CompletionStage<ContentTypesListingResponse> getTypes(); @SuppressWarnings("WeakerAccess") CompletionStage<ContentTypesListingResponse> getTypes(List<NameValuePair> params); CompletionStage<ContentType> getType(String contentTypeCodeName); @SuppressWarnings("unused") CompletionStage<Element> getContentTypeElement(String contentTypeCodeName, String elementCodeName); @SuppressWarnings("WeakerAccess") CompletionStage<Element> getContentTypeElement(
            String contentTypeCodeName, String elementCodeName, List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<TaxonomyGroupListingResponse> getTaxonomyGroups(); @SuppressWarnings("WeakerAccess") CompletionStage<TaxonomyGroupListingResponse> getTaxonomyGroups(List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<TaxonomyGroup> getTaxonomyGroup(String taxonomyGroupCodename); @SuppressWarnings("WeakerAccess") CompletionStage<TaxonomyGroup> getTaxonomyGroup(String taxonomyGroupCodename, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") ContentLinkUrlResolver getContentLinkUrlResolver(); @SuppressWarnings("WeakerAccess") void setContentLinkUrlResolver(ContentLinkUrlResolver contentLinkUrlResolver); @SuppressWarnings("WeakerAccess") BrokenLinkUrlResolver getBrokenLinkUrlResolver(); @SuppressWarnings("WeakerAccess") void setBrokenLinkUrlResolver(BrokenLinkUrlResolver brokenLinkUrlResolver); @SuppressWarnings("WeakerAccess") RichTextElementResolver getRichTextElementResolver(); @SuppressWarnings("WeakerAccess") void setRichTextElementResolver(RichTextElementResolver richTextElementResolver); @SuppressWarnings("WeakerAccess") void addRichTextElementResolver(RichTextElementResolver richTextElementResolver); @SuppressWarnings("WeakerAccess") void registerType(String contentType, Class<?> clazz); @SuppressWarnings("WeakerAccess") void registerType(Class<?> clazz); @SuppressWarnings("WeakerAccess") void registerInlineContentItemsResolver(InlineContentItemsResolver resolver); @SuppressWarnings("WeakerAccess") void scanClasspathForMappings(String basePackage); @SuppressWarnings("WeakerAccess") void setCacheManager(AsyncCacheManager cacheManager); void setCacheManager(final CacheManager cacheManager); }
DeliveryClient { @SuppressWarnings("unused") public CompletionStage<ContentItemResponse> getItem(String contentItemCodename) { return getItem(contentItemCodename, Collections.emptyList()); } @SuppressWarnings("WeakerAccess")  DeliveryClient(DeliveryOptions deliveryOptions); @SuppressWarnings({"ResultOfMethodCallIgnored", "WeakerAccess"})  DeliveryClient(DeliveryOptions deliveryOptions, TemplateEngineConfig templateEngineConfig); @SuppressWarnings("unused")  DeliveryClient(String projectId); @SuppressWarnings("unused")  DeliveryClient(String projectId, String previewApiKey); CompletionStage<ContentItemsListingResponse> getItems(); @SuppressWarnings("WeakerAccess") CompletionStage<ContentItemsListingResponse> getItems(List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<List<T>> getItems(Class<T> tClass, List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<ContentItemResponse> getItem(String contentItemCodename); @SuppressWarnings("unused") CompletionStage<List<T>> getItems(Class<T> tClass); @SuppressWarnings("WeakerAccess") CompletionStage<Page<T>> getPageOfItems(Class<T> tClass, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<Page<T>> getNextPage(Page<T> currentPage); @SuppressWarnings("unused") CompletionStage<T> getItem(String contentItemCodename, Class<T> tClass); @SuppressWarnings("WeakerAccess") CompletionStage<ContentItemResponse> getItem(String contentItemCodename, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") CompletionStage<T> getItem(String contentItemCodename, Class<T> tClass, List<NameValuePair> params); CompletionStage<ContentTypesListingResponse> getTypes(); @SuppressWarnings("WeakerAccess") CompletionStage<ContentTypesListingResponse> getTypes(List<NameValuePair> params); CompletionStage<ContentType> getType(String contentTypeCodeName); @SuppressWarnings("unused") CompletionStage<Element> getContentTypeElement(String contentTypeCodeName, String elementCodeName); @SuppressWarnings("WeakerAccess") CompletionStage<Element> getContentTypeElement(
            String contentTypeCodeName, String elementCodeName, List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<TaxonomyGroupListingResponse> getTaxonomyGroups(); @SuppressWarnings("WeakerAccess") CompletionStage<TaxonomyGroupListingResponse> getTaxonomyGroups(List<NameValuePair> params); @SuppressWarnings("unused") CompletionStage<TaxonomyGroup> getTaxonomyGroup(String taxonomyGroupCodename); @SuppressWarnings("WeakerAccess") CompletionStage<TaxonomyGroup> getTaxonomyGroup(String taxonomyGroupCodename, List<NameValuePair> params); @SuppressWarnings("WeakerAccess") ContentLinkUrlResolver getContentLinkUrlResolver(); @SuppressWarnings("WeakerAccess") void setContentLinkUrlResolver(ContentLinkUrlResolver contentLinkUrlResolver); @SuppressWarnings("WeakerAccess") BrokenLinkUrlResolver getBrokenLinkUrlResolver(); @SuppressWarnings("WeakerAccess") void setBrokenLinkUrlResolver(BrokenLinkUrlResolver brokenLinkUrlResolver); @SuppressWarnings("WeakerAccess") RichTextElementResolver getRichTextElementResolver(); @SuppressWarnings("WeakerAccess") void setRichTextElementResolver(RichTextElementResolver richTextElementResolver); @SuppressWarnings("WeakerAccess") void addRichTextElementResolver(RichTextElementResolver richTextElementResolver); @SuppressWarnings("WeakerAccess") void registerType(String contentType, Class<?> clazz); @SuppressWarnings("WeakerAccess") void registerType(Class<?> clazz); @SuppressWarnings("WeakerAccess") void registerInlineContentItemsResolver(InlineContentItemsResolver resolver); @SuppressWarnings("WeakerAccess") void scanClasspathForMappings(String basePackage); @SuppressWarnings("WeakerAccess") void setCacheManager(AsyncCacheManager cacheManager); void setCacheManager(final CacheManager cacheManager);  }