Exemplo n.º 1
0
 /** Test method for {@link FailureReport#recoverable()}. */
 @Test
 public void recoverable() {
   this.continueFunction = null;
   final FailureReport<String> failReport = new FailureReport<>();
   failReport.recoverable();
   assertThat(failReport.getContinueRoutine().get(), is(nullValue()));
 }
Exemplo n.º 2
0
 /** Test method for {@link FailureReport#getDetails()}. */
 @Test
 public void getDetails() {
   final FailureReport<String> failReport = new FailureReport<>();
   assertThat(failReport.getDetails(), is(nullValue()));
   final FailureReport<String> failReport1 = new FailureReport<>();
   failReport1.details("testmessage %s", "continued");
   assertThat(failReport1.getDetails(), containsString("testmessage continued"));
 }
Exemplo n.º 3
0
 /** Test method for {@link FailureReport#details()}. */
 @Test
 public void details() {
   final String message = "failureMessage";
   final FailureReport<String> failReport = new FailureReport<>();
   failReport.details("failureMessage");
   assertThat(failReport.getDetails(), containsString(message));
   final ThrowingMethod method =
       () -> {
         final FailureReport<String> failReport1 = new FailureReport<>();
         failReport1.details(null);
       };
   assertThat(method, throwsException(NullPointerException.class));
 }
Exemplo n.º 4
0
 /** Test method for {@link FailureReport#cause()}. */
 @Test
 public void cause() {
   final ThrowingMethod method =
       () -> {
         final FailureReport<String> failReport = new FailureReport<>();
         failReport.cause(null);
       };
   assertThat(method, throwsException(NullPointerException.class));
   final FailureReport<String> failReport1 = new FailureReport<>();
   failReport1.cause(new IllegalArgumentException("illegal arg"));
   assertThat(failReport1.getFailureMessage(), containsString("illegal arg"));
   final FailureReport<String> failReport2 = new FailureReport<>();
   failReport2.message("failure message");
   failReport2.cause(new IllegalArgumentException("illegal arg"));
   assertThat(failReport2.getFailureMessage(), containsString("failure message"));
 }
Exemplo n.º 5
0
  /** Test method for {@link FailureReport#continueWith()}. */
  @Test
  public void continueWith() {
    final FailureReport<String> failReport = new FailureReport<>();
    final Runnable runTest = mock(Runnable.class);
    failReport.continueWith(runTest);
    assertThat(failReport.getContinueRoutine().get(), is(nullValue()));
    verify(runTest).run();

    @SuppressWarnings("unchecked")
    final Supplier<Object> continueTest = mock(Supplier.class);
    final Object returned = mock(Object.class);
    final FailureReport<Object> failReport2 = new FailureReport<>();
    failReport2.continueWith(continueTest);
    given(continueTest.get()).willReturn(returned);
    assertThat(failReport2.getContinueRoutine().get(), is(theInstance(returned)));
  }
Exemplo n.º 6
0
 /** Test method for {@link FailureReport#getRetryRoutine()}. */
 @Test
 public void getRetryRoutine() {
   final FailureReport<String> failReport = new FailureReport<>();
   assertThat(failReport.getRetryRoutine(), is(this.retryFunction));
 }
Exemplo n.º 7
0
 /** Test method for {@link FailureReport#getContinueRoutine()}. */
 @Test
 public void getContinueRoutine() {
   final FailureReport<String> failReport = new FailureReport<>();
   assertThat(failReport.getContinueRoutine(), is(this.continueFunction));
 }
Exemplo n.º 8
0
 /** Test method for {@link FailureReport#getFailureCause()}. */
 @Test
 public void getFailureCause() {
   final FailureReport<String> failReport = new FailureReport<>();
   assertThat(failReport.getFailureCause(), is(this.failureCause));
 }