TargetValidator { public static List<ModelError> parseDirectory( File directory ) { return parseDirectory( directory, null ); } TargetValidator( String propertiesFileContent );  TargetValidator( File propertiesFile );  TargetValidator( File propertiesFile, Object modelObject ); void validate(); List<ModelError> getErrors(); Properties getProperties(); static List<ModelError> parseDirectory( File directory ); static List<ModelError> parseDirectory( File directory, Component c ); static List<ModelError> parseTargetProperties( File projectDirectory, Component c );  }
@Test public void testParseDirectory_conflictingIds() throws Exception { File dir = this.folder.newFolder(); Utils.writeStringInto( "id: tid\nhandler: in\nname: na", new File( dir, "t1.properties" )); Utils.writeStringInto( "id: tid\nhandler: in\nname: na", new File( dir, "t2.properties" )); List<ModelError> errors = TargetValidator.parseDirectory( dir ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.REC_TARGET_CONFLICTING_ID, errors.get( 0 ).getErrorCode()); }
@Test public void testParseDirectory_noProperties() throws Exception { File dir = this.folder.newFolder(); List<ModelError> errors = TargetValidator.parseDirectory( dir ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.REC_TARGET_NO_PROPERTIES, errors.get( 0 ).getErrorCode()); }
@Test public void testParseDirectory_ok() throws Exception { File dir = this.folder.newFolder(); Utils.writeStringInto( "id: tid1\nhandler: in\nname: na", new File( dir, "t1.properties" )); Utils.writeStringInto( "id: tid2\nhandler: in\nname: na", new File( dir, "t2.properties" )); List<ModelError> errors = TargetValidator.parseDirectory( dir ); Assert.assertEquals( 0, errors.size()); }