ExtractWalkEntities extends KorypheFunction<Walk, Iterable<Set<Entity>>> { @Override public Iterable<Set<Entity>> apply(final Walk walk) { if (null == walk) { throw new IllegalArgumentException("Walk cannot be null"); } return walk.getEntities(); }  @Override Iterable<Set<Entity>> apply(final Walk walk);  }
@Test public void shouldReturnEntitiesFromWalkObject() { final Function<Walk, Iterable<Set<Entity>>> function = new ExtractWalkEntities(); 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 Iterable<Set<Entity>> results = function.apply(walk); final Matcher<Iterable<? extends Set<Entity>>> matcher = containsInAnyOrder( Sets.newHashSet(ENTITY_A), Sets.newHashSet(ENTITY_B), Sets.newHashSet(ENTITY_C), Sets.newHashSet(ENTITY_A)); assertThat(results, matcher); }