Search in sources :

Example 1 with IsA

use of uk.gov.gchq.gaffer.function.IsA in project Gaffer by gchq.

the class NotTest method shouldJsonSerialiseAndDeserialise.

@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
    // Given
    final IsA isA = new IsA(String.class);
    final Not filter = new Not(isA);
    // When
    final String json = new String(new JSONSerialiser().serialise(filter, true));
    // Then
    JsonUtil.assertEquals(String.format("{%n" + "  \"class\" : \"uk.gov.gchq.gaffer.function.filter.Not\",%n" + "  \"function\" : {%n" + "    \"class\" : \"uk.gov.gchq.gaffer.function.IsA\",%n" + "    \"type\" : \"java.lang.String\"%n" + "  }%n" + "}"), json);
    // When 2
    final Not deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), Not.class);
    // Then 2
    assertNotNull(deserialisedFilter);
    assertEquals(String.class.getName(), ((IsA) deserialisedFilter.getFunction()).getType());
}
Also used : IsA(uk.gov.gchq.gaffer.function.IsA) JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test) FilterFunctionTest(uk.gov.gchq.gaffer.function.FilterFunctionTest)

Example 2 with IsA

use of uk.gov.gchq.gaffer.function.IsA in project Gaffer by gchq.

the class IsAExample method isAString.

public void isAString() {
    // ---------------------------------------------------------
    final IsA function = new IsA(String.class);
    // ---------------------------------------------------------
    runExample(function, 1, 2.5, "abc");
}
Also used : IsA(uk.gov.gchq.gaffer.function.IsA)

Example 3 with IsA

use of uk.gov.gchq.gaffer.function.IsA in project Gaffer by gchq.

the class IsAExample method isANumber.

public void isANumber() {
    // ---------------------------------------------------------
    final IsA function = new IsA(Number.class);
    // ---------------------------------------------------------
    runExample(function, 1, 2.5, "abc");
}
Also used : IsA(uk.gov.gchq.gaffer.function.IsA)

Aggregations

IsA (uk.gov.gchq.gaffer.function.IsA)3 Test (org.junit.Test)1 FilterFunctionTest (uk.gov.gchq.gaffer.function.FilterFunctionTest)1 JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)1