Search in sources :

Example 21 with StoreTrait

use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.

the class FederatedGraphStorageTraitsTest method shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly.

@Test
public void shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly() 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);
    getTraits.setCurrentTraits(false);
    // 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_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 22 with StoreTrait

use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.

the class FederatedStoreGetTraitsTest method shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly.

@Test
public void shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly() throws Exception {
    // given
    final GraphSerialisable acc2 = new GraphSerialisable.Builder().graph(acc.getGraph()).config(new GraphConfig(GRAPH_ID_ACCUMULO + 2)).build();
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_AND_USER, acc);
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, acc2);
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, map);
    getTraits.addOption(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_ID_MAP);
    getTraits.setCurrentTraits(false);
    // when
    final Set<StoreTrait> traits = federatedStore.execute(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_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.Test)

Example 23 with StoreTrait

use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.

the class FederatedStoreGetTraitsTest 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();
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_AND_USER, acc);
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, acc2);
    federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, map);
    getTraits.addOption(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_ID_MAP);
    // when
    final Set<StoreTrait> traits = federatedStore.execute(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.Test)

Example 24 with StoreTrait

use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.

the class ProxyStore method fetchTraits.

protected Set<StoreTrait> fetchTraits() throws StoreException {
    final URL url = getProperties().getGafferUrl("graph/config/storeTraits");
    final ResponseDeserialiser<Set<StoreTrait>> responseDeserialiser = getResponseDeserialiserFor(new TypeReferenceStoreImpl.StoreTraits());
    Set<StoreTrait> newTraits = doGet(url, responseDeserialiser, null);
    if (null == newTraits) {
        newTraits = new HashSet<>(0);
    } else {
        // This proxy store cannot handle visibility due to the simple rest api using a default user.
        newTraits.remove(StoreTrait.VISIBILITY);
    }
    return newTraits;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) TypeReferenceStoreImpl(uk.gov.gchq.gaffer.store.TypeReferenceStoreImpl) URL(java.net.URL)

Example 25 with StoreTrait

use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.

the class MapStoreTest method testTraits.

@Test
public void testTraits() throws StoreException {
    final MapStore mapStore = new MapStore();
    mapStore.initialise("graphId", new Schema(), new MapStoreProperties());
    final Set<StoreTrait> expectedTraits = new HashSet<>(Arrays.asList(StoreTrait.VISIBILITY, StoreTrait.QUERY_AGGREGATION, StoreTrait.INGEST_AGGREGATION, StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.TRANSFORMATION, StoreTrait.POST_TRANSFORMATION_FILTERING, StoreTrait.MATCHED_VERTEX));
    assertEquals(expectedTraits, mapStore.getTraits());
}
Also used : StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

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