Search in sources :

Example 6 with CollectionContains

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);
}
Also used : CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) AdaptedPredicate(uk.gov.gchq.koryphe.predicate.AdaptedPredicate) FederatedGraphWriteAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) FederatedGraphReadAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate) CallMethod(uk.gov.gchq.koryphe.impl.function.CallMethod) Test(org.junit.jupiter.api.Test)

Example 7 with CollectionContains

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");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) Test(org.junit.Test)

Aggregations

CollectionContains (uk.gov.gchq.koryphe.impl.predicate.CollectionContains)7 Test (org.junit.Test)4 Walk (uk.gov.gchq.gaffer.data.graph.Walk)4 Test (org.junit.jupiter.api.Test)2 AccessPredicate (uk.gov.gchq.gaffer.access.predicate.AccessPredicate)2 CallMethod (uk.gov.gchq.koryphe.impl.function.CallMethod)2 AdaptedPredicate (uk.gov.gchq.koryphe.predicate.AdaptedPredicate)2 UnrestrictedAccessPredicate (uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate)1 NamedViewWriteAccessPredicate (uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.NamedViewWriteAccessPredicate)1 FederatedGraphReadAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate)1 FederatedGraphWriteAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate)1 User (uk.gov.gchq.gaffer.user.User)1 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)1