use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method shouldDeserialiseEmptyBytes.
@Override
public void shouldDeserialiseEmptyBytes() throws SerialisationException {
// When
final TypeSubTypeValue value = serialiser.deserialiseEmptyBytes();
// Then
assertEquals(new TypeSubTypeValue(), value);
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method testCanSerialiseDeSerialiseCorrectlyTypeSubTypeOnly.
@Test
public void testCanSerialiseDeSerialiseCorrectlyTypeSubTypeOnly() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue();
typeSubTypeValue.setType("testType");
typeSubTypeValue.setSubType("testSubType");
// When
final byte[] bytes = SERIALISER.serialise(typeSubTypeValue);
final String serialisedForm = new String(bytes);
// Then
assertEquals("testType\0testSubType\0", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(bytes);
// Then
assertEquals(typeSubTypeValue.getType(), deSerialisedTypeSubTypeValue.getType());
assertEquals(typeSubTypeValue.getSubType(), 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 TypeSubTypeValueSerialiserTest method getHistoricSerialisationPairs.
@Override
public Pair<TypeSubTypeValue, byte[]>[] getHistoricSerialisationPairs() {
TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue();
typeSubTypeValue.setType("testType");
typeSubTypeValue.setSubType("testSubType");
return new Pair[] { new Pair(typeSubTypeValue, new byte[] { 116, 101, 115, 116, 84, 121, 112, 101, 0, 116, 101, 115, 116, 83, 117, 98, 84, 121, 112, 101, 0 }) };
}
use of uk.gov.gchq.gaffer.types.TypeSubTypeValue in project Gaffer by gchq.
the class TypeSubTypeValueSerialiserTest method testCanSerialiseDeSerialiseCorrectlySubTypeValueOnly.
@Test
public void testCanSerialiseDeSerialiseCorrectlySubTypeValueOnly() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue();
typeSubTypeValue.setValue("testValue");
typeSubTypeValue.setSubType("testSubType");
// When
final byte[] bytes = SERIALISER.serialise(typeSubTypeValue);
final String serialisedForm = new String(bytes);
// Then
assertEquals("\0testSubType\0testValue", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(bytes);
// Then
assertNull(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 testCanSerialiseDeserialiseCorrectlyAndBeEscaped.
@Test
public void testCanSerialiseDeserialiseCorrectlyAndBeEscaped() throws SerialisationException {
// Given
final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue("testType", "testSubType", "testValue");
// When
final byte[] bytes = ByteArrayEscapeUtils.escape(SERIALISER.serialise(typeSubTypeValue));
final String serialisedForm = new String(bytes);
// Then
assertEquals("testType\1\1testSubType\1\1testValue", serialisedForm);
// When
final TypeSubTypeValue deSerialisedTypeSubTypeValue = SERIALISER.deserialise(ByteArrayEscapeUtils.unEscape(bytes));
// Then
assertEquals(typeSubTypeValue.getType(), deSerialisedTypeSubTypeValue.getType());
assertEquals(typeSubTypeValue.getSubType(), deSerialisedTypeSubTypeValue.getSubType());
assertEquals(typeSubTypeValue.getValue(), deSerialisedTypeSubTypeValue.getValue());
assertEquals(typeSubTypeValue, deSerialisedTypeSubTypeValue);
}
Aggregations