@Test public void testParserErrors_4() throws Exception { ExportedVariablesParser parser = new ExportedVariablesParser(); parser.parse( "ip, port = 8080, path1 = \"value1, value2, path2 = \"value3, value 4\"", this.folder.newFile(), 1 ); Assert.assertEquals( 1, parser.errors.size()); Assert.assertEquals( 4, parser.rawNameToVariables.size()); Assert.assertEquals( ErrorCode.PM_INVALID_EXPORT_COMPLEX_VALUE, parser.errors.get( 0 ).getErrorCode()); Assert.assertEquals( 3, parser.errors.get( 0 ).getDetails().length ); Assert.assertEquals( ErrorDetailsKind.VARIABLE, parser.errors.get( 0 ).getDetails()[ 0 ].getErrorDetailsKind()); Assert.assertEquals( "path1", parser.errors.get( 0 ).getDetails()[ 0 ].getElementName()); Assert.assertEquals( ErrorDetailsKind.FILE, parser.errors.get( 0 ).getDetails()[ 1 ].getErrorDetailsKind()); Assert.assertEquals( ErrorDetailsKind.LINE, parser.errors.get( 0 ).getDetails()[ 2 ].getErrorDetailsKind()); Assert.assertTrue( parser.rawNameToVariables.containsKey( "ip" )); Assert.assertNull( parser.rawNameToVariables.get( "ip" )); Assert.assertEquals( "8080", parser.rawNameToVariables.get( "port" )); Assert.assertTrue( parser.rawNameToVariables.containsKey( "value3" )); Assert.assertNull( parser.rawNameToVariables.get( "value3" )); Assert.assertTrue( parser.rawNameToVariables.containsKey( "value 4\"" )); Assert.assertNull( parser.rawNameToVariables.get( "value 4\"" )); }
public void parse( String line, File sourceFile, int lineNumber ) { this.rawNameToVariables.clear(); this.errors.clear(); this.cursor = 0; while( this.cursor < line.length()) { char c = line.charAt( this.cursor ); if( Character.isWhitespace( c ) || c == ',' ) this.cursor ++; recognizeVariable( line, sourceFile, lineNumber ); } }
ExportedVariablesParser { public void parse( String line, File sourceFile, int lineNumber ) { this.rawNameToVariables.clear(); this.errors.clear(); this.cursor = 0; while( this.cursor < line.length()) { char c = line.charAt( this.cursor ); if( Character.isWhitespace( c ) || c == ',' ) this.cursor ++; recognizeVariable( line, sourceFile, lineNumber ); } } }
ExportedVariablesParser { public void parse( String line, File sourceFile, int lineNumber ) { this.rawNameToVariables.clear(); this.errors.clear(); this.cursor = 0; while( this.cursor < line.length()) { char c = line.charAt( this.cursor ); if( Character.isWhitespace( c ) || c == ',' ) this.cursor ++; recognizeVariable( line, sourceFile, lineNumber ); } }  }
ExportedVariablesParser { public void parse( String line, File sourceFile, int lineNumber ) { this.rawNameToVariables.clear(); this.errors.clear(); this.cursor = 0; while( this.cursor < line.length()) { char c = line.charAt( this.cursor ); if( Character.isWhitespace( c ) || c == ',' ) this.cursor ++; recognizeVariable( line, sourceFile, lineNumber ); } }  void parse( String line, File sourceFile, int lineNumber ); }
ExportedVariablesParser { public void parse( String line, File sourceFile, int lineNumber ) { this.rawNameToVariables.clear(); this.errors.clear(); this.cursor = 0; while( this.cursor < line.length()) { char c = line.charAt( this.cursor ); if( Character.isWhitespace( c ) || c == ',' ) this.cursor ++; recognizeVariable( line, sourceFile, lineNumber ); } }  void parse( String line, File sourceFile, int lineNumber ); final Map<String,String> rawNameToVariables; final List<ParsingError> errors; }