@Test public void test_StandardCase() { final MockedCallout callout1 = createAndRegisterMockedCallout(field); final MockedCallout callout2 = createAndRegisterMockedCallout(field); final MockedCallout callout3 = createAndRegisterMockedCallout(field); calloutExecutor.execute(field); Assert.assertTrue("Callout1 was not called", callout1.isCalled()); Assert.assertTrue("Callout2 was not called", callout2.isCalled()); Assert.assertTrue("Callout3 was not called", callout3.isCalled()); }
@Test public void test_StopExecutionOnFirstFailingCallout() { final MockedCallout callout1 = createAndRegisterMockedCallout(field); final MockedCallout callout2 = createAndRegisterMockedCallout(field); callout2.setOnExecuteFailException(new CalloutExecutionException("test")); final MockedCallout callout3 = createAndRegisterMockedCallout(field); assertExceptionOnExecute(field, CalloutExecutionException.class); Assert.assertTrue("Callout1 shall be called again", callout1.isCalled()); Assert.assertTrue("Callout2 shall be called again", callout2.isCalled()); Assert.assertFalse("Callout3 shall be called again", callout3.isCalled()); }
@Test public void test_FailingCallout_CalloutInitException() { final MockedCallout callout1 = createAndRegisterMockedCallout(field); callout1.setOnExecuteFailException(new CalloutInitException("test")); // // First run assertExceptionOnExecute(field, CalloutInitException.class); Assert.assertTrue("Callout1 was not called", callout1.isCalled()); Assert.assertFalse( "Callout shall be removed from active callouts list", calloutExecutor.hasCallouts(field)); // // Second run - callout shall not be called again callout1.setCalled(false); calloutExecutor.execute(field); Assert.assertFalse("Callout1 shall NOT be called again", callout1.isCalled()); }