mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAddressedCommandResponse.java
public void testResponsesAreAllPresent() throws ValidationFailedException, ClassNotFoundException, 
        InstantiationException, IllegalAccessException
    {
        //some dummy values to insert
        UUID uuid = UUID.randomUUID();
        int sourceId = 1;
        int destId = 2;
        UUID assetUuid = UUID.randomUUID();

        Validator validator = ServiceUtils.getService(m_Context, Validator.class);
        
        for (CommandResponseEnum responseType: CommandResponseEnum.values())
        {
            //capture the class
            final String responseTypeString = 
                    CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, responseType.toString());
            Class<?> clazz = Class.forName("mil.dod.th.core.asset.commands." + responseTypeString);
            Response response = (Response)clazz.newInstance();
            
            AddressedResponse addrResponse = new AddressedResponse(sourceId, destId, assetUuid, response, uuid);
            try
            {
                validator.validate(addrResponse);
            }
            catch (ValidationFailedException e)
            {
                //Expected for certain responses as they have required fields so won't pass validation. If the source
                //for the response cannot be found an IllegalStateException will be thrown, thus causing this test
                //to fail.
            }
            catch (IllegalStateException e)
            {
                fail(String.format("The response %s is not available to the Addressed Response, "
                        + "check the MasterResponses.xsd to ensure that the response schema is included. %s", 
                            clazz, e));
            }
        }
    }
/**
     * Verify that all response type sources are available within a {@link AddressedResponse}.
     */
Verify that all response type sources are available within a  AddressedResponse.
Verify that all response type sources are available within a AddressedResponse .
public void testResponsesAreAllPresent() throws ValidationFailedException, ClassNotFoundException, 
        InstantiationException, IllegalAccessException
    {
        UUID uuid = UUID.randomUUID();
        int sourceId = 1;
        int destId = 2;
        UUID assetUuid = UUID.randomUUID();
        Validator validator = ServiceUtils.getService(m_Context, Validator.class);
        for (CommandResponseEnum responseType: CommandResponseEnum.values())
        {
            final String responseTypeString = 
                    CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, responseType.toString());
            Class<?> clazz = Class.forName("mil.dod.th.core.asset.commands." + responseTypeString);
            Response response = (Response)clazz.newInstance();
            AddressedResponse addrResponse = new AddressedResponse(sourceId, destId, assetUuid, response, uuid);
            try
            {
                validator.validate(addrResponse);
            }
            catch (ValidationFailedException e)
            {
            }
            catch (IllegalStateException e)
            {
                fail(String.format("The response %s is not available to the Addressed Response, "
                        + "check the MasterResponses.xsd to ensure that the response schema is included. %s", 
                            clazz, e));
            }
        }
    }
public void testResponsesAreAllPresent ( ) throws ValidationFailedException , ClassNotFoundException , InstantiationException , IllegalAccessException { UUID uuid = UUID . randomUUID ( ) ; int sourceId = 1 ; int destId = 2 ; UUID assetUuid = UUID . randomUUID ( ) ; Validator validator = ServiceUtils . getService ( m_Context , Validator . class ) ; for ( CommandResponseEnum responseType : CommandResponseEnum . values ( ) ) { final String responseTypeString = CaseFormat . UPPER_UNDERSCORE . to ( CaseFormat . UPPER_CAMEL , responseType . toString ( ) ) ; Class < ? > clazz = Class . forName ( "mil.dod.th.core.asset.commands." + responseTypeString ) ; Response response = ( Response ) clazz . newInstance ( ) ; AddressedResponse addrResponse = new AddressedResponse ( sourceId , destId , assetUuid , response , uuid ) ; try { validator . validate ( addrResponse ) ; } catch ( ValidationFailedException e ) { } catch ( IllegalStateException e ) { fail ( String . format ( "The response %s is not available to the Addressed Response, " + "check the MasterResponses.xsd to ensure that the response schema is included. %s" , clazz , e ) ) ; } } }
Verify that all response type sources are available within a {@link AddressedResponse}.
Verify that all response type sources are available within a { @link AddressedResponse } .
//some dummy values to insert //capture the class //Expected for certain responses as they have required fields so won't pass validation. If the source //for the response cannot be found an IllegalStateException will be thrown, thus causing this test //to fail.