Search in sources :

Example 1 with ContentStore

use of com.iluwatar.flux.store.ContentStore in project java-design-patterns by iluwatar.

the class App method main.

/**
   * Program entry point
   * 
   * @param args command line args
   */
public static void main(String[] args) {
    // initialize and wire the system
    MenuStore menuStore = new MenuStore();
    Dispatcher.getInstance().registerStore(menuStore);
    ContentStore contentStore = new ContentStore();
    Dispatcher.getInstance().registerStore(contentStore);
    MenuView menuView = new MenuView();
    menuStore.registerView(menuView);
    ContentView contentView = new ContentView();
    contentStore.registerView(contentView);
    // render initial view
    menuView.render();
    contentView.render();
    // user clicks another menu item
    // this triggers action dispatching and eventually causes views to render with new content
    menuView.itemClicked(MenuItem.COMPANY);
}
Also used : ContentView(com.iluwatar.flux.view.ContentView) MenuStore(com.iluwatar.flux.store.MenuStore) MenuView(com.iluwatar.flux.view.MenuView) ContentStore(com.iluwatar.flux.store.ContentStore)

Example 2 with ContentStore

use of com.iluwatar.flux.store.ContentStore in project java-design-patterns by iluwatar.

the class ContentView method storeChanged.

@Override
public void storeChanged(Store store) {
    ContentStore contentStore = (ContentStore) store;
    content = contentStore.getContent();
    render();
}
Also used : ContentStore(com.iluwatar.flux.store.ContentStore)

Example 3 with ContentStore

use of com.iluwatar.flux.store.ContentStore in project java-design-patterns by iluwatar.

the class ContentViewTest method testStoreChanged.

@Test
public void testStoreChanged() throws Exception {
    final ContentStore store = mock(ContentStore.class);
    when(store.getContent()).thenReturn(Content.PRODUCTS);
    final ContentView view = new ContentView();
    view.storeChanged(store);
    verify(store, times(1)).getContent();
    verifyNoMoreInteractions(store);
}
Also used : ContentStore(com.iluwatar.flux.store.ContentStore) Test(org.junit.Test)

Aggregations

ContentStore (com.iluwatar.flux.store.ContentStore)3 MenuStore (com.iluwatar.flux.store.MenuStore)1 ContentView (com.iluwatar.flux.view.ContentView)1 MenuView (com.iluwatar.flux.view.MenuView)1 Test (org.junit.Test)1