@Override public void apply (final @Nonnull ResourceFile folder, final @Nonnull ResourcePath relativePath) { documentMapByRelativePath.put(relativePath.asString(), modelFactory.createContent().withFolder(folder).build()); } });
@Override @Nonnull public Finder<Content> findChildren() { return new ResourceFinder<>( getResource().getFile(), folder -> modelFactory.createContent().withFolder(folder).build()); }
/* visible for testing */ void onOpenSite (final @ListensTo @Nonnull OpenSiteEvent event) { log.debug("onOpenSite({})", event); final ResourceFile root = event.getFileSystem().findFileByPath(ROOT_DOCUMENT_PATH); final Content rootContent = modelFactory.createContent().withFolder(root).build(); presentation.populate(rootContent.as(Presentable).createPresentationModel()); presentation.expandFirstLevel(); messageBus.publish(emptySelectionEvent()); } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() { ContextManager.Locator.set(null); context = new ClassPathXmlApplicationContext("DefaultContentExplorerPresentationControlTestBeans.xml"); underTest = context.getBean(DefaultContentExplorerPresentationControl.class); presentation = context.getBean(ContentExplorerPresentation.class); messageBus = context.getBean(MessageBus.class); modelFactory = context.getBean(ModelFactory.class); openSiteEvent = mock(OpenSiteEvent.class); fileSystem = mock(ResourceFileSystem.class); root = mock(ResourceFile.class); content = mockWithAsSupport(Content.class, (RoleFactory<Content>)(c -> new SimpleCompositePresentable(c))); when(fileSystem.findFileByPath(eq(ROOT_DOCUMENT_PATH))).thenReturn(root); when(openSiteEvent.getFileSystem()).thenReturn(fileSystem); // FIXME: this is cumbersome // when(modelFactory.createContent(eq(root))).thenReturn(content); FIXME!!! final Content.Builder.CallBack callBack = mock(Content.Builder.CallBack.class); when(callBack.build(any(Content.Builder.class))).thenReturn(content); when(modelFactory.createContent()).thenReturn(new Content.Builder(modelFactory, callBack)); }