use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseWhenMissingTraits.
@Test
public void shouldValidateAndReturnFalseWhenMissingTraits() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).aggregator(new ElementAggregator.Builder().select(TestPropertyNames.PROP_1).execute(new StringConcat()).build()).postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_2).execute(new Exists()).build()).transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new ExampleTransformFunction()).project(TestPropertyNames.PROP_3).build()).postTransformFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_3).execute(new Exists()).build()).build()).build();
final Schema schema = new Schema.Builder().type("obj", String.class).type("string", String.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").property(TestPropertyNames.PROP_2, "string").build()).build();
// When
final ValidationResult result = validator.validate(view, schema, NO_STORE_TRAITS);
// Then
final String errPrefix = "This store does not currently support ";
assertFalse(result.isValid());
assertEquals(Sets.newHashSet(errPrefix + StoreTrait.PRE_AGGREGATION_FILTERING.name(), errPrefix + StoreTrait.QUERY_AGGREGATION.name(), errPrefix + StoreTrait.POST_AGGREGATION_FILTERING.name(), errPrefix + StoreTrait.TRANSFORMATION.name(), errPrefix + StoreTrait.POST_TRANSFORMATION_FILTERING.name()), result.getErrors());
}
use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.
the class GetSchemaHandlerTest method setup.
@BeforeEach
public void setup() {
handler = new GetSchemaHandler();
store = mock(Store.class);
context = mock(Context.class);
user = mock(User.class);
properties = new StoreProperties();
schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("string").description("anEdge").directed("true").property(TestPropertyNames.PROP_1, "string").build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("string").destination("string").description("anotherEdge").directed("true").property(TestPropertyNames.PROP_1, "string").build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").description("anEntity").build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new StringSerialiser()).aggregateFunction(new StringConcat()).build()).type("true", Boolean.class).build();
compactSchemaBytes = schema.toCompactJson();
}
use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.
the class TableUtilsTest method shouldCreateTableWithAllRequiredIterators.
@Test
public void shouldCreateTableWithAllRequiredIterators() throws Exception {
// Given
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
store.initialise(GRAPH_ID, schema, PROPERTIES);
// When
TableUtils.createTable(store);
// Then - this call will check the table is configured properly
TableUtils.ensureTableExists(store);
}
use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.
the class TableUtilsTest method shouldFailTableValidationWhenMissingValidatorIterator.
@Test
public void shouldFailTableValidationWhenMissingValidatorIterator() throws Exception {
final AccumuloStore store = new SingleUseMiniAccumuloStore();
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).validateFunctions(new Exists()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
store.initialise(GRAPH_ID, schema, PROPERTIES);
final Runnable invalidateTable = () -> {
try {
AddUpdateTableIterator.removeIterator(store, AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME);
} catch (final StoreException e) {
throw new RuntimeException(e);
}
};
shouldFailTableValidationWhenTableInvalid(store, invalidateTable);
}
use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.
the class TableUtilsTest method shouldFailTableValidationWhenTableInvalid.
public void shouldFailTableValidationWhenTableInvalid(final AccumuloStore store, final Runnable invalidateTable) throws Exception {
// Given
final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).validateFunctions(new Exists()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
final AccumuloProperties props = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(TableUtilsTest.class));
store.initialise(GRAPH_ID, schema, props);
invalidateTable.run();
// When / Then
assertThatExceptionOfType(StoreException.class).isThrownBy(() -> TableUtils.ensureTableExists(store)).extracting("message").isNotNull();
}
Aggregations