@Test public void testPuppetValidation_missingParameterFromImports() throws Exception { File appDir = this.folder.newFolder(); Component comp = new Component( "toto" ).installerName( "puppet" ); comp.addImportedVariable( new ImportedVariable( "Test.ip", true, false )); comp.addImportedVariable( new ImportedVariable( "Test.port", true, false )); comp.addImportedVariable( new ImportedVariable( "Oops.ip", true, false )); File directory = ResourceUtils.findInstanceResourcesDirectory( appDir, comp ); Assert.assertTrue( new File( directory, "roboconf_toto/manifests" ).mkdirs()); File targetFile = new File( directory, "roboconf_toto/manifests/start.pp" ); File inputFile = TestUtils.findTestFile( "/recipes/update.pp" ); Utils.copyStream( inputFile, targetFile ); List<ModelError> errors = RecipesValidator.validateComponentRecipes( appDir, comp ); Assert.assertEquals( 2, errors.size()); Assert.assertEquals( ErrorCode.REC_PUPPET_MISSING_PARAM_FROM_IMPORT, errors.get( 0 ).getErrorCode()); Assert.assertEquals( 3, errors.get( 0 ).getDetails().length ); Assert.assertEquals( ErrorDetailsKind.NAME, errors.get( 0 ).getDetails()[ 0 ].getErrorDetailsKind()); Assert.assertEquals( "toto", errors.get( 0 ).getDetails()[ 0 ].getElementName()); Assert.assertEquals( ErrorDetailsKind.FILE, errors.get( 0 ).getDetails()[ 1 ].getErrorDetailsKind()); Assert.assertEquals( ErrorDetailsKind.EXPECTED, errors.get( 0 ).getDetails()[ 2 ].getErrorDetailsKind()); Assert.assertEquals( "test", errors.get( 0 ).getDetails()[ 2 ].getElementName()); Assert.assertEquals( ErrorCode.REC_PUPPET_MISSING_PARAM_FROM_IMPORT, errors.get( 1 ).getErrorCode()); Assert.assertEquals( 3, errors.get( 1 ).getDetails().length ); Assert.assertEquals( ErrorDetailsKind.NAME, errors.get( 1 ).getDetails()[ 0 ].getErrorDetailsKind()); Assert.assertEquals( "toto", errors.get( 1 ).getDetails()[ 0 ].getElementName()); Assert.assertEquals( ErrorDetailsKind.FILE, errors.get( 1 ).getDetails()[ 1 ].getErrorDetailsKind()); Assert.assertEquals( ErrorDetailsKind.EXPECTED, errors.get( 1 ).getDetails()[ 2 ].getErrorDetailsKind()); Assert.assertEquals( "oops", errors.get( 1 ).getDetails()[ 2 ].getElementName()); }
public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) { List<ModelError> result; if( "puppet".equalsIgnoreCase( component.getInstallerName())) result = validatePuppetComponent( applicationFilesDirectory, component ); else if( "script".equalsIgnoreCase( component.getInstallerName())) result = validateScriptComponent( applicationFilesDirectory, component ); else result = Collections.emptyList(); return result; }
RecipesValidator { public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) { List<ModelError> result; if( "puppet".equalsIgnoreCase( component.getInstallerName())) result = validatePuppetComponent( applicationFilesDirectory, component ); else if( "script".equalsIgnoreCase( component.getInstallerName())) result = validateScriptComponent( applicationFilesDirectory, component ); else result = Collections.emptyList(); return result; } }
RecipesValidator { public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) { List<ModelError> result; if( "puppet".equalsIgnoreCase( component.getInstallerName())) result = validatePuppetComponent( applicationFilesDirectory, component ); else if( "script".equalsIgnoreCase( component.getInstallerName())) result = validateScriptComponent( applicationFilesDirectory, component ); else result = Collections.emptyList(); return result; } private  RecipesValidator(); }
RecipesValidator { public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) { List<ModelError> result; if( "puppet".equalsIgnoreCase( component.getInstallerName())) result = validatePuppetComponent( applicationFilesDirectory, component ); else if( "script".equalsIgnoreCase( component.getInstallerName())) result = validateScriptComponent( applicationFilesDirectory, component ); else result = Collections.emptyList(); return result; } private  RecipesValidator(); static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ); }
RecipesValidator { public static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ) { List<ModelError> result; if( "puppet".equalsIgnoreCase( component.getInstallerName())) result = validatePuppetComponent( applicationFilesDirectory, component ); else if( "script".equalsIgnoreCase( component.getInstallerName())) result = validateScriptComponent( applicationFilesDirectory, component ); else result = Collections.emptyList(); return result; } private  RecipesValidator(); static List<ModelError> validateComponentRecipes( File applicationFilesDirectory, Component component ); static final String SCRIPTS_DIR_NAME; }