Search in sources :

Example 31 with IsEqual

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

the class GetAllElementsIT method shouldGetAllTransformedFilteredElements.

@Test
@TraitRequirement({ StoreTrait.TRANSFORMATION, StoreTrait.PRE_AGGREGATION_FILTERING })
public void shouldGetAllTransformedFilteredElements() throws Exception {
    final GetAllElements op = new GetAllElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.VERTEX.name()).execute(new IsEqual("A1")).build()).transientProperty(TestPropertyNames.TRANSIENT_1, String.class).transformer(new ElementTransformer.Builder().select(IdentifierType.VERTEX.name(), TestPropertyNames.SET).execute(new Concat()).project(TestPropertyNames.TRANSIENT_1).build()).build()).build()).build();
    // When
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    // Then
    final List<Element> resultList = Lists.newArrayList(results);
    assertThat(resultList).hasSize(1);
    assertThat(resultList.get(0).getProperties()).containsEntry(TestPropertyNames.TRANSIENT_1, "A1,[3]");
}
Also used : Concat(uk.gov.gchq.koryphe.impl.function.Concat) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Element(uk.gov.gchq.gaffer.data.element.Element) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 32 with IsEqual

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

the class FederatedAddGraphWithHooksHandlerTest method shouldAddGraphWithCustomReadAccessPredicate.

@Test
public void shouldAddGraphWithCustomReadAccessPredicate() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    final Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    final AccessPredicate allowBlankUserAndTestUserReadAccess = new AccessPredicate(new AdaptedPredicate(new CallMethod("getUserId"), new Or<>(new IsEqual(testUser.getUserId()), new IsEqual(blankUser.getUserId()))));
    new FederatedAddGraphWithHooksHandler().doOperation(new AddGraphWithHooks.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).readAccessPredicate(allowBlankUserAndTestUserReadAccess).build(), new Context(testUser), store);
    assertEquals(1, store.getGraphs(blankUser, null, ignore).size());
    assertEquals(1, store.getGraphs(testUser, null, ignore).size());
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Or(uk.gov.gchq.koryphe.impl.predicate.Or) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AdaptedPredicate(uk.gov.gchq.koryphe.predicate.AdaptedPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) CallMethod(uk.gov.gchq.koryphe.impl.function.CallMethod) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Aggregations

IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)32 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)20 Test (org.junit.jupiter.api.Test)18 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)16 Element (uk.gov.gchq.gaffer.data.element.Element)12 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)10 Test (org.junit.Test)7 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)7 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)7 Entity (uk.gov.gchq.gaffer.data.element.Entity)6 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)6 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)6 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)6 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)6 IsLessThan (uk.gov.gchq.koryphe.impl.predicate.IsLessThan)6 Or (uk.gov.gchq.koryphe.impl.predicate.Or)6 Graph (uk.gov.gchq.gaffer.graph.Graph)5 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)4 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)4 User (uk.gov.gchq.gaffer.user.User)4