Search in sources :

Example 16 with TypeSubTypeValue

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

Example 17 with TypeSubTypeValue

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

Example 18 with TypeSubTypeValue

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

Example 19 with TypeSubTypeValue

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

Example 20 with TypeSubTypeValue

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

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