Search in sources :

Example 61 with EntityId

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

the class EntitySeedTest method shouldBeRelatedToEdgeIdWhenDestinationAndVertexAreNull.

@Test
public void shouldBeRelatedToEdgeIdWhenDestinationAndVertexAreNull() {
    // Given
    final String source = "source";
    final String destination = null;
    final EntityId seed = new EntitySeed(destination);
    final EdgeId relatedSeed = mock(EdgeId.class);
    given(relatedSeed.getSource()).willReturn(source);
    given(relatedSeed.getDestination()).willReturn(destination);
    // Then
    assertTrue(seed.isRelated((ElementId) relatedSeed).isMatch());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 62 with EntityId

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

the class EntitySeedTest method shouldNotBeEqualWhenVerticesEqual.

@Test
public void shouldNotBeEqualWhenVerticesEqual() {
    // Given
    final EntityId seed1 = new EntitySeed("vertex");
    final EntityId seed2 = new EntitySeed("other vertex");
    // Then
    assertNotEquals(seed1, seed2);
    assertNotEquals(seed1.hashCode(), seed2.hashCode());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 63 with EntityId

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

the class AbstractStoreIT method createDefaultEntities.

public static Map<EntityId, Entity> createDefaultEntities() {
    final Map<EntityId, Entity> entities = new HashMap<>();
    for (int i = 0; i <= 10; i++) {
        for (int j = 0; j < VERTEX_PREFIXES.length; j++) {
            final Entity entity = new Entity(TestGroups.ENTITY, VERTEX_PREFIXES[j] + i);
            entity.putProperty(TestPropertyNames.COUNT, 1L);
            entity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
            addToMap(entity, entities);
        }
        final Entity secondEntity = new Entity(TestGroups.ENTITY, SOURCE + i);
        secondEntity.putProperty(TestPropertyNames.COUNT, 1L);
        secondEntity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
        addToMap(secondEntity, entities);
        final Entity thirdEntity = new Entity(TestGroups.ENTITY, DEST + i);
        thirdEntity.putProperty(TestPropertyNames.COUNT, 1L);
        thirdEntity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
        addToMap(thirdEntity, entities);
        final Entity fourthEntity = new Entity(TestGroups.ENTITY, SOURCE_DIR + i);
        fourthEntity.putProperty(TestPropertyNames.COUNT, 1L);
        fourthEntity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
        addToMap(fourthEntity, entities);
        final Entity fifthEntity = new Entity(TestGroups.ENTITY, DEST_DIR + i);
        fifthEntity.putProperty(TestPropertyNames.COUNT, 1L);
        fifthEntity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
        addToMap(fifthEntity, entities);
    }
    return entities;
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Entity(uk.gov.gchq.gaffer.data.element.Entity) HashMap(java.util.HashMap)

Example 64 with EntityId

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

the class OperationChainTest method shouldBuildOperationChainWithTypeUnsafe.

@Test
public void shouldBuildOperationChainWithTypeUnsafe() {
    // When
    final GetAdjacentIds getAdjIds1 = new GetAdjacentIds();
    final ExportToSet<CloseableIterable<? extends EntityId>> exportToSet1 = new ExportToSet<>();
    final DiscardOutput discardOutput1 = new DiscardOutput();
    final GetSetExport getSetExport1 = new GetSetExport();
    final GetAdjacentIds getAdjIds2 = new GetAdjacentIds();
    final ExportToSet<CloseableIterable<? extends EntityId>> exportToSet2 = new ExportToSet<>();
    final DiscardOutput discardOutput2 = new DiscardOutput();
    final GetSetExport getSetExport2 = new GetSetExport();
    final OperationChain<CloseableIterable<? extends EntityId>> opChain = new Builder().first(getAdjIds1).then(exportToSet1).then(discardOutput1).then(getSetExport1).thenTypeUnsafe(// we can use the type unsafe here as we know the output from the set export will be an Iterable of EntityIds
    getAdjIds2).then(exportToSet2).then(discardOutput2).then(getSetExport2).buildTypeUnsafe();
    // Then
    final Operation[] expecteds = { getAdjIds1, exportToSet1, discardOutput1, getSetExport1, getAdjIds2, exportToSet2, discardOutput2, getSetExport2 };
    assertArrayEquals(expecteds, opChain.getOperationArray());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) ExportToSet(uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) GetSetExport(uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport) Test(org.junit.jupiter.api.Test)

Example 65 with EntityId

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

the class OperationChainTest method shouldBuildOperationChain.

@Test
public void shouldBuildOperationChain() {
    // Given
    final AddElements addElements1 = mock(AddElements.class);
    final AddElements addElements2 = mock(AddElements.class);
    final GetAdjacentIds getAdj1 = mock(GetAdjacentIds.class);
    final GetAdjacentIds getAdj2 = mock(GetAdjacentIds.class);
    final GetAdjacentIds getAdj3 = mock(GetAdjacentIds.class);
    final GetElements getElements1 = mock(GetElements.class);
    final GetElements getElements2 = mock(GetElements.class);
    final GetAllElements getAllElements = mock(GetAllElements.class);
    final DiscardOutput discardOutput = mock(DiscardOutput.class);
    final GetJobDetails getJobDetails = mock(GetJobDetails.class);
    final GenerateObjects<EntityId> generateEntitySeeds = mock(GenerateObjects.class);
    final Limit<Element> limit = mock(Limit.class);
    final ToSet<Element> deduplicate = mock(ToSet.class);
    final CountGroups countGroups = mock(CountGroups.class);
    final ExportToSet<GroupCounts> exportToSet = mock(ExportToSet.class);
    final ExportToGafferResultCache<CloseableIterable<? extends Element>> exportToGafferCache = mock(ExportToGafferResultCache.class);
    final If<Iterable<? extends EntityId>, Iterable<? extends EntityId>> ifOp = mock(If.class);
    // When
    final OperationChain<JobDetail> opChain = new Builder().first(addElements1).then(getAdj1).then(getAdj2).then(getElements1).then(generateEntitySeeds).then(getAdj3).then(ifOp).then(getElements2).then(deduplicate).then(limit).then(countGroups).then(exportToSet).then(discardOutput).then(getAllElements).then(exportToGafferCache).then(addElements2).then(getJobDetails).build();
    // Then
    final Operation[] expecteds = { addElements1, getAdj1, getAdj2, getElements1, generateEntitySeeds, getAdj3, ifOp, getElements2, deduplicate, limit, countGroups, exportToSet, discardOutput, getAllElements, exportToGafferCache, addElements2, getJobDetails };
    assertArrayEquals(expecteds, opChain.getOperationArray());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) GroupCounts(uk.gov.gchq.gaffer.data.GroupCounts) Test(org.junit.jupiter.api.Test)

Aggregations

EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)93 Test (org.junit.jupiter.api.Test)60 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)41 HashSet (java.util.HashSet)22 User (uk.gov.gchq.gaffer.user.User)21 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)15 Entity (uk.gov.gchq.gaffer.data.element.Entity)15 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)15 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)15 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 Element (uk.gov.gchq.gaffer.data.element.Element)14 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)14 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)13 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)13 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)12 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)10 ArrayList (java.util.ArrayList)8 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)7 Graph (uk.gov.gchq.gaffer.graph.Graph)7 Context (uk.gov.gchq.gaffer.store.Context)7