Skip to content

Commit

Permalink
Added additional testcase for nested HTTP client exception mercedes-b…
Browse files Browse the repository at this point in the history
…enz#100

- former commit had no test about a nested exception (where the bad
  Request error was root cause)
  • Loading branch information
de-jcup committed Dec 4, 2019
1 parent b4324cf commit 64231a1
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;

import com.daimler.sechub.sharedkernel.execution.SecHubExecutionException;
import com.daimler.sechub.sharedkernel.resilience.ResilienceContext;
import com.daimler.sechub.sharedkernel.resilience.ResilienceProposal;
import com.daimler.sechub.sharedkernel.resilience.RetryResilienceProposal;
Expand Down Expand Up @@ -62,4 +63,21 @@ public void http_bad_request_400_exception_returns_retry_proposal_with_3_retries
assertEquals(2000, rrp.getMillisecondsToWaitBeforeRetry());
}

@Test
public void nested_http_bad_request_400_exception_wrapped_in_runtime_and_sechubexecution_exception_returns_retry_proposal_with_3_retries_and_2000_millis_to_wait() {

/* prepare*/
when(context.getCurrentError()).thenReturn(new SecHubExecutionException("se1",new RuntimeException(new HttpClientErrorException(HttpStatus.BAD_REQUEST))));

/* execute*/
ResilienceProposal proposal = consultantToTest.consultFor(context);

/* test*/
assertNotNull(proposal);
assertTrue(proposal instanceof RetryResilienceProposal);
RetryResilienceProposal rrp = (RetryResilienceProposal) proposal;
assertEquals(3, rrp.getMaximumAmountOfRetries());
assertEquals(2000, rrp.getMillisecondsToWaitBeforeRetry());
}

}

0 comments on commit 64231a1

Please sign in to comment.