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