mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestMetatypeMessageService.java
@Test
    public void testGetAttributeDefinitionInvalidAndNoKey() throws IOException
    {
        Bundle bundleA = mock(Bundle.class);
        when(bundleA.getBundleId()).thenReturn(1L);
        when(m_Context.getBundles()).thenReturn(new Bundle[] { bundleA });
        
        //mock meta type information for the bundles
        MetaTypeInformation infoA = mock(MetaTypeInformation.class);
        when(infoA.getPids()).thenReturn(new String[] {"configA", "configF"});
        when(infoA.getFactoryPids()).thenReturn(new String[] {"FactoryconfigA", "FactoryconfigF"});
        
        //testing not found bundle/pid
        ObjectClassDefinition ocdBad  = mock(ObjectClassDefinition.class);
        when(infoA.getObjectClassDefinition("Swan", null)).thenReturn(ocdBad);
        
        //testing not found bundle/pid
        GetAttributeDefinitionRequestData request = GetAttributeDefinitionRequestData.newBuilder().
            setBundleId(900).
            setPid("Swan").build();
        TerraHarvestPayload payload = createPayload(request, MetaTypeMessageType.GetAttributeDefinitionRequest);
        TerraHarvestMessage message = createTerraHarvestMessage(request, MetaTypeMessageType.
            GetAttributeDefinitionRequest);

        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // handle the message
        m_SUT.handleMessage(message, payload, channel);

        //capture the message, verify error code
        verify(m_EventAdmin).postEvent(Mockito.any(Event.class));
        
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE, 
                "The bundle id 900, and pid Swan did not return any attribute definitions.");
    }
/**
     * Verify that if bundle id/pid does not return attributes and no key value is set that the 
     * GetAttributeDefinitionRequest is properly handled.
     */
Verify that if bundle id/pid does not return attributes and no key value is set that the
GetAttributeDefinitionRequest is properly handled.
Verify that if bundle id / pid does not return attributes and no key value is set that the GetAttributeDefinitionRequest is properly handled .
@Test
    public void testGetAttributeDefinitionInvalidAndNoKey() throws IOException
    {
        Bundle bundleA = mock(Bundle.class);
        when(bundleA.getBundleId()).thenReturn(1L);
        when(m_Context.getBundles()).thenReturn(new Bundle[] { bundleA });
        MetaTypeInformation infoA = mock(MetaTypeInformation.class);
        when(infoA.getPids()).thenReturn(new String[] {"configA", "configF"});
        when(infoA.getFactoryPids()).thenReturn(new String[] {"FactoryconfigA", "FactoryconfigF"});
        ObjectClassDefinition ocdBad  = mock(ObjectClassDefinition.class);
        when(infoA.getObjectClassDefinition("Swan", null)).thenReturn(ocdBad);
        GetAttributeDefinitionRequestData request = GetAttributeDefinitionRequestData.newBuilder().
            setBundleId(900).
            setPid("Swan").build();
        TerraHarvestPayload payload = createPayload(request, MetaTypeMessageType.GetAttributeDefinitionRequest);
        TerraHarvestMessage message = createTerraHarvestMessage(request, MetaTypeMessageType.
            GetAttributeDefinitionRequest);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_EventAdmin).postEvent(Mockito.any(Event.class));
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.INVALID_VALUE, 
                "The bundle id 900, and pid Swan did not return any attribute definitions.");
    }
@ Test public void testGetAttributeDefinitionInvalidAndNoKey ( ) throws IOException { Bundle bundleA = mock ( Bundle . class ) ; when ( bundleA . getBundleId ( ) ) . thenReturn ( 1L ) ; when ( m_Context . getBundles ( ) ) . thenReturn ( new Bundle [ ] { bundleA } ) ; MetaTypeInformation infoA = mock ( MetaTypeInformation . class ) ; when ( infoA . getPids ( ) ) . thenReturn ( new String [ ] { "configA" , "configF" } ) ; when ( infoA . getFactoryPids ( ) ) . thenReturn ( new String [ ] { "FactoryconfigA" , "FactoryconfigF" } ) ; ObjectClassDefinition ocdBad = mock ( ObjectClassDefinition . class ) ; when ( infoA . getObjectClassDefinition ( "Swan" , null ) ) . thenReturn ( ocdBad ) ; GetAttributeDefinitionRequestData request = GetAttributeDefinitionRequestData . newBuilder ( ) . setBundleId ( 900 ) . setPid ( "Swan" ) . build ( ) ; TerraHarvestPayload payload = createPayload ( request , MetaTypeMessageType . GetAttributeDefinitionRequest ) ; TerraHarvestMessage message = createTerraHarvestMessage ( request , MetaTypeMessageType . GetAttributeDefinitionRequest ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_EventAdmin ) . postEvent ( Mockito . any ( Event . class ) ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . INVALID_VALUE , "The bundle id 900, and pid Swan did not return any attribute definitions." ) ; }
Verify that if bundle id/pid does not return attributes and no key value is set that the
 GetAttributeDefinitionRequest is properly handled.
Verify that if bundle id / pid does not return attributes and no key value is set that the GetAttributeDefinitionRequest is properly handled .
//mock meta type information for the bundles //testing not found bundle/pid //testing not found bundle/pid //mock the channel the message came from // handle the message //capture the message, verify error code