Search in sources :

Example 6 with StoreTrait

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

the class GraphConfigurationControllerTest method shouldSerialiseAndDeserialiseGetStoreTraits.

@Test
public void shouldSerialiseAndDeserialiseGetStoreTraits() throws SerialisationException {
    // Given
    Store store = mock(Store.class);
    Schema schema = new Schema();
    StoreProperties props = new StoreProperties();
    Set<StoreTrait> storeTraits = Sets.newHashSet(INGEST_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING);
    when(store.getSchema()).thenReturn(schema);
    when(store.getProperties()).thenReturn(props);
    when(store.getTraits()).thenReturn(storeTraits);
    Graph graph = new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).store(store).build();
    when(graphFactory.getGraph()).thenReturn(graph);
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    // When
    byte[] bytes = JSONSerialiser.serialise(controller.getStoreTraits());
    final Set<String> traits = JSONSerialiser.deserialise(bytes, Set.class);
    // Then
    assertEquals(Sets.newHashSet(INGEST_AGGREGATION.name(), PRE_AGGREGATION_FILTERING.name(), POST_AGGREGATION_FILTERING.name()), traits);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStore(uk.gov.gchq.gaffer.mapstore.MapStore) Store(uk.gov.gchq.gaffer.store.Store) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 7 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetCurrentTraitsWhenContainsStoreWithOtherTraitsWithOptions.

@Test
public void shouldGetCurrentTraitsWhenContainsStoreWithOtherTraitsWithOptions() throws Exception {
    // Given
    federatedStore.initialise(FED_STORE_ID, null, properties);
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ACC_STORE).storeProperties(PROPERTIES).schema(new Schema()).build(), new Context(testUser()));
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().option(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, ALT_STORE).currentTraits(true).build(), new Context(testUser()));
    // Then
    assertEquals(Sets.newHashSet(TRANSFORMATION, MATCHED_VERTEX, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING), traits);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 8 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetZeroTraitsForEmptyStore.

@Test
public void shouldGetZeroTraitsForEmptyStore() throws Exception {
    // Given
    federatedStore.initialise(FED_STORE_ID, null, properties);
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(false).build(), new Context(testUser()));
    // Then
    assertEquals(Collections.emptySet(), 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) Test(org.junit.jupiter.api.Test)

Example 9 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetCurrentTraitsWhenContainsStoreWithOtherTraits.

@Test
public void shouldGetCurrentTraitsWhenContainsStoreWithOtherTraits() throws Exception {
    // Given
    federatedStore.initialise(FED_STORE_ID, null, properties);
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(true).build(), new Context(testUser()));
    // Then
    assertEquals(Sets.newHashSet(TRANSFORMATION, MATCHED_VERTEX, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING), 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) Test(org.junit.jupiter.api.Test)

Example 10 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetAllTraitsWhenContainsStoreWithOtherTraitsWithOptions.

@Test
public void shouldGetAllTraitsWhenContainsStoreWithOtherTraitsWithOptions() throws Exception {
    // Given
    federatedStore.initialise(FED_STORE_ID, null, properties);
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE).storeProperties(storeProperties).schema(new Schema()).build(), new Context(testUser()));
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ACC_STORE).storeProperties(PROPERTIES).schema(new Schema()).build(), new Context(testUser()));
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().option(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, ALT_STORE).currentTraits(false).build(), new Context(testUser()));
    // Then
    assertEquals(TestStoreImpl.STORE_TRAITS, traits);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) 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