use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method testCanSerialiseDeSerialiseCorrectly.
@Test
public void testCanSerialiseDeSerialiseCorrectly() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue("testType", "testSubType", "testValue");
// When
final byte[] bytes = SERIALISER.serialise(typeSubTypeValue);
final String serialisedForm = new String(bytes);
// Then
assertEquals("testType\0testSubType\0testValue", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(bytes);
// Then
assertEquals(typeSubTypeValue.getType(), deSerialisedTypeSubTypeValue.getType());
assertEquals(typeSubTypeValue.getSubType(), deSerialisedTypeSubTypeValue.getSubType());
assertEquals(typeSubTypeValue.getValue(), deSerialisedTypeSubTypeValue.getValue());
assertEquals(typeSubTypeValue, deSerialisedTypeSubTypeValue);
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method shouldDeserialiseEmpty.
@Test
@Override
public void shouldDeserialiseEmpty() {
final TypeSubTypeValue value = SERIALISER.deserialiseEmpty();
assertEquals(new TypeSubTypeValue(), value);
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method testCanSerialiseDeSerialiseCorrectlyTypeValueOnly.
@Test
public void testCanSerialiseDeSerialiseCorrectlyTypeValueOnly() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue();
typeSubTypeValue.setValue("testValue");
typeSubTypeValue.setType("testType");
// When
final byte[] bytes = SERIALISER.serialise(typeSubTypeValue);
final String serialisedForm = new String(bytes);
// Then
assertEquals("testType\0\0testValue", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(bytes);
// Then
assertEquals(typeSubTypeValue.getType(), deSerialisedTypeSubTypeValue.getType());
assertNull(deSerialisedTypeSubTypeValue.getSubType());
assertEquals(typeSubTypeValue.getValue(), deSerialisedTypeSubTypeValue.getValue());
assertEquals(typeSubTypeValue, deSerialisedTypeSubTypeValue);
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method testCanSerialiseDeSerialiseCorrectlyTypeOnly.
@Test
public void testCanSerialiseDeSerialiseCorrectlyTypeOnly() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue();
typeSubTypeValue.setType("testType");
// When
final byte[] bytes = SERIALISER.serialise(typeSubTypeValue);
final String serialisedForm = new String(bytes);
// Then
assertEquals("testType\0\0", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(bytes);
// Then
assertEquals(typeSubTypeValue.getType(), deSerialisedTypeSubTypeValue.getType());
assertNull(deSerialisedTypeSubTypeValue.getSubType());
assertNull(typeSubTypeValue.getValue(), deSerialisedTypeSubTypeValue.getValue());
assertEquals(typeSubTypeValue, deSerialisedTypeSubTypeValue);
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class ToTypeSubTypeValueTest method shouldConvertNullToTypeSubTypeValue.
@Test
public void shouldConvertNullToTypeSubTypeValue() {
// Given
final ToTypeSubTypeValue function = new ToTypeSubTypeValue();
// When
final TypeSubTypeValue result = function.apply(null);
// Then
assertEquals(new TypeSubTypeValue(null, null, null), result);
}
Aggregations