Search in sources :

Example 1 with CollectionContains

use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project gaffer-doc by gchq.

the class CollectionContainsExample method collectionContains.

public void collectionContains() {
    // ---------------------------------------------------------
    final CollectionContains function = new CollectionContains(1);
    // ---------------------------------------------------------
    runExample(function, null, createSet(1, 2, 3), createSet(1), createSet(2), createSet());
}
Also used : CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains)

Example 2 with CollectionContains

use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.

the class NamedViewDetailTest method shouldTestAccessUsingCustomAccessPredicatesWhenConfigured.

@Test
public void shouldTestAccessUsingCustomAccessPredicatesWhenConfigured() {
    // Given
    final User testUser = new User.Builder().userId("testUserId").build();
    final User differentUser = new User.Builder().userId("differentUserId").opAuth("different").build();
    final String adminAuth = "adminAuth";
    final AccessPredicate readAccessPredicate = new AccessPredicate(new AdaptedPredicate(new CallMethod("getUserId"), new IsEqual("testUserId")));
    final AccessPredicate writeAccessPredicate = new AccessPredicate(new AdaptedPredicate(new CallMethod("getOpAuths"), new CollectionContains("different")));
    // When
    final NamedViewDetail namedViewDetail = createNamedViewDetailBuilder().readAccessPredicate(readAccessPredicate).writeAccessPredicate(writeAccessPredicate).build();
    // Then
    assertTrue(namedViewDetail.hasReadAccess(testUser, adminAuth));
    assertFalse(namedViewDetail.hasReadAccess(differentUser, adminAuth));
    assertFalse(namedViewDetail.hasWriteAccess(testUser, adminAuth));
    assertTrue(namedViewDetail.hasWriteAccess(differentUser, adminAuth));
}
Also used : CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) User(uk.gov.gchq.gaffer.user.User) AdaptedPredicate(uk.gov.gchq.koryphe.predicate.AdaptedPredicate) NamedViewWriteAccessPredicate(uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.NamedViewWriteAccessPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) UnrestrictedAccessPredicate(uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate) CallMethod(uk.gov.gchq.koryphe.impl.function.CallMethod) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Example 3 with CollectionContains

use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.

the class GetWalksIT method shouldFilterAllWalksWhenNoneContainProperty.

@Test
public void shouldFilterAllWalksWhenNoneContainProperty() throws Exception {
    final Iterable<Walk> walks = getWalksThatPassPredicateTest(new CollectionContains(6));
    assertThat(getPaths(walks)).isEmpty();
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) Test(org.junit.Test)

Example 4 with CollectionContains

use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.

the class GetWalksIT method shouldNotFilterAnyWalksWhenAllContainProperty.

@Test
public void shouldNotFilterAnyWalksWhenAllContainProperty() throws Exception {
    final Iterable<Walk> walks = getWalksThatPassPredicateTest(new CollectionContains(1));
    assertThat(getPaths(walks)).isEqualTo("AED,ABC");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) Test(org.junit.Test)

Example 5 with CollectionContains

use of uk.gov.gchq.koryphe.impl.predicate.CollectionContains in project Gaffer by gchq.

the class GetWalksIT method shouldFilterWalksThatDoNotContainProperty5.

@Test
public void shouldFilterWalksThatDoNotContainProperty5() throws Exception {
    final Iterable<Walk> walks = getWalksThatPassPredicateTest(new CollectionContains(5));
    assertThat(getPaths(walks)).isEqualTo("AED");
}
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