use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.
the class FederatedAccessAuthTest method shouldSerialiseAndDeserialiseAccessPredicatesToJson.
@Test
public void shouldSerialiseAndDeserialiseAccessPredicatesToJson() throws SerialisationException {
// Given
final FederatedAccess federatedAccess = new FederatedAccess.Builder().addingUserId(AUTH_USER_ID).isPublic(false).readAccessPredicate(new AccessPredicate(new AdaptedPredicate(new CallMethod("getDataAuths"), new CollectionContains(ALL_USERS)))).writeAccessPredicate(new AccessPredicate(new AdaptedPredicate(new CallMethod("getDataAuths"), new CollectionContains(AUTH_1)))).build();
// When
final String serialised = new String(JSONSerialiser.serialise(federatedAccess));
// Then
final String expected = "{" + " \"addingUserId\": \"authUser\"," + " \"disabledByDefault\": false," + " \"public\": false," + " \"readAccessPredicate\": {" + " \"class\": \"uk.gov.gchq.gaffer.access.predicate.AccessPredicate\"," + " \"userPredicate\": {" + " \"class\": \"uk.gov.gchq.koryphe.predicate.AdaptedPredicate\"," + " \"inputAdapter\": {" + " \"class\": \"uk.gov.gchq.koryphe.impl.function.CallMethod\"," + " \"method\": \"getDataAuths\"" + " }," + " \"predicate\": {" + " \"class\": \"uk.gov.gchq.koryphe.impl.predicate.CollectionContains\"," + " \"value\": \"allUsers\"" + " }" + " }" + " }," + " \"writeAccessPredicate\": {" + " \"class\": \"uk.gov.gchq.gaffer.access.predicate.AccessPredicate\"," + " \"userPredicate\": {" + " \"class\": \"uk.gov.gchq.koryphe.predicate.AdaptedPredicate\"," + " \"inputAdapter\": {" + " \"class\": \"uk.gov.gchq.koryphe.impl.function.CallMethod\"," + " \"method\": \"getDataAuths\"" + " }," + " \"predicate\": {" + " \"class\": \"uk.gov.gchq.koryphe.impl.predicate.CollectionContains\"," + " \"value\": \"auth1\"" + " }" + " }" + " }" + "}";
JsonAssert.assertEquals(expected, serialised);
final FederatedAccess deserialised = JSONSerialiser.deserialise(serialised, FederatedAccess.class);
assertEquals(federatedAccess, deserialised);
}
use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.
the class GetWalksIT method shouldFilterWalksThatDoNotContainProperty2.
@Test
public void shouldFilterWalksThatDoNotContainProperty2() throws Exception {
final Iterable<Walk> walks = getWalksThatPassPredicateTest(new CollectionContains(2));
assertThat(getPaths(walks)).isEqualTo("ABC");
}
Aggregations