@Override public void start() { Context context = new Context(); definitions.forEach(definition -> definition.define(context)); Context coreContext = new Context(); corePageDefinitions.stream() .map(CorePageDefinition::getPageDefinition) .forEach(definition -> definition.define(coreContext)); pages = Stream.concat( context.getPages().stream().peek(this::checkPluginExists), coreContext.getPages().stream().peek(this::checkCoreExtensionExists)) .sorted(comparing(Page::getKey)) .collect(toList()); }
@Test public void empty_pages_by_default() { Collection<Page> result = underTest.getPages(); assertThat(result).isEmpty(); }
@Test public void test_page_definition() { PageDefinition underTest = context -> context.addPage(Page.builder("my_plugin/my_page").setName("My Page").build()); Context context = new Context(); underTest.define(context); assertThat(context.getPages()).extracting(Page::getKey).contains("my_plugin/my_page"); }
@Test public void ordered_by_name() { underTest .addPage(Page.builder("fake/K1").setName("N2").build()) .addPage(Page.builder("fake/K2").setName("N3").build()) .addPage(Page.builder("fake/K3").setName("N1").build()); Collection<Page> result = underTest.getPages(); assertThat(result).extracting(Page::getKey, Page::getName) .containsOnly( tuple("fake/K3", "N1"), tuple("fake/K1", "N2"), tuple("fake/K2", "N3")); }
@Override public void start() { Context context = new Context(); definitions.forEach(definition -> definition.define(context)); Context coreContext = new Context(); corePageDefinitions.stream() .map(CorePageDefinition::getPageDefinition) .forEach(definition -> definition.define(coreContext)); pages = Stream.concat( context.getPages().stream().peek(this::checkPluginExists), coreContext.getPages().stream().peek(this::checkCoreExtensionExists)) .sorted(comparing(Page::getKey)) .collect(toList()); }