Search in sources :

Example 21 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class IsEdgeValidatorTest method shouldValidateWhenEdge.

@Test
public void shouldValidateWhenEdge() {
    // Given
    final Element element = new Edge(TestGroups.EDGE);
    // When
    final boolean valid = new IsEdgeValidator().validate(element);
    // Then
    assertTrue(valid);
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 22 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class IsEntityValidatorTest method shouldValidateWhenEntity.

@Test
public void shouldValidateWhenEntity() {
    // Given
    final Element element = new Entity(TestGroups.ENTITY);
    // When
    final boolean valid = new IsEntityValidator().validate(element);
    // Then
    assertTrue(valid);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) Test(org.junit.Test)

Example 23 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class MapGeneratorTest method shouldGenerateAnEmptyMap.

@Test
public void shouldGenerateAnEmptyMap() {
    // Given
    final Object vertex = "source vertex";
    final String prop1 = "property 1";
    final int count = 10;
    final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
    final MapGenerator generator = new MapGenerator();
    // When
    final Map<String, Object> map = generator.getObject(element);
    // Then
    final Map<String, Object> expectedMap = new LinkedHashMap<>();
    assertEquals(expectedMap, map);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) MapGenerator(uk.gov.gchq.gaffer.data.generator.MapGenerator) Element(uk.gov.gchq.gaffer.data.element.Element) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 24 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class AccumuloIDWithinSetRetrieverTest method returnElementsFromOperation.

private Set<Element> returnElementsFromOperation(final AccumuloStore store, final GetElements operation, final User user, final boolean loadIntoMemory) throws StoreException {
    final AccumuloRetriever<?> retriever = new AccumuloIDWithinSetRetriever(store, operation, user, loadIntoMemory);
    final Set<Element> results = new HashSet<>();
    for (final Element elm : retriever) {
        results.add(elm);
    }
    retriever.close();
    return results;
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) HashSet(java.util.HashSet)

Example 25 with Element

use of uk.gov.gchq.gaffer.data.element.Element in project Gaffer by gchq.

the class AccumuloIDWithinSetRetrieverTest method shouldStillApplyOtherFilter.

private void shouldStillApplyOtherFilter(final boolean loadIntoMemory, final AccumuloStore store) throws StoreException {
    // Query for all edges in set {A0, A23}
    final Set<EntitySeed> seeds = new HashSet<>();
    seeds.add(AccumuloTestData.SEED_A0);
    seeds.add(AccumuloTestData.SEED_A23);
    final GetElements<EntitySeed, ?> op = new GetElements<>(defaultView, seeds);
    // Set graph to give us edges only
    op.setIncludeEntities(false);
    final Set<Element> results = returnElementsFromOperation(store, op, new User(), loadIntoMemory);
    assertThat(results, IsCollectionContaining.hasItem(AccumuloTestData.EDGE_A0_A23));
    // Set graph to return entities only
    final GetElements<EntitySeed, ?> entitiesOnlyOp = new GetElements<>(defaultView, seeds);
    entitiesOnlyOp.setIncludeEntities(true);
    entitiesOnlyOp.setIncludeEdges(IncludeEdgeType.NONE);
    // Query for all edges in set {A0, A23}
    final Set<Element> entitiesOnlyResults = returnElementsFromOperation(store, entitiesOnlyOp, new User(), loadIntoMemory);
    assertThat(entitiesOnlyResults, IsCollectionContaining.hasItems(AccumuloTestData.A0_ENTITY, AccumuloTestData.A23_ENTITY));
    // Set graph to return both entities and edges again, and to only return summary type "X" (which will result
    // in no data)
    final View view = new View.Builder().edge("X").build();
    final GetElements<EntitySeed, ?> entitiesAndEdgesOp = new GetElements<>(view, seeds);
    entitiesAndEdgesOp.setIncludeEdges(IncludeEdgeType.ALL);
    entitiesAndEdgesOp.setIncludeEntities(true);
    final Set<Element> entitiesAndEdgesResults = returnElementsFromOperation(store, entitiesAndEdgesOp, new User(), loadIntoMemory);
    assertEquals(0, entitiesAndEdgesResults.size());
}
Also used : User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) HashSet(java.util.HashSet)

Aggregations

Element (uk.gov.gchq.gaffer.data.element.Element)182 Test (org.junit.Test)102 Edge (uk.gov.gchq.gaffer.data.element.Edge)72 User (uk.gov.gchq.gaffer.user.User)53 Entity (uk.gov.gchq.gaffer.data.element.Entity)52 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)50 HashSet (java.util.HashSet)47 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)42 ArrayList (java.util.ArrayList)33 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)32 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)26 Key (org.apache.accumulo.core.data.Key)23 Value (org.apache.accumulo.core.data.Value)23 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)17 Graph (uk.gov.gchq.gaffer.graph.Graph)16 HashMap (java.util.HashMap)14 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)14 Configuration (org.apache.hadoop.conf.Configuration)12 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)12