@Test public void shouldReturnNullWhenIdentifierTypeNotFoundInElement() { // Given final Element element = mock(Element.class); final IdentifierType type = IdentifierType.VERTEX; final ExtractId extractor = new ExtractId(type); // When final Object result = extractor.apply(element); // Then assertNull(result); }
@Override protected ExtractId getInstance() { return new ExtractId(IdentifierType.SOURCE); }
@Override public void shouldJsonSerialiseAndDeserialise() throws SerialisationException { // Given final ExtractId function = getInstance(); // When final byte[] json = JSONSerialiser.serialise(function); final ExtractId deserialisedObj = JSONSerialiser.deserialise(json, ExtractId.class); // Then JsonAssert.assertEquals( "{\"class\":\"uk.gov.gchq.gaffer.data.element.function.ExtractId\",\"id\":\"SOURCE\"}", new String(json) ); assertEquals(IdentifierType.SOURCE, deserialisedObj.getId()); } }
@Test public void shouldReturnValueOfIdentifierType() { // Given final Element element = mock(Element.class); final IdentifierType type = IdentifierType.SOURCE; final String value = "testSource"; final ExtractId extractor = new ExtractId(type); given(element.getIdentifier(type)).willReturn(value); // When final Object result = extractor.apply(element); // Then assertEquals(value, result); }