ExtractId extends KorypheFunction<Element, Object> { @Override public Object apply(final Element element) { return null != element ? element.getIdentifier(id) : null; } ExtractId();  ExtractId(final IdentifierType id); @Override Object apply(final Element element); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); IdentifierType getId(); void setId(final IdentifierType id);  }
@Test public void shouldReturnNullForNullElement() { final ExtractId extractor = new ExtractId(); final Object result = extractor.apply(null); assertNull(result); }
@Test public void shouldReturnNullWithNoIdentifierTypeProvided() { final Element element = mock(Element.class); final ExtractId extractor = new ExtractId(); final Object result = extractor.apply(element); assertNull(result); }
@Test public void shouldReturnNullWhenIdentifierTypeNotFoundInElement() { final Element element = mock(Element.class); final IdentifierType type = IdentifierType.VERTEX; final ExtractId extractor = new ExtractId(type); final Object result = extractor.apply(element); assertNull(result); }
@Test public void shouldReturnValueOfIdentifierType() { 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); final Object result = extractor.apply(element); assertEquals(value, result); }