Search in sources :

Example 1 with View

use of com.iluwatar.flux.view.View in project java-design-patterns by iluwatar.

the class ContentStoreTest method testOnAction.

@Test
public void testOnAction() throws Exception {
    final ContentStore contentStore = new ContentStore();
    final View view = mock(View.class);
    contentStore.registerView(view);
    verifyZeroInteractions(view);
    // Content should not react on menu action ...
    contentStore.onAction(new MenuAction(MenuItem.PRODUCTS));
    verifyZeroInteractions(view);
    // ... but it should react on a content action
    contentStore.onAction(new ContentAction(Content.COMPANY));
    verify(view, times(1)).storeChanged(eq(contentStore));
    verifyNoMoreInteractions(view);
    assertEquals(Content.COMPANY, contentStore.getContent());
}
Also used : MenuAction(com.iluwatar.flux.action.MenuAction) ContentAction(com.iluwatar.flux.action.ContentAction) View(com.iluwatar.flux.view.View) Test(org.junit.Test)

Example 2 with View

use of com.iluwatar.flux.view.View in project java-design-patterns by iluwatar.

the class MenuStoreTest method testOnAction.

@Test
public void testOnAction() throws Exception {
    final MenuStore menuStore = new MenuStore();
    final View view = mock(View.class);
    menuStore.registerView(view);
    verifyZeroInteractions(view);
    // Menu should not react on content action ...
    menuStore.onAction(new ContentAction(Content.COMPANY));
    verifyZeroInteractions(view);
    // ... but it should react on a menu action
    menuStore.onAction(new MenuAction(MenuItem.PRODUCTS));
    verify(view, times(1)).storeChanged(eq(menuStore));
    verifyNoMoreInteractions(view);
    assertEquals(MenuItem.PRODUCTS, menuStore.getSelected());
}
Also used : MenuAction(com.iluwatar.flux.action.MenuAction) ContentAction(com.iluwatar.flux.action.ContentAction) View(com.iluwatar.flux.view.View) Test(org.junit.Test)

Aggregations

ContentAction (com.iluwatar.flux.action.ContentAction)2 MenuAction (com.iluwatar.flux.action.MenuAction)2 View (com.iluwatar.flux.view.View)2 Test (org.junit.Test)2