Search in sources :

Example 1 with TypeSubTypeValue

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);
}
Also used : TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue)

Example 2 with TypeSubTypeValue

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);
}
Also used : TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue) Test(org.junit.jupiter.api.Test)

Example 3 with TypeSubTypeValue

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 }) };
}
Also used : TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair)

Example 4 with TypeSubTypeValue

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);
}
Also used : TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue) Test(org.junit.jupiter.api.Test)

Example 5 with TypeSubTypeValue

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);
}
Also used : TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue) Test(org.junit.jupiter.api.Test)

Aggregations

TypeSubTypeValue (uk.gov.gchq.gaffer.types.TypeSubTypeValue)21 Test (org.junit.jupiter.api.Test)18 FunctionTest (uk.gov.gchq.koryphe.function.FunctionTest)6 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 FunctionComposite (uk.gov.gchq.koryphe.function.FunctionComposite)2 ToString (uk.gov.gchq.koryphe.impl.function.ToString)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Pair (uk.gov.gchq.gaffer.commonutil.pair.Pair)1 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)1 CallMethod (uk.gov.gchq.koryphe.impl.function.CallMethod)1 DivideBy (uk.gov.gchq.koryphe.impl.function.DivideBy)1 FirstItem (uk.gov.gchq.koryphe.impl.function.FirstItem)1 Length (uk.gov.gchq.koryphe.impl.function.Length)1 ToInteger (uk.gov.gchq.koryphe.impl.function.ToInteger)1 ToLong (uk.gov.gchq.koryphe.impl.function.ToLong)1 TupleAdaptedFunctionComposite (uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite)1