mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestTemplateProgramManagerImpl.java
@Test
    public void testGetMissionTemplates() throws IllegalArgumentException, PersistenceFailedException, IOException, 
        UnmarshalException, URISyntaxException
    {    
        //mock the stored templates
        mockTemplateProgramManagerTemplates();
        mockTemplatesFromDir();
        m_SUT.activate(context);
        
        //make a list of uuids, and byte data assigned to each template from the template directory
        ArgumentCaptor<byte[]> dataByte = ArgumentCaptor.forClass(byte[].class);
        ArgumentCaptor<UUID> uuidCaptor = ArgumentCaptor.forClass(UUID.class);
        verify(m_PersistentDataStore, times(2)).persist(eq(TemplateProgramManagerImpl.class), uuidCaptor.capture(), 
                anyString(), dataByte.capture());
        
        //mock behavior of look-up
        PersistentData data = mock(PersistentData.class);
        PersistentData data1 = mock(PersistentData.class);
        when((byte[])data.getEntity()).thenReturn(dataByte.getAllValues().get(0));
        when(m_PersistentDataStore.find(uuidCaptor.getAllValues().get(0))).thenReturn(data);
        when((byte[])data1.getEntity()).thenReturn(dataByte.getAllValues().get(1));
        when(m_PersistentDataStore.find(uuidCaptor.getAllValues().get(1))).thenReturn(data1);
        
        //get all templates known, should be 7, as five templates are mocked, 2 are from the template directory
        assertThat(m_SUT.getTemplates().size(), is(7));
    }
/**
     * Test that a list of all templates is returned.
     */
Test that a list of all templates is returned.
Test that a list of all templates is returned .
@Test
    public void testGetMissionTemplates() throws IllegalArgumentException, PersistenceFailedException, IOException, 
        UnmarshalException, URISyntaxException
    {    
        mockTemplateProgramManagerTemplates();
        mockTemplatesFromDir();
        m_SUT.activate(context);
        ArgumentCaptor<byte[]> dataByte = ArgumentCaptor.forClass(byte[].class);
        ArgumentCaptor<UUID> uuidCaptor = ArgumentCaptor.forClass(UUID.class);
        verify(m_PersistentDataStore, times(2)).persist(eq(TemplateProgramManagerImpl.class), uuidCaptor.capture(), 
                anyString(), dataByte.capture());
        PersistentData data = mock(PersistentData.class);
        PersistentData data1 = mock(PersistentData.class);
        when((byte[])data.getEntity()).thenReturn(dataByte.getAllValues().get(0));
        when(m_PersistentDataStore.find(uuidCaptor.getAllValues().get(0))).thenReturn(data);
        when((byte[])data1.getEntity()).thenReturn(dataByte.getAllValues().get(1));
        when(m_PersistentDataStore.find(uuidCaptor.getAllValues().get(1))).thenReturn(data1);
        assertThat(m_SUT.getTemplates().size(), is(7));
    }
@ Test public void testGetMissionTemplates ( ) throws IllegalArgumentException , PersistenceFailedException , IOException , UnmarshalException , URISyntaxException { mockTemplateProgramManagerTemplates ( ) ; mockTemplatesFromDir ( ) ; m_SUT . activate ( context ) ; ArgumentCaptor < byte [ ] > dataByte = ArgumentCaptor . forClass ( byte [ ] . class ) ; ArgumentCaptor < UUID > uuidCaptor = ArgumentCaptor . forClass ( UUID . class ) ; verify ( m_PersistentDataStore , times ( 2 ) ) . persist ( eq ( TemplateProgramManagerImpl . class ) , uuidCaptor . capture ( ) , anyString ( ) , dataByte . capture ( ) ) ; PersistentData data = mock ( PersistentData . class ) ; PersistentData data1 = mock ( PersistentData . class ) ; when ( ( byte [ ] ) data . getEntity ( ) ) . thenReturn ( dataByte . getAllValues ( ) . get ( 0 ) ) ; when ( m_PersistentDataStore . find ( uuidCaptor . getAllValues ( ) . get ( 0 ) ) ) . thenReturn ( data ) ; when ( ( byte [ ] ) data1 . getEntity ( ) ) . thenReturn ( dataByte . getAllValues ( ) . get ( 1 ) ) ; when ( m_PersistentDataStore . find ( uuidCaptor . getAllValues ( ) . get ( 1 ) ) ) . thenReturn ( data1 ) ; assertThat ( m_SUT . getTemplates ( ) . size ( ) , is ( 7 ) ) ; }
Test that a list of all templates is returned.
Test that a list of all templates is returned .
//mock the stored templates //make a list of uuids, and byte data assigned to each template from the template directory //mock behavior of look-up //get all templates known, should be 7, as five templates are mocked, 2 are from the template directory