/** * Creates a matcher of {@link Comparable} object that matches when the examined object is * greater than the specified value, as reported by the <code>compareTo</code> method of the * <b>examined</b> object. * <p/> * For example: * <pre>assertThat(2, greaterThan(1))</pre> * * @param value * the value which, when passed to the compareTo method of the examined object, should return greater * than zero */ public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThan(T value) { return org.hamcrest.number.OrderingComparison.<T>greaterThan(value); }
public void testDescription() { assertDescription("a value greater than <1>", greaterThan(1)); assertDescription("a value equal to or greater than <1>", greaterThanOrEqualTo(1)); assertDescription("a value equal to <1>", comparesEqualTo(1)); assertDescription("a value less than or equal to <1>", lessThanOrEqualTo(1)); assertDescription("a value less than <1>", lessThan(1)); }
/** * Creates a matcher of {@link Comparable} object that matches when the examined object is * greater than the specified value, as reported by the <code>compareTo</code> method of the * <b>examined</b> object. * For example: * <pre>assertThat(2, greaterThan(1))</pre> * * @param value the value which, when passed to the compareTo method of the examined object, should return greater * than zero */ public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThan(T value) { return org.hamcrest.number.OrderingComparison.greaterThan(value); }
public void testDescription() { assertDescription("a value greater than <1>", greaterThan(1)); assertDescription("a value equal to or greater than <1>", greaterThanOrEqualTo(1)); assertDescription("a value equal to <1>", comparesEqualTo(1)); assertDescription("a value less than or equal to <1>", lessThanOrEqualTo(1)); assertDescription("a value less than <1>", lessThan(1)); }
@Override protected Matcher<Integer> createMatcher() { return greaterThan(1); }
public void testSupportsDifferentTypesOfComparableObjects() { assertThat(1.1, greaterThan(1.0)); assertThat("cc", greaterThan("bb")); }
public void testSupportsDifferentTypesOfComparableObjects() { assertThat(1.1, greaterThan(1.0)); assertThat("cc", greaterThan("bb")); }
public void testComparesObjectsForGreaterThan() { assertThat(2, greaterThan(1)); assertThat(0, not(greaterThan(1))); }
/** * Matches a directory with at least one file. * * @return the Matcher. */ public static Matcher<File> hasFiles() { return hasNumberOfFiles(greaterThan(0)); }
public void testComparesObjectsForGreaterThan() { assertThat(2, greaterThan(1)); assertThat(0, not(greaterThan(1))); }
Long fastRequestElapsedMillis = fastFuture.get(); assertThat("Slow request takes less than expected", slowRequestElapsedMillis, is(greaterThan(5 * 1000L))); assertThat("Fast request takes longer than expected", fastRequestElapsedMillis, is(lessThan(5 * 1000L)));
@SuppressWarnings("unchecked") private void assertCommonClientAccessTokenProperties(OAuth2AccessToken accessToken) { assertThat(accessToken, allOf(clientId(is(CLIENT_ID)), userId(is(nullValue())), subject(is(CLIENT_ID)), username(is(nullValue())), cid(is(CLIENT_ID)), scope(is(tokenSupport.clientScopes)), audience(is(tokenSupport.resourceIds)), jwtId(not(isEmptyString())), issuedAt(is(greaterThan(0))), expiry(is(greaterThan(0))))); }
@SuppressWarnings("unchecked") private void assertCommonUserRefreshTokenProperties(OAuth2RefreshToken refreshToken) { assertThat(refreshToken, allOf(/*issuer(is(issuerUri)),*/ OAuth2RefreshTokenMatchers.username(is(tokenSupport.username)), OAuth2RefreshTokenMatchers.clientId(is(CLIENT_ID)), OAuth2RefreshTokenMatchers.subject(is(not(nullValue()))), OAuth2RefreshTokenMatchers.audience(is(tokenSupport.resourceIds)), OAuth2RefreshTokenMatchers.origin(is(OriginKeys.UAA)), OAuth2RefreshTokenMatchers.revocationSignature(is(not(nullValue()))), OAuth2RefreshTokenMatchers.jwtId(not(isEmptyString())), OAuth2RefreshTokenMatchers.issuedAt(is(greaterThan(0))), OAuth2RefreshTokenMatchers.expiry(is(greaterThan(0))) ) ); }
public void testMismatchDescriptions() { assertMismatchDescription("<0> was less than <1>", greaterThan(1), 0); assertMismatchDescription("<1> was equal to <1>", greaterThan(1), 1); assertMismatchDescription("<1> was greater than <0>", lessThan(0), 1); assertMismatchDescription("<2> was equal to <2>", lessThan(2), 2); }
@SuppressWarnings({"unused", "unchecked"}) private void assertCommonUserAccessTokenProperties(OAuth2AccessToken accessToken, String clientId) { assertThat(accessToken, allOf(username(is(tokenSupport.username)), clientId(is(clientId)), subject(is(tokenSupport.userId)), audience(is(tokenSupport.resourceIds)), origin(is(OriginKeys.UAA)), revocationSignature(is(not(nullValue()))), cid(is(clientId)), userId(is(tokenSupport.userId)), email(is(tokenSupport.email)), jwtId(not(isEmptyString())), issuedAt(is(greaterThan(0))), expiry(is(greaterThan(0))) )); }
public void testMismatchDescriptions() { assertMismatchDescription("<0> was less than <1>", greaterThan(1), 0); assertMismatchDescription("<1> was equal to <1>", greaterThan(1), 1); assertMismatchDescription("<1> was greater than <0>", lessThan(0), 1); assertMismatchDescription("<2> was equal to <2>", lessThan(2), 2); }
@Test public void testRemoveAllWithHash() throws Exception { final int totalCount = 10037; ConcurrentHashMap<Comparable<?>, String> map = new ConcurrentHashMap<>(); int lastHash = 0; for(int i = 0; i < totalCount; i++) { String o = Integer.toString(i); lastHash = o.hashCode(); map.put(o, "val#" + i); } Collection<Entry<Comparable<?>, String>> removed = map.removeAllWithHash(lastHash); assertThat(removed.size(), greaterThan(0)); assertThat(map.size() + removed.size(), is(totalCount)); assertRemovedEntriesAreRemoved(map, removed); }
Thread.sleep(50); assertThat(RestartReporter.numRestarts.getValue(), is(greaterThan(4L)));
assertTrue("Token should be composite token", accessToken instanceof CompositeToken); CompositeToken composite = (CompositeToken) accessToken; assertThat("id_token should be JWT, thus longer than 36 characters", composite.getIdTokenValue().length(), greaterThan(36)); assertThat("Opaque access token must be shorter than 37 characters", accessToken.getValue().length(), lessThanOrEqualTo(36)); assertThat("Opaque refresh token must be shorter than 37 characters", accessToken.getRefreshToken().getValue().length(), lessThanOrEqualTo(36));
@Test public void tableTypeCompare2() throws Exception { final TableType tableType1 = new TableType("table"); final TableType tableType2 = new TableType("materialized view"); assertThat(tableType1, lessThan(tableType2)); assertThat(tableType2, greaterThan(tableType1)); }