Search in sources :

Example 1 with GetSchema

use of uk.gov.gchq.gaffer.store.operation.GetSchema in project gaffer-doc by gchq.

the class GetSchemaExample method getFullSchema.

public void getFullSchema() {
    // ---------------------------------------------------------
    final GetSchema operation = new GetSchema();
    // ---------------------------------------------------------
    runExample(operation, "This operation defaults the compact field to false, " + "thereby returning the full Schema.");
}
Also used : GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema)

Example 2 with GetSchema

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

the class FederatedGetSchemaHandlerTest method shouldReturnSchema.

@Test
public void shouldReturnSchema() throws OperationException {
    library.addProperties(ACC_PROP_ID, PROPERTIES);
    fStore.setGraphLibrary(library);
    final Schema edgeSchema = new Schema.Builder().edge("edge", new SchemaEdgeDefinition.Builder().source("string").destination("string").directed(DIRECTED_EITHER).property("prop1", "string").build()).vertexSerialiser(new StringSerialiser()).type(DIRECTED_EITHER, Boolean.class).merge(STRING_SCHEMA).build();
    library.addSchema(EDGE_SCHEMA_ID, edgeSchema);
    fStore.execute(Operation.asOperationChain(new AddGraph.Builder().graphId("schema").parentPropertiesId(ACC_PROP_ID).parentSchemaIds(Lists.newArrayList(EDGE_SCHEMA_ID)).build()), context);
    final GetSchema operation = new GetSchema.Builder().compact(true).build();
    // When
    final Schema result = handler.doOperation(operation, context, fStore);
    // Then
    assertNotNull(result);
    JsonAssert.assertEquals(edgeSchema.toJson(true), result.toJson(true));
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Test(org.junit.jupiter.api.Test)

Example 3 with GetSchema

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

the class GetSchemaHandlerTest method shouldReturnCompactSchema.

@Test
public void shouldReturnCompactSchema() throws OperationException {
    given(store.getProperties()).willReturn(properties);
    given(store.getSchema()).willReturn(schema);
    given(context.getUser()).willReturn(user);
    final GetSchema operation = new GetSchema.Builder().compact(true).build();
    // When
    final Schema result = handler.doOperation(operation, context, store);
    // Then
    assertNotNull(result);
    JsonAssert.assertNotEqual(schema.toJson(true), result.toJson(true));
    JsonAssert.assertEquals(compactSchemaBytes, result.toJson(true));
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Test(org.junit.jupiter.api.Test)

Example 4 with GetSchema

use of uk.gov.gchq.gaffer.store.operation.GetSchema in project gaffer-doc by gchq.

the class GetSchemaExample method getCompactSchema.

public void getCompactSchema() {
    // ---------------------------------------------------------
    final GetSchema operation = new GetSchema.Builder().compact(true).build();
    // ---------------------------------------------------------
    runExample(operation, "This operation will retrieve the compact Schema from the store, " + "rather than the full schema.");
}
Also used : GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema)

Example 5 with GetSchema

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

the class GetSchemaHandlerTest method shouldReturnFullSchema.

@Test
public void shouldReturnFullSchema() throws OperationException {
    given(store.getProperties()).willReturn(properties);
    given(store.getOriginalSchema()).willReturn(schema);
    given(context.getUser()).willReturn(user);
    final GetSchema operation = new GetSchema();
    // When
    final Schema result = handler.doOperation(operation, context, store);
    // Then
    assertNotNull(result);
    JsonAssert.assertEquals(schema.toJson(true), result.toJson(true));
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Test(org.junit.jupiter.api.Test)

Aggregations

GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)10 Schema (uk.gov.gchq.gaffer.store.schema.Schema)7 Test (org.junit.jupiter.api.Test)5 List (java.util.List)3 SchemaException (uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException)3 OperationException (uk.gov.gchq.gaffer.operation.OperationException)3 Graph (uk.gov.gchq.gaffer.graph.Graph)2 Builder (uk.gov.gchq.gaffer.store.schema.Schema.Builder)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Set (java.util.Set)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 StreamSupport (java.util.stream.StreamSupport)1 Logger (org.slf4j.Logger)1