Package org.hamcrest

Examples of org.hamcrest.Description$NullDescription


    public ExpectedException thrown = ExpectedException.none();
   
    @Test
    public void matcherShouldDescribeItselfCorrectly() {
        HasJsonWhich matcher = new HasJsonWhich(new HasJsonValue("number", new IsEqual<Integer>(1)));
        Description description = new StringDescription();
        matcher.describeTo(description);
        assertThat(description.toString(), is("JsonNode with 'number' matching: <1>"));
    }
View Full Code Here


    }
   
    @Test
    public void matcherShouldDescribeMismatchCorrectly() {
        HasJsonWhich matcher = new HasJsonWhich(new HasJsonValue("number", new IsEqual<Integer>(1)));
        Description description = new StringDescription();
        matcher.describeMismatchSafely("{\"number\":10}", description);
        assertThat(description.toString(), is("was <{\"number\":10}>"));
    }
View Full Code Here

        matcher = new HasResponseBody(containsString("something"));
    }
   
    @Test
    public void matcherDescribesItselfCorrectly() {
        Description description = new StringDescription();
        matcher.describeTo(description);
       
        assertThat(description.toString(), is("Response with body matching: a string containing \"something\""));
    }
View Full Code Here

        assertThat(new Rfc1123DateMatcher().matches(unCompliantDate), is(false));
    }
   
    @Test
    public void testDescription() {
        Description description = new StringDescription();
        new Rfc1123DateMatcher().describeTo(description);
       
        assertThat(description.toString(), is("Rfc1123-compliant date in header, like 'Mon, 09 May 2011 18:49:18 GMT'"));
    }
View Full Code Here

        matcher = new HasHeader("Header");
    }
   
    @Test
    public void matcherShouldDescribeItselfCorrectly() {
        Description description = new StringDescription();
        matcher.describeTo(description);
       
        assertThat(description.toString(), is("Response with header named 'Header'"));
    }
View Full Code Here

        assertThat(matcher.matches(mockResponse), is(true));
    }
   
    @Test
    public void matcherShouldDescribeMismatchCorrectlyWithNoHeaders() {
        Description description = new StringDescription();
        Response mockResponse = mock(Response.class);
        matcher.describeMismatchSafely(mockResponse, description);
       
        assertThat(description.toString(), is("Response has no headers"));
    }
View Full Code Here

    }
   
    @Test
    public void matcherShouldDescribeMismatchCorrectlyWithHeaders() {
        List<Header> headers = Arrays.asList(new Header("This: that"), new Header("The: other"));
        Description description = new StringDescription();
        Response mockResponse = mock(Response.class);
        when(mockResponse.getHeaders()).thenReturn(headers);
        matcher.describeMismatchSafely(mockResponse, description);
       
        assertThat(description.toString(), is("Response has headers [This: that, The: other]"));
    }
View Full Code Here

    }
   
    @Test
    public void descriptionIsSufficient() {
       
        Description description = new StringDescription();
       
        matcher.describeTo(description);
       
        assertThat(description.toString(), is("Response with status code matching: <200>"));
       
    }
View Full Code Here

    public void mismatchResponseDescribesCorrectly() {
       
        when(response.getStatusCode()).thenReturn(200);
        when(response.getContent()).thenReturn(null);
       
        Description description = new StringDescription();
       
        matcher.describeMismatchSafely(response, description);
       
        assertThat(description.toString(), is("Response has status code: 200"));
       
    }
View Full Code Here

        matcher = new HasHeaderWithValue("Content-Type", containsString("application/json"));
    }
   
    @Test
    public void matcherShouldDescribeItselfCorrectly() {
        Description description = new StringDescription();
        matcher.describeTo(description);
       
        assertThat(description.toString(), is("Response with header named 'Content-Type' and value matching: a string containing \"application/json\""));
    }
View Full Code Here

TOP

Related Classes of org.hamcrest.Description$NullDescription

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.