use of uk.gov.gchq.gaffer.function.aggregate.StringConcat in project Gaffer by gchq.
the class GraphTest method shouldThrowExceptionIfSchemaIsInvalid.
@Test
public void shouldThrowExceptionIfSchemaIsInvalid() throws OperationException {
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(StoreImpl.class.getName());
try {
new Graph.Builder().addSchema(new Schema.Builder().type("intnoagg", new TypeDefinition.Builder().clazz(Integer.class).build()).type("int", new TypeDefinition.Builder().clazz(Integer.class).aggregateFunction(new Sum()).build()).type("string", new TypeDefinition.Builder().clazz(String.class).aggregateFunction(new StringConcat()).build()).type("boolean", Boolean.class).edge("EDGE", new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("boolean").property("p", "intnoagg").build()).entity("ENTITY", new SchemaEntityDefinition.Builder().vertex("string").property("p2", "int").build()).build()).storeProperties(storeProperties).build();
fail("exception expected");
} catch (final SchemaException e) {
assertNotNull(e.getMessage());
}
}
use of uk.gov.gchq.gaffer.function.aggregate.StringConcat in project Gaffer by gchq.
the class TableUtilsTest method shouldCreateTableWithAllRequiredIterators.
@Test
public void shouldCreateTableWithAllRequiredIterators() throws Exception {
// Given
final MockAccumuloStore store = new MockAccumuloStore();
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();
final AccumuloProperties props = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(TableUtilsTest.class));
props.setTable(TABLE_NAME);
store.initialise(schema, props);
// When
TableUtils.createTable(store);
// Then
final Map<String, EnumSet<IteratorScope>> itrs = store.getConnection().tableOperations().listIterators(TABLE_NAME);
assertEquals(2, itrs.size());
final EnumSet<IteratorScope> validator = itrs.get(AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME);
assertEquals(EnumSet.allOf(IteratorScope.class), validator);
final IteratorSetting validatorSetting = store.getConnection().tableOperations().getIteratorSetting(TABLE_NAME, AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME, IteratorScope.majc);
assertEquals(AccumuloStoreConstants.VALIDATOR_ITERATOR_PRIORITY, validatorSetting.getPriority());
assertEquals(ValidatorFilter.class.getName(), validatorSetting.getIteratorClass());
final Map<String, String> validatorOptions = validatorSetting.getOptions();
assertNotNull(Schema.fromJson(validatorOptions.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8)).getEdge(TestGroups.EDGE));
assertEquals(ByteEntityAccumuloElementConverter.class.getName(), validatorOptions.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
final EnumSet<IteratorScope> aggregator = itrs.get(AccumuloStoreConstants.AGGREGATOR_ITERATOR_NAME);
assertEquals(EnumSet.allOf(IteratorScope.class), aggregator);
final IteratorSetting aggregatorSetting = store.getConnection().tableOperations().getIteratorSetting(TABLE_NAME, AccumuloStoreConstants.AGGREGATOR_ITERATOR_NAME, IteratorScope.majc);
assertEquals(AccumuloStoreConstants.AGGREGATOR_ITERATOR_PRIORITY, aggregatorSetting.getPriority());
assertEquals(AggregatorIterator.class.getName(), aggregatorSetting.getIteratorClass());
final Map<String, String> aggregatorOptions = aggregatorSetting.getOptions();
assertNotNull(Schema.fromJson(aggregatorOptions.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8)).getEdge(TestGroups.EDGE));
assertEquals(ByteEntityAccumuloElementConverter.class.getName(), aggregatorOptions.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
final Map<String, String> tableProps = new HashMap<>();
for (final Map.Entry<String, String> entry : store.getConnection().tableOperations().getProperties(TABLE_NAME)) {
tableProps.put(entry.getKey(), entry.getValue());
}
assertEquals(0, Integer.parseInt(tableProps.get(Property.TABLE_FILE_REPLICATION.getKey())));
}
Aggregations