Search in sources :

Example 11 with StoreTrait

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);
}
Also used : StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 12 with StoreTrait

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 13 with StoreTrait

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Builder(uk.gov.gchq.gaffer.store.schema.Schema.Builder) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Example 14 with StoreTrait

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);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Test(org.junit.jupiter.api.Test)

Example 15 with StoreTrait

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));
    }
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Before(org.junit.Before)

Aggregations

StoreTrait (uk.gov.gchq.gaffer.store.StoreTrait)29 Schema (uk.gov.gchq.gaffer.store.schema.Schema)16 Test (org.junit.jupiter.api.Test)15 Context (uk.gov.gchq.gaffer.store.Context)11 HashSet (java.util.HashSet)9 Graph (uk.gov.gchq.gaffer.graph.Graph)8 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)8 GetTraits (uk.gov.gchq.gaffer.store.operation.GetTraits)8 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)7 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)4 Test (org.junit.Test)3 MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)3 Operation (uk.gov.gchq.gaffer.operation.Operation)3 Store (uk.gov.gchq.gaffer.store.Store)3 Annotation (java.lang.annotation.Annotation)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Before (org.junit.Before)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2