use of org.hamcrest.BaseMatcher in project indy by Commonjava.
the class GroupDataManagerTCK method createAndRetrieveEmptyGroup.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void createAndRetrieveEmptyGroup() throws Exception {
final Group grp = new Group("test");
store(grp);
final Group result = manager.query().packageType(MAVEN_PKG_KEY).storeType(Group.class).getByName(grp.getName());
assertThat(result, notNullValue());
assertThat(result.getName(), equalTo(grp.getName()));
assertThat(result.getConstituents(), anyOf(nullValue(), new BaseMatcher<List>() {
@Override
public boolean matches(final Object item) {
return (item instanceof List) && ((List) item).isEmpty();
}
@Override
public void describeTo(final Description description) {
description.appendText("empty list");
}
}));
}
use of org.hamcrest.BaseMatcher in project android_frameworks_base by DirtyUnicorns.
the class MockUtils method checkUserRestrictions.
public static Bundle checkUserRestrictions(String... keys) {
final Bundle expected = DpmTestUtils.newRestrictions(Preconditions.checkNotNull(keys));
final Matcher<Bundle> m = new BaseMatcher<Bundle>() {
@Override
public boolean matches(Object item) {
if (item == null)
return false;
return UserRestrictionsUtils.areEqual((Bundle) item, expected);
}
@Override
public void describeTo(Description description) {
description.appendText("User restrictions=" + getRestrictionsAsString(expected));
}
};
return Mockito.argThat(m);
}
use of org.hamcrest.BaseMatcher in project android_frameworks_base by ResurrectionRemix.
the class MockUtils method checkUserRestrictions.
public static Bundle checkUserRestrictions(String... keys) {
final Bundle expected = DpmTestUtils.newRestrictions(Preconditions.checkNotNull(keys));
final Matcher<Bundle> m = new BaseMatcher<Bundle>() {
@Override
public boolean matches(Object item) {
if (item == null)
return false;
return UserRestrictionsUtils.areEqual((Bundle) item, expected);
}
@Override
public void describeTo(Description description) {
description.appendText("User restrictions=" + getRestrictionsAsString(expected));
}
};
return Mockito.argThat(m);
}
use of org.hamcrest.BaseMatcher in project calcite-avatica by apache.
the class AbstractAvaticaHandlerTest method disallowUnauthenticatedUsers.
@Test
public void disallowUnauthenticatedUsers() throws Exception {
ServletOutputStream os = mock(ServletOutputStream.class);
when(config.getAuthenticationType()).thenReturn(AuthenticationType.SPNEGO);
when(request.getRemoteUser()).thenReturn(null);
when(response.getOutputStream()).thenReturn(os);
assertFalse(handler.isUserPermitted(config, request, response));
verify(response).setStatus(HttpURLConnection.HTTP_UNAUTHORIZED);
// Make sure that the serialized ErrorMessage looks reasonable
verify(os).write(argThat(new BaseMatcher<byte[]>() {
@Override
public void describeTo(Description description) {
String desc = "A serialized ErrorMessage which contains 'User is not authenticated'";
description.appendText(desc);
}
@Override
public boolean matches(Object item) {
String msg = new String((byte[]) item, StandardCharsets.UTF_8);
return msg.contains("User is not authenticated");
}
@Override
public void describeMismatch(Object item, Description mismatchDescription) {
mismatchDescription.appendText("The message should contain 'User is not authenticated'");
}
}));
}
use of org.hamcrest.BaseMatcher in project android_frameworks_base by crdroidandroid.
the class MockUtils method checkUserRestrictions.
public static Bundle checkUserRestrictions(String... keys) {
final Bundle expected = DpmTestUtils.newRestrictions(Preconditions.checkNotNull(keys));
final Matcher<Bundle> m = new BaseMatcher<Bundle>() {
@Override
public boolean matches(Object item) {
if (item == null)
return false;
return UserRestrictionsUtils.areEqual((Bundle) item, expected);
}
@Override
public void describeTo(Description description) {
description.appendText("User restrictions=" + getRestrictionsAsString(expected));
}
};
return Mockito.argThat(m);
}
Aggregations