use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class GetTraitsHandlerTest method shouldGetTraitsForSchemaEmpty.
@Test
public void shouldGetTraitsForSchemaEmpty() throws Exception {
// When
final Set<StoreTrait> actual = getStoreTraits(new Schema());
// Then
final Set<StoreTrait> expected = Sets.newHashSet(this.expectedTraits);
expected.remove(StoreTrait.QUERY_AGGREGATION);
expected.remove(StoreTrait.STORE_VALIDATION);
expected.remove(StoreTrait.VISIBILITY);
expected.remove(StoreTrait.INGEST_AGGREGATION);
assertEquals(expected, actual);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class GetTraitsHandlerTest method shouldHaveAllTraitsForSupported.
@Test
public void shouldHaveAllTraitsForSupported() throws Exception {
// Given
store.initialise(STORE_ID, new Schema(), new StoreProperties());
// When
Set<StoreTrait> traits = store.execute(new GetTraits.Builder().currentTraits(false).build(), new Context(testUser()));
// Then
assertEquals(expectedTraits, traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedStoreTest method shouldCombineTraitsToMin.
@Test
public void shouldCombineTraitsToMin() throws Exception {
// Given
final GetTraits getTraits = new GetTraits.Builder().currentTraits(true).build();
// When
final Set<StoreTrait> before = store.getTraits(getTraits, userContext);
store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(ACC_ID_1).storeProperties(PROPERTIES_1).build(), new Context(testUser()));
final Set<StoreTrait> afterAcc = store.getTraits(getTraits, userContext);
StoreProperties TestStoreImp = new StoreProperties();
TestStoreImp.setStoreClass(FederatedGetTraitsHandlerTest.TestStoreImpl.class);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(MAP_ID_1).storeProperties(TestStoreImp).build(), new Context(testUser()));
final Set<StoreTrait> afterMap = store.getTraits(getTraits, userContext);
// Then
assertNotEquals(SingleUseAccumuloStore.TRAITS, new HashSet<>(Arrays.asList(StoreTrait.INGEST_AGGREGATION, StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.TRANSFORMATION, StoreTrait.POST_TRANSFORMATION_FILTERING, StoreTrait.MATCHED_VERTEX)));
assertEquals(Collections.emptySet(), before, "No traits should be found for an empty FederatedStore");
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, ORDERED, MATCHED_VERTEX), afterAcc);
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, MATCHED_VERTEX), afterMap);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class FederatedGraphStorageTraitsTest method shouldGetCurrentTraitsForAddingUserButSelectedGraphsOnly.
@Test
public void shouldGetCurrentTraitsForAddingUserButSelectedGraphsOnly() throws Exception {
// given
final GraphSerialisable acc2 = new GraphSerialisable.Builder().graph(acc.getGraph()).config(new GraphConfig(GRAPH_ID_ACCUMULO + 2)).build();
graphStorage.put(acc, ACCESS_UNUSED_AUTH_AND_USER);
graphStorage.put(acc2, ACCESS_UNUSED_AUTH_WITH_TEST_USER);
graphStorage.put(map, ACCESS_UNUSED_AUTH_WITH_TEST_USER);
getTraits.addOption(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_ID_MAP);
// when
final Set<StoreTrait> traits = graphStorage.getTraits(getTraits, testUserContext);
// then
assertNotEquals(ACCUMULO_TRAITS, traits, "Returning AccumuloStore traits instead of MapStore");
assertEquals(Collections.emptySet(), traits.stream().filter(ACCUMULO_TRAITS_EXCLUSIVE_OF_MAP::contains).collect(Collectors.toSet()), "Revealing some hidden traits from the AccumuloStore instead of only MapStore");
assertEquals(MAP_CURRENT_TRAITS, traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class AbstractStoreIT method setup.
/**
* Setup the Parameterised Graph for each type of Store.
* Excludes tests where the graph's Store doesn't implement the required StoreTraits.
*
* @throws Exception should never be thrown
*/
@Before
public void setup() throws Exception {
assumeTrue("Skipping test as no store properties have been defined.", null != storeProperties);
final String originalMethodName = name.getMethodName().endsWith("]") ? name.getMethodName().substring(0, name.getMethodName().indexOf("[")) : name.getMethodName();
assumeTrue("Skipping test as only " + singleTestMethod + " is being run.", null == singleTestMethod || singleTestMethod.equals(originalMethodName));
final Method testMethod = this.getClass().getMethod(originalMethodName);
final Collection<StoreTrait> requiredTraits = new ArrayList<>();
for (final Annotation annotation : testMethod.getDeclaredAnnotations()) {
if (annotation.annotationType().equals(TraitRequirement.class)) {
final TraitRequirement traitRequirement = (TraitRequirement) annotation;
requiredTraits.addAll(Arrays.asList(traitRequirement.value()));
}
}
assumeTrue("Skipping test. Justification: " + skippedTests.get(getClass()), !skippedTests.containsKey(getClass()));
graph = new Graph.Builder().storeProperties(storeProperties).addSchema(createSchema()).addSchema(storeSchema).build();
for (final StoreTrait requiredTrait : requiredTraits) {
assumeTrue("Skipping test as the store does not implement all required traits.", graph.hasTrait(requiredTrait));
}
}
Aggregations