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());
}
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());
}
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);
}
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);
}
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();
}
Aggregations