use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class StoreTest method shouldGetJobTracker.
@Test
public void shouldGetJobTracker() throws OperationException, ExecutionException, InterruptedException, StoreException {
// Given
final StoreProperties properties = mock(StoreProperties.class);
given(properties.getJobTrackerClass()).willReturn("jobTrackerClass");
final Store store = new StoreImpl();
final Schema schema = new Schema();
store.initialise(schema, properties);
// When
final JobTracker resultJobTracker = store.getJobTracker();
// Then
assertSame(jobTracker, resultJobTracker);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class StoreTest method shouldReturnTrueWhenOperationSupported.
@Test
public void shouldReturnTrueWhenOperationSupported() throws Exception {
// Given
final Schema schema = createSchemaMock();
final StoreProperties properties = mock(StoreProperties.class);
final Validatable<Integer> validatable = mock(Validatable.class);
final Map<String, String> options = mock(HashMap.class);
final StoreImpl store = new StoreImpl();
final int expectedNumberOfOperations = 15;
given(validatable.isValidate()).willReturn(true);
given(validatable.getOptions()).willReturn(options);
given(validatableHandler.doOperation(validatable, context, store)).willReturn(expectedNumberOfOperations);
store.initialise(schema, properties);
// WHen
final Set<Class<? extends Operation>> supportedOperations = store.getSupportedOperations();
for (final Class<? extends Operation> operationClass : supportedOperations) {
final boolean isOperationClassSupported = store.isSupported(operationClass);
// Then
assertTrue(isOperationClassSupported);
}
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class AccumuloStoreRelationTest method testBuildScanSpecifyColumnsFullView.
@Test
public void testBuildScanSpecifyColumnsFullView() throws OperationException, StoreException {
final Schema schema = getSchema();
final View view = getViewFromSchema(schema);
final String[] requiredColumns = new String[] { "property1" };
testBuildScanSpecifyColumnsWithView("testBuildScanSpecifyColumnsFullView", view, requiredColumns, e -> true);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class AccumuloStoreRelationTest method testBuildScanWithView.
private void testBuildScanWithView(final String name, final View view, final Predicate<Element> returnElement) throws OperationException, StoreException {
// Given
final SQLContext sqlContext = getSqlContext(name);
final Schema schema = getSchema();
final AccumuloProperties properties = AccumuloProperties.loadStoreProperties(AccumuloStoreRelationTest.class.getResourceAsStream("/store.properties"));
final SingleUseMockAccumuloStore store = new SingleUseMockAccumuloStore();
store.initialise(schema, properties);
addElements(store);
// When
final AccumuloStoreRelation relation = new AccumuloStoreRelation(sqlContext, Collections.emptyList(), view, store, new User());
final RDD<Row> rdd = relation.buildScan();
final Row[] returnedElements = (Row[]) rdd.collect();
// Then
// - Actual results are:
final Set<Row> results = new HashSet<>();
for (int i = 0; i < returnedElements.length; i++) {
results.add(returnedElements[i]);
}
// - Expected results are:
final SchemaToStructTypeConverter schemaConverter = new SchemaToStructTypeConverter(schema, view, new ArrayList<>());
final ConvertElementToRow elementConverter = new ConvertElementToRow(schemaConverter.getUsedProperties(), schemaConverter.getPropertyNeedsConversion(), schemaConverter.getConverterByProperty());
final Set<Row> expectedRows = new HashSet<>();
StreamSupport.stream(getElements().spliterator(), false).filter(returnElement).map(elementConverter::apply).forEach(expectedRows::add);
assertEquals(expectedRows, results);
sqlContext.sparkContext().stop();
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class AccumuloStoreRelationTest method testBuildScanSpecifyColumnsAndFiltersFullView.
@Test
public void testBuildScanSpecifyColumnsAndFiltersFullView() throws OperationException, StoreException {
final Schema schema = getSchema();
final View view = getViewFromSchema(schema);
final String[] requiredColumns = new String[1];
requiredColumns[0] = "property1";
final Filter[] filters = new Filter[1];
filters[0] = new GreaterThan("property1", 4);
final Predicate<Element> returnElement = (Element element) -> ((Integer) element.getProperty("property1")) > 4;
testBuildScanSpecifyColumnsAndFiltersWithView("testBuildScanSpecifyColumnsAndFiltersFullView", view, requiredColumns, filters, returnElement);
}
Aggregations