mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionRequestImpl.java
@Test
    public void testGetMissionsNoActiveController()
    {
        //Mock class and create real data needed for the primary and secondary images.
        MissionProgramTemplate template = mock(MissionProgramTemplate.class);
        Set<MissionProgramTemplate> templates = new HashSet<MissionProgramTemplate>();
        templates.add(template);
        DigitalMedia image = mock(DigitalMedia.class);
        MissionVariableMetaData variableData = mock(MissionVariableMetaData.class);
        Set<String> testNames = new HashSet<String>();
        testNames.add("Name 1");
        List<DigitalMedia> imageList = new ArrayList<DigitalMedia>();
        imageList.add(image);
        List<MissionVariableMetaData> variableList = new ArrayList<MissionVariableMetaData>();
        variableList.add(variableData);
        byte[] someByteArr = {10, 12, 15, 25, 35};
    
        //Mocked methods.
        when(m_Tpm.getTemplates()).thenReturn(templates);
        when(template.getName()).thenReturn("Name 1");
        when(template.getDescription()).thenReturn("Some description about the mission.");
        when(template.getPrimaryImage()).thenReturn(image);
        when(template.getSecondaryImages()).thenReturn(imageList);
        when(template.getVariableMetaData()).thenReturn(variableList);
        when(image.getEncoding()).thenReturn("image/some encoding");
        when(image.getValue()).thenReturn(someByteArr);
        when(variableData.getName()).thenReturn("Awesome Variable!");
        when(variableData.getDefaultValue()).thenReturn("Default");
        when(variableData.getType()).thenReturn(MissionVariableTypesEnum.STRING);
        
        //active controller behavior
        when(m_ActiveController.isActiveControllerSet()).thenReturn(false);
        
        //Verify that the mission is retrieved and all data is correct.
        List<MissionModel> models = m_SUT.getMissions();
        assertThat(models.get(0).getName(), equalTo("Name 1"));
        assertThat(models.get(0).getDescription(), equalTo("Some description about the mission."));
        assertThat(models.get(0).getArguments().get(0).getName(), equalTo("Awesome Variable!"));
        assertThat((String)models.get(0).getArguments().get(0).getCurrentValue(), equalTo("Default"));
        assertThat(models.get(0).getLocation(), is(MissionTemplateLocation.LOCAL));
    }
/**
     * Test get mission when there is not an active controller set.
     * 
     * Verify template is denoted as local.
     */
Test get mission when there is not an active controller set.

Verify template is denoted as local.
Test get mission when there is not an active controller set . Verify template is denoted as local .
@Test
    public void testGetMissionsNoActiveController()
    {
        MissionProgramTemplate template = mock(MissionProgramTemplate.class);
        Set<MissionProgramTemplate> templates = new HashSet<MissionProgramTemplate>();
        templates.add(template);
        DigitalMedia image = mock(DigitalMedia.class);
        MissionVariableMetaData variableData = mock(MissionVariableMetaData.class);
        Set<String> testNames = new HashSet<String>();
        testNames.add("Name 1");
        List<DigitalMedia> imageList = new ArrayList<DigitalMedia>();
        imageList.add(image);
        List<MissionVariableMetaData> variableList = new ArrayList<MissionVariableMetaData>();
        variableList.add(variableData);
        byte[] someByteArr = {10, 12, 15, 25, 35};
        when(m_Tpm.getTemplates()).thenReturn(templates);
        when(template.getName()).thenReturn("Name 1");
        when(template.getDescription()).thenReturn("Some description about the mission.");
        when(template.getPrimaryImage()).thenReturn(image);
        when(template.getSecondaryImages()).thenReturn(imageList);
        when(template.getVariableMetaData()).thenReturn(variableList);
        when(image.getEncoding()).thenReturn("image/some encoding");
        when(image.getValue()).thenReturn(someByteArr);
        when(variableData.getName()).thenReturn("Awesome Variable!");
        when(variableData.getDefaultValue()).thenReturn("Default");
        when(variableData.getType()).thenReturn(MissionVariableTypesEnum.STRING);
        when(m_ActiveController.isActiveControllerSet()).thenReturn(false);
        List<MissionModel> models = m_SUT.getMissions();
        assertThat(models.get(0).getName(), equalTo("Name 1"));
        assertThat(models.get(0).getDescription(), equalTo("Some description about the mission."));
        assertThat(models.get(0).getArguments().get(0).getName(), equalTo("Awesome Variable!"));
        assertThat((String)models.get(0).getArguments().get(0).getCurrentValue(), equalTo("Default"));
        assertThat(models.get(0).getLocation(), is(MissionTemplateLocation.LOCAL));
    }
@ Test public void testGetMissionsNoActiveController ( ) { MissionProgramTemplate template = mock ( MissionProgramTemplate . class ) ; Set < MissionProgramTemplate > templates = new HashSet < MissionProgramTemplate > ( ) ; templates . add ( template ) ; DigitalMedia image = mock ( DigitalMedia . class ) ; MissionVariableMetaData variableData = mock ( MissionVariableMetaData . class ) ; Set < String > testNames = new HashSet < String > ( ) ; testNames . add ( "Name 1" ) ; List < DigitalMedia > imageList = new ArrayList < DigitalMedia > ( ) ; imageList . add ( image ) ; List < MissionVariableMetaData > variableList = new ArrayList < MissionVariableMetaData > ( ) ; variableList . add ( variableData ) ; byte [ ] someByteArr = { 10 , 12 , 15 , 25 , 35 } ; when ( m_Tpm . getTemplates ( ) ) . thenReturn ( templates ) ; when ( template . getName ( ) ) . thenReturn ( "Name 1" ) ; when ( template . getDescription ( ) ) . thenReturn ( "Some description about the mission." ) ; when ( template . getPrimaryImage ( ) ) . thenReturn ( image ) ; when ( template . getSecondaryImages ( ) ) . thenReturn ( imageList ) ; when ( template . getVariableMetaData ( ) ) . thenReturn ( variableList ) ; when ( image . getEncoding ( ) ) . thenReturn ( "image/some encoding" ) ; when ( image . getValue ( ) ) . thenReturn ( someByteArr ) ; when ( variableData . getName ( ) ) . thenReturn ( "Awesome Variable!" ) ; when ( variableData . getDefaultValue ( ) ) . thenReturn ( "Default" ) ; when ( variableData . getType ( ) ) . thenReturn ( MissionVariableTypesEnum . STRING ) ; when ( m_ActiveController . isActiveControllerSet ( ) ) . thenReturn ( false ) ; List < MissionModel > models = m_SUT . getMissions ( ) ; assertThat ( models . get ( 0 ) . getName ( ) , equalTo ( "Name 1" ) ) ; assertThat ( models . get ( 0 ) . getDescription ( ) , equalTo ( "Some description about the mission." ) ) ; assertThat ( models . get ( 0 ) . getArguments ( ) . get ( 0 ) . getName ( ) , equalTo ( "Awesome Variable!" ) ) ; assertThat ( ( String ) models . get ( 0 ) . getArguments ( ) . get ( 0 ) . getCurrentValue ( ) , equalTo ( "Default" ) ) ; assertThat ( models . get ( 0 ) . getLocation ( ) , is ( MissionTemplateLocation . LOCAL ) ) ; }
Test get mission when there is not an active controller set.
Test get mission when there is not an active controller set .
//Mock class and create real data needed for the primary and secondary images. //Mocked methods. //active controller behavior //Verify that the mission is retrieved and all data is correct.