ExtractWalkVertex extends KorypheFunction<Walk, Object> { @Override public Object apply(final Walk walk) { if (null == walk) { throw new IllegalArgumentException("Walk cannot be null"); } return walk.getSourceVertex(); }  @Override Object apply(final Walk walk);  }
@Test public void shouldReturnVertexFromWalkObject() { final Function<Walk, Object> function = new ExtractWalkVertex(); final Walk walk = new Walk.Builder() .entity(ENTITY_A) .edge(EDGE_AB) .entity(ENTITY_B) .edge(EDGE_BC) .entity(ENTITY_C) .edge(EDGE_CA) .entity(ENTITY_A) .build(); final Object result = function.apply(walk); assertEquals("A", result); }
@Test public void shouldThrowIAEForNullWalkInput() { final Function<Walk, Object> function = new ExtractWalkVertex(); final Exception exception = assertThrows(IllegalArgumentException.class, () -> function.apply(null)); assertEquals("Walk cannot be null", exception.getMessage()); }