mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/observation/TestRetrieveDeleteObsHelperImpl.java
@Test
    public void testValidateDates()
    {
        // date objs, start time after end
        Date start = new Date(5L);
        Date stop = new Date(1L);

        // UIComponents
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        UIComponent uiComp = mock(UIComponent.class);
        when(event.getComponent()).thenReturn(uiComp);
        UIInput uiInputStart = mock(UIInput.class);
        when(uiInputStart.getLocalValue()).thenReturn(start);
        when(uiInputStart.getClientId()).thenReturn("start");
        UIInput uiInputStop = mock(UIInput.class);
        when(uiInputStop.getLocalValue()).thenReturn(stop);
        when(uiInputStop.getClientId()).thenReturn("stop");

        // mock finding of start/stop inputs
        when(uiComp.findComponent("startDateRetrieve")).thenReturn(uiInputStart);
        when(uiComp.findComponent("endDateRetrieve")).thenReturn(uiInputStop);

        // mock the faces context
        FacesContext context = mock(FacesContext.class);
        when(m_FacesContextUtil.getFacesContext()).thenReturn(context);

        // validate
        m_SUT.validateDates(event);

        // verify growl messages
        verify(m_FacesContextUtil).getFacesContext();

        // stop message
        verify(context).addMessage(eq("start"), Mockito.any(FacesMessage.class));

        // verify validation failed
        verify(context).validationFailed();

        // verify rendering response
        verify(context).renderResponse();
    }
/**
     * Verify the the validation of date objects for retrieve operations.
     */
Verify the the validation of date objects for retrieve operations.
Verify the the validation of date objects for retrieve operations .
@Test
    public void testValidateDates()
    {
        Date start = new Date(5L);
        Date stop = new Date(1L);
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        UIComponent uiComp = mock(UIComponent.class);
        when(event.getComponent()).thenReturn(uiComp);
        UIInput uiInputStart = mock(UIInput.class);
        when(uiInputStart.getLocalValue()).thenReturn(start);
        when(uiInputStart.getClientId()).thenReturn("start");
        UIInput uiInputStop = mock(UIInput.class);
        when(uiInputStop.getLocalValue()).thenReturn(stop);
        when(uiInputStop.getClientId()).thenReturn("stop");
        when(uiComp.findComponent("startDateRetrieve")).thenReturn(uiInputStart);
        when(uiComp.findComponent("endDateRetrieve")).thenReturn(uiInputStop);
        FacesContext context = mock(FacesContext.class);
        when(m_FacesContextUtil.getFacesContext()).thenReturn(context);
        m_SUT.validateDates(event);
        verify(m_FacesContextUtil).getFacesContext();
        verify(context).addMessage(eq("start"), Mockito.any(FacesMessage.class));
        verify(context).validationFailed();
        verify(context).renderResponse();
    }
@ Test public void testValidateDates ( ) { Date start = new Date ( 5L ) ; Date stop = new Date ( 1L ) ; ComponentSystemEvent event = mock ( ComponentSystemEvent . class ) ; UIComponent uiComp = mock ( UIComponent . class ) ; when ( event . getComponent ( ) ) . thenReturn ( uiComp ) ; UIInput uiInputStart = mock ( UIInput . class ) ; when ( uiInputStart . getLocalValue ( ) ) . thenReturn ( start ) ; when ( uiInputStart . getClientId ( ) ) . thenReturn ( "start" ) ; UIInput uiInputStop = mock ( UIInput . class ) ; when ( uiInputStop . getLocalValue ( ) ) . thenReturn ( stop ) ; when ( uiInputStop . getClientId ( ) ) . thenReturn ( "stop" ) ; when ( uiComp . findComponent ( "startDateRetrieve" ) ) . thenReturn ( uiInputStart ) ; when ( uiComp . findComponent ( "endDateRetrieve" ) ) . thenReturn ( uiInputStop ) ; FacesContext context = mock ( FacesContext . class ) ; when ( m_FacesContextUtil . getFacesContext ( ) ) . thenReturn ( context ) ; m_SUT . validateDates ( event ) ; verify ( m_FacesContextUtil ) . getFacesContext ( ) ; verify ( context ) . addMessage ( eq ( "start" ) , Mockito . any ( FacesMessage . class ) ) ; verify ( context ) . validationFailed ( ) ; verify ( context ) . renderResponse ( ) ; }
Verify the the validation of date objects for retrieve operations.
Verify the the validation of date objects for retrieve operations .
// date objs, start time after end // UIComponents // mock finding of start/stop inputs // mock the faces context // validate // verify growl messages // stop message // verify validation failed // verify rendering response