@Test public void testGetExportedVariables() { String holderName = "facet-name"; FileDefinition def = new FileDefinition( null ); AbstractBlockHolder holder = new BlockFacet( def ); holder.setName( holderName ); BlockProperty prop = new BlockProperty( def, ParsingConstants.PROPERTY_GRAPH_EXPORTS, "" ); holder.getInnerBlocks().add( prop ); String varName1 = "var1"; prop.setValue( "var1" ); Map<String,ExportedVariable> map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertTrue( map.containsKey( varName1 )); Assert.assertNull( map.get( varName1 ).getValue()); Assert.assertNull( map.get( varName1 ).getRandomKind()); Assert.assertFalse( map.get( varName1 ).isRandom()); prop.setValue( "var1 = 5" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertEquals( "5", map.get( varName1 ).getValue()); prop.setValue( "var1=5" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertEquals( "5", map.get( varName1 ).getValue()); prop.setValue( "var1= 5895" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertEquals( "5895", map.get( varName1 ).getValue()); String varName2 = "var2"; prop.setValue( "var1, var2" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 2, map.size()); Assert.assertTrue( map.containsKey( varName1 )); Assert.assertTrue( map.containsKey( varName2 )); Assert.assertNull( map.get( varName1 ).getValue()); Assert.assertNull( map.get( varName2 ).getValue()); prop.setValue( "var1, var2 = 587" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 2, map.size()); Assert.assertTrue( map.containsKey( varName1 )); Assert.assertNull( map.get( varName1 ).getValue()); Assert.assertEquals( "587", map.get( varName2 ).getValue()); prop.setValue( "var1 = abc, var2 = 587" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 2, map.size()); Assert.assertEquals( "abc", map.get( varName1 ).getValue()); Assert.assertEquals( "587", map.get( varName2 ).getValue()); prop.setValue( "random[port] var1" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertTrue( map.containsKey( varName1 )); Assert.assertNull( map.get( varName1 ).getValue()); Assert.assertEquals( RandomKind.PORT, map.get( varName1 ).getRandomKind()); Assert.assertTrue( map.get( varName1 ).isRandom()); prop.setValue( "raNdom[pOrt] var1" ); map = ModelUtils.getExportedVariables( holder ); Assert.assertEquals( 1, map.size()); Assert.assertTrue( map.containsKey( varName1 )); Assert.assertNull( map.get( varName1 ).getValue()); Assert.assertEquals( RandomKind.PORT, map.get( varName1 ).getRandomKind()); Assert.assertTrue( map.get( varName1 ).isRandom()); }
public static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ) { Map<String,ExportedVariable> result = new HashMap<> (); for( BlockProperty p : holder.findPropertiesBlockByName( ParsingConstants.PROPERTY_GRAPH_EXPORTS )) { result.putAll( findExportedVariables( p.getValue(), p.getFile(), p.getLine())); } return result; }
ModelUtils { public static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ) { Map<String,ExportedVariable> result = new HashMap<> (); for( BlockProperty p : holder.findPropertiesBlockByName( ParsingConstants.PROPERTY_GRAPH_EXPORTS )) { result.putAll( findExportedVariables( p.getValue(), p.getFile(), p.getLine())); } return result; } }
ModelUtils { public static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ) { Map<String,ExportedVariable> result = new HashMap<> (); for( BlockProperty p : holder.findPropertiesBlockByName( ParsingConstants.PROPERTY_GRAPH_EXPORTS )) { result.putAll( findExportedVariables( p.getValue(), p.getFile(), p.getLine())); } return result; } private  ModelUtils(); }
ModelUtils { public static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ) { Map<String,ExportedVariable> result = new HashMap<> (); for( BlockProperty p : holder.findPropertiesBlockByName( ParsingConstants.PROPERTY_GRAPH_EXPORTS )) { result.putAll( findExportedVariables( p.getValue(), p.getFile(), p.getLine())); } return result; } private  ModelUtils(); static String getPropertyValue( AbstractBlockHolder holder, String propertyName ); static List<String> getPropertyValues( AbstractBlockHolder holder, String propertyName ); static Map<String,String> getData( AbstractBlockHolder holder ); static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ); static Map<String,ExportedVariable> findExportedVariables( String exportedVariablesDecl, File sourceFile, int lineNumber ); }
ModelUtils { public static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ) { Map<String,ExportedVariable> result = new HashMap<> (); for( BlockProperty p : holder.findPropertiesBlockByName( ParsingConstants.PROPERTY_GRAPH_EXPORTS )) { result.putAll( findExportedVariables( p.getValue(), p.getFile(), p.getLine())); } return result; } private  ModelUtils(); static String getPropertyValue( AbstractBlockHolder holder, String propertyName ); static List<String> getPropertyValues( AbstractBlockHolder holder, String propertyName ); static Map<String,String> getData( AbstractBlockHolder holder ); static Map<String,ExportedVariable> getExportedVariables( AbstractBlockHolder holder ); static Map<String,ExportedVariable> findExportedVariables( String exportedVariablesDecl, File sourceFile, int lineNumber );  }