Package org.hamcrest

Examples of org.hamcrest.StringDescription


    }

    @Test
    public void testDescription_AfterMatchWithWrongType() {
        testSubject.matches(new MyOtherEvent());
        StringDescription description = new StringDescription();
        testSubject.describeTo(description);
        assertEquals("org.axonframework.test.MyEvent", description.toString());
    }
View Full Code Here


    }

    @Test
    public void testDescription_AfterMatchWithWrongFieldValue() {
        testSubject.matches(new MyEvent(aggregateId, 2));
        StringDescription description = new StringDescription();
        testSubject.describeTo(description);
        assertEquals("org.axonframework.test.MyEvent (failed on field 'someValue')", description.toString());
    }
View Full Code Here

     * Assert that the condition is satisfied.
     * @throws AssertionError if the condition is not satisfied
     */
    public static void assertThat(Condition condition) {
        if(condition.isSatisfied()) return;
        Description description = new StringDescription();
        description.appendText("\nExpected: ")
                    .appendDescriptionOf(condition)
                    .appendText("\n     but: ");
        condition.describeDissatisfactionTo(description);
        throw new AssertionError(description.toString());
    }
View Full Code Here

  }

  @Override
  public boolean isSatisfied(Description mismatchDescription) {
    StringBuilder sb = new StringBuilder();
    StringDescription description = new StringDescription(sb);
    description.appendText(serverName + ":<" + getPort() + ">:\n");
   
    boolean allSatisfied = true;
   
    for (Expectation expectation : expectations) {
      allSatisfied &= isExpectationSatisfied(expectation, description);
View Full Code Here

   
    return allSatisfied;
  }
 
  private boolean isExpectationSatisfied(Expectation expectation, Description description) {
    Description subDescription = new StringDescription();
    boolean isSatisfied = expectation.isSatisfied(subDescription);
    if (!isSatisfied) {
      description.appendValue(subDescription).appendText("\n");
    }
    return isSatisfied;
View Full Code Here

  }

 
  private void assertServers(List<FakeServer> servers) {
    StringBuilder failMessage = new StringBuilder();
    Description mismatchDescription = new StringDescription(failMessage);
    boolean allSatisfied = true;
   
    for (FakeServer server : servers) {
      boolean isSatisfied = server.isSatisfied(mismatchDescription);
      allSatisfied &= isSatisfied;
View Full Code Here

 
  @Test
  public void isSatisfiedReturnsFalseWhenNotSatisfied() {
    expectation.setcardinality(oneOf());
   
    assertThat(expectation.isSatisfied(new StringDescription()), is(false));
  }
View Full Code Here

   
    allowingRequestMatcherReturns(true);

    expectation.handle(VALID_REQUEST, VALID_RESPONSE);

    assertThat(expectation.isSatisfied(new StringDescription()), is(true));
  }
View Full Code Here

 
  private Matcher<FakeServer> satisfied() {
    return new FeatureMatcher<FakeServer, Boolean>(Matchers.is(true), "satisfied", "satisfied") {
      @Override
      protected Boolean featureValueOf(FakeServer actual) {
        return actual.isSatisfied(new StringDescription());
      }
    };
  }
View Full Code Here

  private final String msg;

  @Override
  public void is(Matcher<? super T> matching) {
    Description message = new StringDescription();
    message.appendText("expecting ");
    matching.describeTo(message);
    message.appendText(" but ");
    T obj = provider.get();
    if (!matching.matches(obj)) {
      matching.describeMismatch(obj, message);
      if (assertion) {
        throw new AssertionError((msg == null ? "" : msg + "\n")
            + message.toString());
      } else {
        throw new AssumptionError((msg == null ? "" : msg + "\n")
            + message.toString());
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.hamcrest.StringDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.