mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAddressedCommandResponse.java
public void testCommandsAreAllPresent() 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 (CommandTypeEnum commandType: CommandTypeEnum.values())
        {
            //capture the class
            final String commandTypeString = 
                    CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, commandType.toString());
            Class<?> clazz = Class.forName("mil.dod.th.core.asset.commands." + commandTypeString);
            Command command = (Command)clazz.newInstance();

            AddressedCommand addrCommand = new AddressedCommand(uuid, sourceId, destId, assetUuid, command);
            //validate
            try
            {
                validator.validate(addrCommand);
            }
            catch (ValidationFailedException e)
            {
                //Expected for certain commands as they have required fields so won't pass validation. If the source
                //for the command cannot be found an IllegalStateException will be thrown, thus causing this test
                //to fail.
            }
            catch (IllegalStateException e)
            {
                fail(String.format(
                        "Command schema was likely not found, ensure that the command %s in included in"
                        + " MasterCommands.xsd %s", command.getClass(), e));
            }
        }
    }
/**
     * Verify all commands sources are available within a {@link AddressedCommand}.
     */
Verify all commands sources are available within a  AddressedCommand.
Verify all commands sources are available within a AddressedCommand .
public void testCommandsAreAllPresent() 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 (CommandTypeEnum commandType: CommandTypeEnum.values())
        {
            final String commandTypeString = 
                    CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, commandType.toString());
            Class<?> clazz = Class.forName("mil.dod.th.core.asset.commands." + commandTypeString);
            Command command = (Command)clazz.newInstance();
            AddressedCommand addrCommand = new AddressedCommand(uuid, sourceId, destId, assetUuid, command);
            try
            {
                validator.validate(addrCommand);
            }
            catch (ValidationFailedException e)
            {
            }
            catch (IllegalStateException e)
            {
                fail(String.format(
                        "Command schema was likely not found, ensure that the command %s in included in"
                        + " MasterCommands.xsd %s", command.getClass(), e));
            }
        }
    }
public void testCommandsAreAllPresent ( ) 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 ( CommandTypeEnum commandType : CommandTypeEnum . values ( ) ) { final String commandTypeString = CaseFormat . UPPER_UNDERSCORE . to ( CaseFormat . UPPER_CAMEL , commandType . toString ( ) ) ; Class < ? > clazz = Class . forName ( "mil.dod.th.core.asset.commands." + commandTypeString ) ; Command command = ( Command ) clazz . newInstance ( ) ; AddressedCommand addrCommand = new AddressedCommand ( uuid , sourceId , destId , assetUuid , command ) ; try { validator . validate ( addrCommand ) ; } catch ( ValidationFailedException e ) { } catch ( IllegalStateException e ) { fail ( String . format ( "Command schema was likely not found, ensure that the command %s in included in" + " MasterCommands.xsd %s" , command . getClass ( ) , e ) ) ; } } }
Verify all commands sources are available within a {@link AddressedCommand}.
Verify all commands sources are available within a { @link AddressedCommand } .
//some dummy values to insert //capture the class //validate //Expected for certain commands as they have required fields so won't pass validation. If the source //for the command cannot be found an IllegalStateException will be thrown, thus causing this test //to fail.