/******************************************************************************************************************* * * @param entity * @param path the path * @return the entity, if present * ******************************************************************************************************************/ @Nonnull private static Optional<PathAwareEntity> childMatchingPath (final @Nonnull PathAwareEntity entity, final @Nonnull Path path) { return ((PathAwareFinder)asSimpleComposite(entity).findChildren()).withPath(path).optionalResult(); }
/******************************************************************************************************************* * * Constrains the search to the entity with the given path. * * @param path the path * @return the {@code Finder} * ******************************************************************************************************************/ @Nonnull public default PathAwareFinder withPath (@Nonnull String path) { return withPath(Paths.get(path)); } }
@Test public void must_return_correct_root_children() throws Exception { // when final List<? extends Entity> children = underTest.findRoot().findChildren().results(); // then assertThat(children.size(), is(4)); assertThat(children.get(0).as(Displayable).getDisplayName(), is("Music")); assertThat(children.get(1).as(Displayable).getDisplayName(), is("Photos")); assertThat(children.get(2).as(Displayable).getDisplayName(), is("Videos")); assertThat(children.get(3).as(Displayable).getDisplayName(), is("Services")); // TODO: mock music and services, assert contents } }
final Entity entity = contentDirectory.findRoot() .findChildren() .withPath(path) .optionalResult() .orElseThrow(() -> new ContentDirectoryException(NO_SUCH_OBJECT,