Package org.hamcrest

Examples of org.hamcrest.StringDescription


        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


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

   
    @Test
    public void matcherShouldDescribeMismatchCorrectlyIfResponseHasHeaders() {
        Response mockResponse = mock(Response.class);
        when(mockResponse.getHeaders()).thenReturn(Arrays.asList(new Header("Header1: value"), new Header("Header2: value")));
        Description description = new StringDescription();
        matcher.describeMismatchSafely(mockResponse, description);
       
        assertThat(description.toString(), is("Response has headers [Header1: value, Header2: value]"));
    }
View Full Code Here

        for (Object analysedObject : deque) {
            if (matcher.matches(analysedObject)) {
                return;
            }
        }
        StringDescription description = new StringDescription();
        matcher.describeTo(description);
        Assert.fail(eventDescription + ": " + description.toString());
    }
View Full Code Here

            }

            @Override
            public String toString() {
                Description description = new StringDescription();
                description.appendText("HasDeclaredAnnotation(").appendText(annotationName);
                defaultValueMatcher.describeTo(description);
                description.appendText(")");
                return description.toString();
            }

            @Override
            public void describeTo(Description description) {
                description.appendText(toString());
            }
        };
    }
View Full Code Here

            }

            @Override
            public String toString() {
                Description description = new StringDescription();
                description.appendText("HasDeclaredAnnotation(").appendText(annotationName);
                description.appendText(")");
                return description.toString();
            }

            @Override
            public void describeTo(Description description) {
                description.appendText(toString());
            }
        };
    }
View Full Code Here

        this.condition = condition;
    }

    @Override
    public Void call() throws RuntimeException {
        Description description = new StringDescription();
        condition.describeTo(description);
        throw new AssertionError(description.toString());
    }
View Full Code Here

    @Override
    public boolean isSatisfied() {
        T value = actual.call();
        boolean matches = matcher.matches(value);
        if (!matches) {
            StringDescription failure = new StringDescription();
            matcher.describeMismatch(value, failure);
            description.add(failure);
        }
        return matches;
    }
View Full Code Here

        ;
    }

    private String getDescriptionOf(Callable<T, RuntimeException> actual) {
        if (actual instanceof SelfDescribing) {
            StringDescription description = new StringDescription();
            ((SelfDescribing) actual).describeTo(description);
            return description.toString();
        }
        return actual.getClass().getSimpleName();
    }
View Full Code Here

        }
        return contextProperty;
    }

    private static <T> String descriptionOf(final Matcher<T> matcher) {
        final StringDescription stringDescription = new StringDescription();
        matcher.describeTo(stringDescription);
        final String description = stringDescription.toString();
        return description;
    }
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.