/** * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * <p/> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWith(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWithIgnoringCase("My"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static Matcher<String> startsWithIgnoringCase(String prefix) { return new StringStartsWith(true, prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix); }
/** * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * <p/> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWith(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static Matcher<String> startsWith(String prefix) { return new StringStartsWith(false, prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWithIgnoringCase("My"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix); }
/** * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * <p/> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWith(prefix); }
/** * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * <p/> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @Factory public static Matcher<String> startsWith(String prefix) { return new StringStartsWith(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static Matcher<java.lang.String> startsWith(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWith(prefix); }
/** * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * <p/> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ @Factory public static Matcher<String> startsWith(String prefix) { return new StringStartsWith(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}. * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWith(prefix); }
private static ResultMatcher invalidTokenHeader(String message) { return header().string(HttpHeaders.WWW_AUTHENTICATE, AllOf.allOf( new StringStartsWith("Bearer " + "error=\"invalid_token\", " + "error_description=\""), new StringContains(message), new StringEndsWith(", " + "error_uri=\"https://tools.ietf.org/html/rfc6750#section-3.1\"") ) ); }
public void testMatchesStringAtStartIgnoringCase() { final Matcher<String> ignoreCase = startsWithIgnoringCase("EXCerPT"); assertMatches(ignoreCase, "exCerPT" + "END"); assertDoesNotMatch(ignoreCase, "START" + "EXCerpt"); assertDoesNotMatch(ignoreCase, "START" + "EXcerpT" + "END"); assertMatches(ignoreCase, "excERPT"); assertMatches(ignoreCase, "ExcerPT" + "EXCerpt"); assertDoesNotMatch(ignoreCase, "ExcER"); assertDescription("a string starting with \"EXCerPT\" ignoring case", ignoreCase); assertMismatchDescription("was \"Something else\"", ignoreCase, "Something else"); }
private String getContent(MvcResult result) throws UnsupportedEncodingException { String content = result.getResponse().getContentAsString(); if (StringUtils.hasLength(this.prefix)) { try { String reason = String.format("Expected a JSON payload prefixed with \"%s\" but found: %s", this.prefix, StringUtils.quote(content.substring(0, this.prefix.length()))); MatcherAssert.assertThat(reason, content, StringStartsWith.startsWith(this.prefix)); return content.substring(this.prefix.length()); } catch (StringIndexOutOfBoundsException ex) { throw new AssertionError("JSON prefix \"" + this.prefix + "\" not found", ex); } } else { return content; } }
private static ResultMatcher invalidRequestHeader(String message) { return header().string(HttpHeaders.WWW_AUTHENTICATE, AllOf.allOf( new StringStartsWith("Bearer " + "error=\"invalid_request\", " + "error_description=\""), new StringContains(message), new StringEndsWith(", " + "error_uri=\"https://tools.ietf.org/html/rfc6750#section-3.1\"") ) ); }
/** * <p> * Creates a matcher that matches if the examined {@link String} starts with the specified * {@link String}, ignoring case * </p> * For example: * <pre>assertThat("myStringOfNote", startsWith("my"))</pre> * * @param prefix * the substring that the returned matcher will expect at the start of any examined string */ public static org.hamcrest.Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix) { return org.hamcrest.core.StringStartsWith.startsWithIgnoringCase(prefix); }