Search in sources :

Example 1 with EntityIdExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldGetSourceFromEdge.

@Test
public void shouldGetSourceFromEdge() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.SOURCE);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("1").dest("2").directed(false).build();
    // When
    final EntityId seed = extractor._apply(edge);
    // Then
    assertEquals("1", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 2 with EntityIdExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldGetIdentifierFromEntity.

@Test
public void shouldGetIdentifierFromEntity() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor();
    final Entity entity = new Entity.Builder().group(TestGroups.ENTITY).vertex("identifier").build();
    // When
    final EntityId seed = extractor._apply(entity);
    // Then
    assertSame("identifier", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Entity(uk.gov.gchq.gaffer.data.element.Entity) Test(org.junit.jupiter.api.Test)

Example 3 with EntityIdExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor in project Gaffer by gchq.

the class ExportIT method shouldExportResultsInSet.

@Test
public void shouldExportResultsInSet() throws OperationException {
    // Given
    final View edgesView = new View.Builder().edge(TestGroups.EDGE).build();
    final OperationChain<Iterable<?>> exportOpChain = new Builder().first(new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_0)).view(edgesView).build()).then(new ExportToSet<>()).then(new GenerateObjects.Builder<EntityId>().generator(new EntityIdExtractor()).build()).then(new GetElements.Builder().view(edgesView).build()).then(new ExportToSet<>()).then(new DiscardOutput()).then(new GetSetExport()).build();
    // When
    final Iterable<?> export = graph.execute(exportOpChain, getUser());
    // Then
    assertThat(Sets.newHashSet(export)).hasSize(2);
}
Also used : ExportToSet(uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetSetExport(uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) Test(org.junit.Test)

Example 4 with EntityIdExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor in project Gaffer by gchq.

the class ExportIT method shouldExportResultsToGafferCache.

@Test
public void shouldExportResultsToGafferCache() throws OperationException {
    assumeThat(graph.isSupported(ExportToGafferResultCache.class)).as("Gaffer result cache has not been enabled for this store.").isTrue();
    // Given
    final View edgesView = new View.Builder().edge(TestGroups.EDGE).build();
    final OperationChain<? extends Iterable<?>> exportOpChain = new Builder().first(new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_0)).view(edgesView).build()).then(new ExportToGafferResultCache<>()).then(new GenerateObjects.Builder<EntityId>().generator(new EntityIdExtractor()).build()).then(new GetElements.Builder().view(edgesView).build()).then(new ExportToGafferResultCache<>()).then(new DiscardOutput()).then(new GetGafferResultCacheExport()).build();
    // When
    final Iterable<?> export = graph.execute(exportOpChain, getUser());
    // Then
    assertThat(Sets.newHashSet(export)).hasSize(2);
}
Also used : EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) GetGafferResultCacheExport(uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ExportToGafferResultCache(uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 5 with EntityIdExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldThrowIllegalArgumentExceptionFromEdgeWhenIdTypeIsDirected.

@Test
public void shouldThrowIllegalArgumentExceptionFromEdgeWhenIdTypeIsDirected() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.DIRECTED);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("source").dest("destination").directed(false).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> extractor._apply(edge)).extracting("message").isNotNull();
}
Also used : EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Aggregations

EntityIdExtractor (uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor)8 Test (org.junit.jupiter.api.Test)6 Edge (uk.gov.gchq.gaffer.data.element.Edge)5 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)5 Test (org.junit.Test)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 DiscardOutput (uk.gov.gchq.gaffer.operation.impl.DiscardOutput)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 ExportToGafferResultCache (uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)1 GetGafferResultCacheExport (uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport)1 ExportToSet (uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet)1 GetSetExport (uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport)1