ExtractProperty extends KorypheFunction<Element, Object> { @Override public Object apply(final Element element) { return null != element ? element.getProperty(name) : null; } ExtractProperty();  ExtractProperty(final String name); @Override Object apply(final Element element); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); String getName(); void setName(final String name);  }
@Test public void shouldReturnNullForNullElement() { final ExtractProperty extractor = new ExtractProperty(); final Object result = extractor.apply(null); assertNull(result); }
@Test public void shouldReturnNullWithNoNameProvided() { final Element element = mock(Element.class); final ExtractProperty extractor = new ExtractProperty(); final Object result = extractor.apply(element); assertNull(result); }
@Test public void shouldReturnNullWhenNameNotFoundInElementProperties() { final Element element = mock(Element.class); final String propName = "absentProperty"; final ExtractProperty extractor = new ExtractProperty(propName); final Object result = extractor.apply(element); assertNull(result); }
@Test public void shouldReturnValueOfProperty() { final Element element = mock(Element.class); final String propName = "presentProperty"; final int propValue = 3; final ExtractProperty extractor = new ExtractProperty(propName); given(element.getProperty(propName)).willReturn(propValue); final Object result = extractor.apply(element); assertEquals(propValue, result); }