@Inject public TimeInstantEditor(View view, TimeAmountEditor timeAmountEditor) { this.timeAmountEditor = timeAmountEditor; this.timeInstant = new TimeInstant(); this.view = view; this.view.init(this); }
@Inject public TimeInstantEditor(View view, TimeAmountEditor timeAmountEditor) { this.timeAmountEditor = timeAmountEditor; this.timeInstant = new TimeInstant(); this.view = view; this.view.init(this); }
@Test public void testNullInitialization() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.NOW.getIndex()); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).clearIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(timeInstantView, never()).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView, never()).setSelectedIntervalTypeIndex(any(Integer.class)); }
@Test public void testNullInitialization() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.NOW.getIndex()); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).clearIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(timeInstantView, never()).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView, never()).setSelectedIntervalTypeIndex(any(Integer.class)); }
@Test public void testViewInitialization() { TimeInstant beginMonth = new TimeInstant(TimeInstant.TimeMode.BEGIN, DateIntervalType.MONTH, Month.JANUARY, new TimeAmount(10, DateIntervalType.DAY)); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(beginMonth, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.BEGIN.getIndex()); verify(timeInstantView).enableIntervalTypeSelector(); verify(timeInstantView).clearIntervalTypeSelector(); verify(timeInstantView, times(TimeInstantEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView).setSelectedIntervalTypeIndex(3); }
@Test public void testViewInitialization() { TimeInstant beginMonth = new TimeInstant(TimeInstant.TimeMode.BEGIN, DateIntervalType.MONTH, Month.JANUARY, new TimeAmount(10, DateIntervalType.DAY)); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(beginMonth, changeCommand); assertEquals(timeInstantView, timeInstantEditor.view); verify(timeInstantView).init(timeInstantEditor); verify(timeInstantView).clearTimeModeSelector(); verify(timeInstantView, times(TimeInstant.TimeMode.values().length)).addTimeModeItem(any(TimeInstant.TimeMode.class)); verify(timeInstantView).setSelectedTimeModeIndex(TimeInstant.TimeMode.BEGIN.getIndex()); verify(timeInstantView).enableIntervalTypeSelector(); verify(timeInstantView).clearIntervalTypeSelector(); verify(timeInstantView, times(TimeInstantEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeInstantView).setSelectedIntervalTypeIndex(3); }