@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@Test public void testNullInitialization() { TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(null, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); // "0year" set by default verify(timeAmountView).setSelectedTypeIndex(7); verify(timeAmountView).setQuantity(0); }
@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@Test public void testNullInitialization() { TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(null, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); // "0year" set by default verify(timeAmountView).setSelectedTypeIndex(7); verify(timeAmountView).setQuantity(0); }
@Test public void testViewInitialization() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(timeAmount, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeAmountView).setSelectedTypeIndex(3); verify(timeAmountView).setQuantity(10); }
@Test public void testViewInitialization() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(timeAmount, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeAmountView).setSelectedTypeIndex(3); verify(timeAmountView).setQuantity(10); }
@Test public void testDecreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.decreaseQuantity(); verify(timeAmountView).setQuantity(9); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 9); }
@Test public void testDecreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.decreaseQuantity(); verify(timeAmountView).setQuantity(9); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 9); }
@Test public void testIncreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.increaseQuantity(); verify(timeAmountView).setQuantity(11); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 11); } }
@Test public void testIncreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.increaseQuantity(); verify(timeAmountView).setQuantity(11); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 11); } }