Search in sources :

Example 26 with StoreTrait

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

the class GraphConfigurationControllerIT method shouldReturn200WithAllStoreTraits.

@Test
public void shouldReturn200WithAllStoreTraits() {
    // Given
    Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    when(graphFactory.getGraph()).thenReturn(emptyGraph);
    // When
    ResponseEntity<Set> response = get("/graph/config/storeTraits", Set.class);
    // The response will come back as a Set of strings. We'll convert these to store traits
    Set<StoreTrait> responseTraits = new HashSet<>();
    response.getBody().forEach(trait -> responseTraits.add(StoreTrait.valueOf((String) trait)));
    // Then
    checkResponse(response, 200);
    assertThat(responseTraits).isEqualTo(MapStore.TRAITS);
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Set(java.util.Set) HashSet(java.util.HashSet) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with StoreTrait

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

the class GraphConfigurationControllerTest method shouldGetStoreTraits.

@Test
public void shouldGetStoreTraits() {
    // Given
    when(graphFactory.getGraph()).thenReturn(new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).storeProperties(// Will be a map store
    new MapStoreProperties()).build());
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    // When
    final Set<StoreTrait> traits = controller.getStoreTraits();
    // Then
    assertEquals(MapStore.TRAITS, 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) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 28 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetZeroTraitsForEmptyStoreWithCurrentTraits.

@Test
public void shouldGetZeroTraitsForEmptyStoreWithCurrentTraits() throws Exception {
    // Given
    federatedStore.initialise(FED_STORE_ID, null, properties);
    assertEquals(0, federatedStore.getAllGraphIds(testUser()).size(), "graph is not starting empty");
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(true).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 29 with StoreTrait

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

the class FederatedGetTraitsHandlerTest method shouldGetAllTraitsWhenContainsStoreWithOtherTraits.

@Test
public void shouldGetAllTraitsWhenContainsStoreWithOtherTraits() 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()));
    StoreProperties altProps = new StoreProperties();
    altProps.setStoreClass(TestStoreAltImpl.class);
    federatedStore.execute(new AddGraph.Builder().isPublic(true).graphId(ALT_STORE + 2).storeProperties(altProps).schema(new Schema()).build(), new Context(testUser()));
    // When
    final Set<StoreTrait> traits = federatedStore.execute(new GetTraits.Builder().currentTraits(false).build(), new Context(testUser()));
    HashSet<Object> expectedIntersectionTraits = new HashSet<>();
    expectedIntersectionTraits.addAll(TestStoreImpl.STORE_TRAITS);
    expectedIntersectionTraits.retainAll(TestStoreAltImpl.STORE_TRAITS);
    // Then
    assertEquals(expectedIntersectionTraits, traits);
    assertTrue(expectedIntersectionTraits.size() < TestStoreImpl.STORE_TRAITS.size());
}
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) FederatedStoreProperties(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) 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