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);
}
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);
}
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);
}
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());
}
Aggregations