Search in sources :

Example 1 with RawDoubleSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser in project Gaffer by gchq.

the class SerialisationFactoryTest method shouldReturnCustomSerialiserIfCustomSerialiserFound.

@Test
public void shouldReturnCustomSerialiserIfCustomSerialiserFound() throws SerialisationException {
    // Given
    final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
    final SerialisationFactory factory = new SerialisationFactory(serialisers);
    final Class<?> clazz = Double.class;
    // When
    final Serialiser serialiser = factory.getSerialiser(clazz);
    // Then
    assertTrue(serialiser.canHandle(clazz));
    assertEquals(RawDoubleSerialiser.class, serialiser.getClass());
}
Also used : RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) OrderedIntegerSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser) RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) BooleanSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.BooleanSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) Test(org.junit.jupiter.api.Test)

Example 2 with RawDoubleSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser in project Gaffer by gchq.

the class SerialisationFactoryTest method testAddSerialisers.

@Test
public void testAddSerialisers() throws SerialisationException {
    // Given
    final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
    final SerialisationFactory factory = new SerialisationFactory(serialisers);
    final Class<?> clazz = String.class;
    // When
    factory.addSerialisers(new StringSerialiser());
    Serialiser serialiser = factory.getSerialiser(clazz);
    // Then
    assertTrue(serialiser.canHandle(clazz));
    assertEquals(StringSerialiser.class, serialiser.getClass());
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) OrderedIntegerSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser) RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) BooleanSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.BooleanSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) Test(org.junit.jupiter.api.Test)

Example 3 with RawDoubleSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser in project Gaffer by gchq.

the class GraphTest method shouldThrowExceptionIfSchemaIsInvalid.

@Test
public void shouldThrowExceptionIfSchemaIsInvalid() throws OperationException {
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStoreImpl.class.getName());
    try {
        new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).build()).addSchema(new Schema.Builder().type("int", new TypeDefinition.Builder().clazz(Integer.class).aggregateFunction(new Sum()).serialiser(new RawDoubleSerialiser()).build()).type("string", new TypeDefinition.Builder().clazz(String.class).aggregateFunction(new StringConcat()).build()).type("boolean", Boolean.class).edge("EDGE", new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("boolean").build()).entity("ENTITY", new SchemaEntityDefinition.Builder().vertex("string").property("p2", "int").build()).build()).storeProperties(storeProperties).build();
        fail("exception expected");
    } catch (final SchemaException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : SchemaException(uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Sum(uk.gov.gchq.koryphe.impl.binaryoperator.Sum) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

Example 4 with RawDoubleSerialiser

use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser in project Gaffer by gchq.

the class SerialisationFactoryTest method shouldReturnJavaSerialiserIfNoCustomSerialiserFound.

@Test
public void shouldReturnJavaSerialiserIfNoCustomSerialiserFound() throws SerialisationException {
    // Given
    final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
    final SerialisationFactory factory = new SerialisationFactory(serialisers);
    final Class<?> clazz = String.class;
    // When
    final Serialiser serialiser = factory.getSerialiser(clazz);
    // Then
    assertTrue(serialiser.canHandle(clazz));
    assertEquals(JavaSerialiser.class, serialiser.getClass());
}
Also used : RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) OrderedIntegerSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser) RawDateSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) BooleanSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.BooleanSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) RawFloatSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 RawDoubleSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser)4 Serialiser (uk.gov.gchq.gaffer.serialisation.Serialiser)3 BooleanSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.BooleanSerialiser)3 JavaSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser)3 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)3 OrderedIntegerSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.ordered.OrderedIntegerSerialiser)3 RawDateSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDateSerialiser)3 RawFloatSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser)3 SchemaException (uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException)1 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)1 StringConcat (uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat)1 Sum (uk.gov.gchq.koryphe.impl.binaryoperator.Sum)1