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());
}
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());
}
Aggregations