@Test public void testProperty() { FileDefinition file = new FileDefinition( new File( "some-file" )); BlockProperty block = new BlockProperty( file ); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_INSTALLER, "" ); Collection<ParsingError> errors = ParsingModelValidator.validate((AbstractBlock) block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_INSTALLER, "installerName" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_INSTALLER, "installer-name" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_INSTALLER, "installer.name" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_INSTALLER, "installer#name" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_INSTALLER_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet1, facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet1 , facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet1 , facet2, facet3453_, facet-, facet." ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "-facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, ".facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet#" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet with spaces" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet with tabs" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_CHILD_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet-with-minus-symbols" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 0, errors.size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_CHILDREN, "facet_with_underscores" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 0, errors.size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "_facet1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet1, facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet1 , facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet1 , facet2, facet3453_, facet-, facet." ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "-facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, ".facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "54_facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet#" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet with spaces" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet with special ch@r@cters" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_FACETS, "facet1, , facet2" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_REFERENCED_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "_facet1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet1, facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet1 , facet2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet1 , facet2, facet3453_, facet-, facet." ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "-facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, ".facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "54_facet" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet#" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet with spaces" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet with tabs and speci@l" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXTENDS, "facet1,,facet2" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_REFERENCED_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "_var1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1,var2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1 , var2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1=value1, var2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1 = value1 , var2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1, var2 = value2" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1, var2 = value2 , var3" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1, var2 = \"value2\" , var3" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "random[port] var1 , var2 = \"value2\" , var3" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "-var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, ".var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "2var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var#" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1, var2;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var1; var2;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var2, , var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_VARIABLE_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var2, var1 = \"value1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORT_COMPLEX_VALUE, errors.iterator().next().getErrorCode()); Assert.assertEquals( "var1", errors.iterator().next().getDetails()[ 0 ].getElementName()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var2, var1 =value1\"" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORT_COMPLEX_VALUE, errors.iterator().next().getErrorCode()); Assert.assertEquals( "var1", errors.iterator().next().getDetails()[ 0 ].getElementName()); block.setNameAndValue( ParsingConstants.PROPERTY_GRAPH_EXPORTS, "var#, var2;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 2, errors.size()); for( ParsingError parsingError : errors ) Assert.assertEquals( ErrorCode.PM_INVALID_EXPORTED_VAR_NAME, parsingError.getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "c.var1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "_c.var1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "_c._var1" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "c.var1, c2.var" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "c.var1 , c2.var" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INCOMPLETE_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "var." ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INCOMPLETE_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "c.var, var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INCOMPLETE_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "var, var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 2, errors.size()); for( ParsingError parsingError : errors ) Assert.assertEquals( ErrorCode.PM_INCOMPLETE_IMPORTED_VAR_NAME, parsingError.getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "var#" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "-var" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, ".var" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "c.var, var;" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_IMPORTED_VAR_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, "-var, var!" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 2, errors.size()); for( ParsingError parsingError : errors ) Assert.assertEquals( ErrorCode.PM_INVALID_IMPORTED_VAR_NAME, parsingError.getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_COMPONENT_IMPORTS, ", comp.var1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_VARIABLE_NAME, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "a" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_INSTANCE_COUNT, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "woo" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_INSTANCE_COUNT, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "-5" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_INSTANCE_COUNT, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "2.3" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_INVALID_INSTANCE_COUNT, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "1" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_USELESS_INSTANCE_COUNT, errors.iterator().next().getErrorCode()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_COUNT, "3" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( ParsingConstants.PROPERTY_INSTANCE_CHANNELS, "whatever, there is no validation yet" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block.setNameAndValue( "An Invalid Property", "" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_EMPTY_PROPERTY_VALUE, errors.iterator().next().getErrorCode()); block.setNameAndValue( "An Invalid Property", "some value" ); errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_UNKNOWN_PROPERTY_NAME, errors.iterator().next().getErrorCode()); }
public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); static Collection<ParsingError> validate( FileDefinition definitionFile ); static Collection<ParsingError> validate( AbstractBlock block ); static Collection<ParsingError> validate( BlockImport block ); static Collection<ParsingError> validate( BlockComponent block ); static Collection<ParsingError> validate( BlockInstanceOf block ); static Collection<ParsingError> validate( BlockFacet block ); static Collection<ParsingError> validate( BlockProperty block ); static Collection<ParsingError> validate( BlockComment block ); static Collection<ParsingError> validate( BlockBlank block ); }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); static Collection<ParsingError> validate( FileDefinition definitionFile ); static Collection<ParsingError> validate( AbstractBlock block ); static Collection<ParsingError> validate( BlockImport block ); static Collection<ParsingError> validate( BlockComponent block ); static Collection<ParsingError> validate( BlockInstanceOf block ); static Collection<ParsingError> validate( BlockFacet block ); static Collection<ParsingError> validate( BlockProperty block ); static Collection<ParsingError> validate( BlockComment block ); static Collection<ParsingError> validate( BlockBlank block );  }