use of uk.gov.gchq.gaffer.operation.graph.GraphFilters in project Gaffer by gchq.
the class FilterToOperationConverterTest method testSpecifySource.
@Test
public void testSpecifySource() {
final Schema schema = getSchema();
final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
final Filter[] filters = new Filter[1];
filters[0] = new EqualTo(SchemaToStructTypeConverter.SRC_COL_NAME, "0");
FiltersToOperationConverter converter = new FiltersToOperationConverter(getViewFromSchema(schema), schema, filters);
Operation operation = converter.getOperation();
assertTrue(operation instanceof GetRDDOfElements);
assertEquals(0, ((GraphFilters) operation).getView().getEntityGroups().size());
assertEquals(EDGE_GROUPS, ((GraphFilters) operation).getView().getEdgeGroups());
final Set<EntityId> seeds = new HashSet<>();
for (final Object seed : ((GetRDDOfElements) operation).getInput()) {
seeds.add((EntitySeed) seed);
}
assertEquals(Collections.singleton(new EntitySeed("0")), seeds);
}
use of uk.gov.gchq.gaffer.operation.graph.GraphFilters in project Gaffer by gchq.
the class FilterToOperationConverterTest method testTwoGroups.
@Test
public void testTwoGroups() {
final Schema schema = getSchema();
final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
final Filter[] filters = new Filter[1];
final Filter left = new EqualTo(SchemaToStructTypeConverter.GROUP, ENTITY_GROUP);
final Filter right = new EqualTo(SchemaToStructTypeConverter.GROUP, EDGE_GROUP2);
filters[0] = new Or(left, right);
final FiltersToOperationConverter converter = new FiltersToOperationConverter(getViewFromSchema(schema), schema, filters);
final Operation operation = converter.getOperation();
assertTrue(operation instanceof GetRDDOfAllElements);
assertEquals(Collections.singleton(ENTITY_GROUP), ((GraphFilters) operation).getView().getEntityGroups());
assertEquals(Collections.singleton(EDGE_GROUP2), ((GraphFilters) operation).getView().getEdgeGroups());
}
use of uk.gov.gchq.gaffer.operation.graph.GraphFilters in project Gaffer by gchq.
the class FilterToOperationConverterTest method testSpecifyDestination.
@Test
public void testSpecifyDestination() {
final Schema schema = getSchema();
final SparkSession sparkSession = SparkSessionProvider.getSparkSession();
final Filter[] filters = new Filter[1];
filters[0] = new EqualTo(SchemaToStructTypeConverter.DST_COL_NAME, "0");
final FiltersToOperationConverter converter = new FiltersToOperationConverter(getViewFromSchema(schema), schema, filters);
final Operation operation = converter.getOperation();
assertTrue(operation instanceof GetRDDOfElements);
assertEquals(0, ((GraphFilters) operation).getView().getEntityGroups().size());
assertEquals(EDGE_GROUPS, ((GraphFilters) operation).getView().getEdgeGroups());
final Set<EntityId> seeds = new HashSet<>();
for (final Object seed : ((GetRDDOfElements) operation).getInput()) {
seeds.add((EntitySeed) seed);
}
assertEquals(Collections.singleton(new EntitySeed("0")), seeds);
}
Aggregations