mil.dod.th.ose.controller/test/mil/dod/th/ose/controller/impl/TestTerraHarvestControllerImpl.java
@Test
    public void testSetGetOperationMode() throws Exception
    {
        //set to test mode
        m_SUT.setOperationMode(OperationMode.OPERATIONAL_MODE);
        
        ArgumentCaptor<File> fileCaptor = ArgumentCaptor.forClass(File.class);
        verify(m_FileService, atLeastOnce()).createFileOutputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        assertThat(new String(m_OutputData.toByteArray()), containsString("operation.mode=operational"));

        //verify
        assertThat(m_SUT.getOperationMode(), is(OperationMode.OPERATIONAL_MODE));
        
        ArgumentCaptor<Event> changeModeCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(changeModeCaptor.capture());
        
        final Event changeEvent = changeModeCaptor.getValue();
        assertThat(changeEvent.getTopic(), is(TerraHarvestController.TOPIC_CONTROLLER_MODE_CHANGED));
        assertThat(changeEvent.getProperty(TerraHarvestController.EVENT_PROP_SYSTEM_MODE), 
                is((Object)OperationMode.OPERATIONAL_MODE.value()));
    }
/**
     * Test setting and getting operation mode of a controller. 
     */
Test setting and getting operation mode of a controller.
Test setting and getting operation mode of a controller .
@Test
    public void testSetGetOperationMode() throws Exception
    {
        m_SUT.setOperationMode(OperationMode.OPERATIONAL_MODE);
        ArgumentCaptor<File> fileCaptor = ArgumentCaptor.forClass(File.class);
        verify(m_FileService, atLeastOnce()).createFileOutputStream(fileCaptor.capture());
        assertThat(fileCaptor.getValue().getPath(), is(EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME));
        assertThat(new String(m_OutputData.toByteArray()), containsString("operation.mode=operational"));
        assertThat(m_SUT.getOperationMode(), is(OperationMode.OPERATIONAL_MODE));
        ArgumentCaptor<Event> changeModeCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(changeModeCaptor.capture());
        final Event changeEvent = changeModeCaptor.getValue();
        assertThat(changeEvent.getTopic(), is(TerraHarvestController.TOPIC_CONTROLLER_MODE_CHANGED));
        assertThat(changeEvent.getProperty(TerraHarvestController.EVENT_PROP_SYSTEM_MODE), 
                is((Object)OperationMode.OPERATIONAL_MODE.value()));
    }
@ Test public void testSetGetOperationMode ( ) throws Exception { m_SUT . setOperationMode ( OperationMode . OPERATIONAL_MODE ) ; ArgumentCaptor < File > fileCaptor = ArgumentCaptor . forClass ( File . class ) ; verify ( m_FileService , atLeastOnce ( ) ) . createFileOutputStream ( fileCaptor . capture ( ) ) ; assertThat ( fileCaptor . getValue ( ) . getPath ( ) , is ( EXPECTED_TH_SYSTEM_PROPERTIES_FILENAME ) ) ; assertThat ( new String ( m_OutputData . toByteArray ( ) ) , containsString ( "operation.mode=operational" ) ) ; assertThat ( m_SUT . getOperationMode ( ) , is ( OperationMode . OPERATIONAL_MODE ) ) ; ArgumentCaptor < Event > changeModeCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , atLeastOnce ( ) ) . postEvent ( changeModeCaptor . capture ( ) ) ; final Event changeEvent = changeModeCaptor . getValue ( ) ; assertThat ( changeEvent . getTopic ( ) , is ( TerraHarvestController . TOPIC_CONTROLLER_MODE_CHANGED ) ) ; assertThat ( changeEvent . getProperty ( TerraHarvestController . EVENT_PROP_SYSTEM_MODE ) , is ( ( Object ) OperationMode . OPERATIONAL_MODE . value ( ) ) ) ; }
Test setting and getting operation mode of a controller.
Test setting and getting operation mode of a controller .
//set to test mode //verify