Search in sources :

Example 1 with StringToStringSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser in project Gaffer by gchq.

the class SchemaTest method shouldThrowExceptionWhenMergeSchemasWithConflictingVertexSerialiser.

@Test
public void shouldThrowExceptionWhenMergeSchemasWithConflictingVertexSerialiser() {
    // Given
    final Serialiser vertexSerialiser1 = new StringSerialiser();
    final Serialiser vertexSerialiser2 = new StringToStringSerialiser();
    final Schema schema1 = new Schema.Builder().vertexSerialiser(vertexSerialiser1).build();
    final Schema schema2 = new Schema.Builder().vertexSerialiser(vertexSerialiser2).build();
    // When / Then
    assertThatExceptionOfType(SchemaException.class).isThrownBy(() -> new Schema.Builder().merge(schema1).merge(schema2).build()).withMessageContaining("vertex serialiser");
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) RawLongSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawLongSerialiser) MapSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.MapSerialiser) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) ToBytesSerialiser(uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) Test(org.junit.jupiter.api.Test)

Example 2 with StringToStringSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser in project Gaffer by gchq.

the class StoreTest method shouldFindInvalidSerialiser.

@Test
public void shouldFindInvalidSerialiser() throws Exception {
    final Class<StringToStringSerialiser> invalidSerialiserClass = StringToStringSerialiser.class;
    Schema invalidSchema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("invalidString").directed("true").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new StringSerialiser()).build()).type("invalidString", new TypeDefinition.Builder().clazz(String.class).serialiser(invalidSerialiserClass.newInstance()).build()).type("true", Boolean.class).build();
    final StoreProperties properties = mock(StoreProperties.class);
    given(properties.getJobExecutorThreadCount()).willReturn(1);
    final Class<ToBytesSerialiser> validSerialiserInterface = ToBytesSerialiser.class;
    try {
        new StoreImpl() {

            @Override
            protected Class<? extends Serialiser> getRequiredParentSerialiserClass() {
                return validSerialiserInterface;
            }
        }.initialise("graphId", invalidSchema, properties);
        fail("Should have thrown exception");
    } catch (final SchemaException e) {
        assertTrue(e.getMessage().contains(invalidSerialiserClass.getSimpleName()));
    }
}
Also used : SchemaException(uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) ToBytesSerialiser(uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) ToBytesSerialiser(uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 Serialiser (uk.gov.gchq.gaffer.serialisation.Serialiser)2 ToBytesSerialiser (uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser)2 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)2 StringToStringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser)2 SchemaException (uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException)1 JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)1 JavaSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser)1 MapSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.MapSerialiser)1 RawLongSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.raw.RawLongSerialiser)1 GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)1 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)1