private Graphs buildFinalGraphs() { Graphs result = new Graphs(); for( ComponentData cd : this.componentNameToComponentData.values()) { if( ComponentHelpers.findAllAncestors( cd.object ).isEmpty()) result.getRootComponents().add( cd.object ); } for( FacetData data : this.facetNameToFacetData.values()) result.getFacetNameToFacet().put( data.object.getName(), data.object ); return result; }
keys.add( "components" ); if( this.options.containsKey( DocConstants.OPTION_RECIPE ) ) { if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty() ) keys.add( "facets" );
@Override protected String renderDocumentIndex() { // What keys should we inject in the index? List<String> keys = new ArrayList<> (); keys.add( "introduction" ); keys.add( "components" ); if( this.options.containsKey( DocConstants.OPTION_RECIPE )) { if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty()) keys.add( "facets" ); } else { keys.add( "instances" ); } // Create the index StringBuilder sb = new StringBuilder(); sb.append( "<ul>\n" ); for( String key : keys ) { sb.append( "\t<li><a href=\"index.html#" ); sb.append( this.messages.get( key ).toLowerCase()); sb.append( "\">" ); sb.append( this.messages.get( key )); sb.append( "</a></li>\n" ); } sb.append( "</ul>\n" ); this.menu = sb.toString(); return ""; }
keys.add( "components" ); if( this.options.containsKey( DocConstants.OPTION_RECIPE ) ) { if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty() ) keys.add( "facets" );
@Override protected String renderDocumentIndex() { // What keys should we inject in the index? List<String> keys = new ArrayList<> (); keys.add( "introduction" ); keys.add( "components" ); if( this.options.containsKey( DocConstants.OPTION_RECIPE )) { if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty()) keys.add( "facets" ); } else { keys.add( "instances" ); } // Create the index StringBuilder sb = new StringBuilder(); sb.append( "<ul>\n" ); for( String key : keys ) { sb.append( "\t<li><a href=\"index.html#" ); sb.append( this.messages.get( key ).toLowerCase()); sb.append( "\">" ); sb.append( this.messages.get( key )); sb.append( "</a></li>\n" ); } sb.append( "</ul>\n" ); this.menu = sb.toString(); return ""; }
types.addAll( g.getFacetNameToFacet().values());
for( Facet f : graphs.getFacetNameToFacet().values()) { facetVariables.addAll( f.exportedVariables.keySet()); facetVariables.add( f.getName() + "." + Constants.WILDCARD ); for( Facet f : graphs.getFacetNameToFacet().values()) { if( f.getAssociatedComponents().isEmpty()) { if( f.getChildren().isEmpty())
if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty()) { List<Facet> allFacets = new ArrayList<>( this.applicationTemplate.getGraphs().getFacetNameToFacet().values()); Collections.sort( allFacets, new AbstractTypeComparator());
for( Facet f : graphs.getFacetNameToFacet().values()) { if( alreadySerializedNames.contains( f.getName())) continue;
if( ! this.applicationTemplate.getGraphs().getFacetNameToFacet().isEmpty()) { List<Facet> allFacets = new ArrayList<>( this.applicationTemplate.getGraphs().getFacetNameToFacet().values()); Collections.sort( allFacets, new AbstractTypeComparator());
@Test public void testIncompleteFilesResultInEmptyGraphByDefault() throws Exception { List<File> files = TestUtils.findTestFiles( "/configurations/flexibles" ); Assert.assertNotSame( 0, files.size()); List<String> almostValids = Arrays.asList( new String[] { "one-component-no-property.graph", "two-components-no-property.graph" }); File directory = files.iterator().next().getParentFile(); for( File f : files ) { // There are some exceptions if( almostValids.contains( f.getName())) continue; // Others contain syntactic errors and no component was found FromGraphDefinition fromDef = new FromGraphDefinition( directory ); Graphs graph = fromDef.buildGraphs( f ); Assert.assertNotSame( f.getName(), 0, fromDef.getErrors().size()); Assert.assertEquals( f.getName(), 0, graph.getRootComponents().size()); Assert.assertEquals( f.getName(), 0, graph.getFacetNameToFacet().size()); } } }
Assert.assertEquals( 0, graphs.getFacetNameToFacet().size()); Assert.assertEquals( 2, graphs.getFacetNameToFacet().size()); Facet f1 = graphs.getFacetNameToFacet().get( "f1" ); Assert.assertNotNull( f1 ); Assert.assertEquals( 2, f1.exportedVariables.size()); Assert.assertEquals( 0, f1.getChildren().size()); Facet f2 = graphs.getFacetNameToFacet().get( "f2" ); Assert.assertNotNull( f2 ); Assert.assertEquals( 0, f2.exportedVariables.size());
@Test public void testIDsWithSpaces() throws Exception { File f = TestUtils.findTestFile( "/configurations/valid/real-lamp-all-in-one-flex.graph" ); FromGraphDefinition fromDef = new FromGraphDefinition( f.getParentFile()); Graphs graphs = fromDef.buildGraphs( f ); Assert.assertEquals( 7, fromDef.getErrors().size()); for( ParsingError error : fromDef.getErrors()) { boolean a1 = ErrorCode.PM_INVALID_NAME == error.getErrorCode(); boolean a2 = ErrorCode.PM_INVALID_CHILD_NAME == error.getErrorCode(); Assert.assertTrue( error.getErrorCode().name(), a1 || a2 ); } Assert.assertEquals( 0, graphs.getRootComponents().size()); Assert.assertEquals( 0, graphs.getFacetNameToFacet().size()); }
Assert.assertEquals( 0, graphs.getFacetNameToFacet().size()); Assert.assertEquals( 2, graphs.getFacetNameToFacet().size()); Facet f1 = graphs.getFacetNameToFacet().get( "f1" ); Assert.assertNotNull( f1 ); Assert.assertEquals( 2, f1.exportedVariables.size()); Assert.assertEquals( 0, f1.getChildren().size()); Facet f2 = graphs.getFacetNameToFacet().get( "f2" ); Assert.assertNotNull( f2 ); Assert.assertEquals( 0, f2.exportedVariables.size());
Assert.assertEquals( 2, graphs.getFacetNameToFacet().size()); Assert.assertEquals( 3, fromDef.getTypeAnnotations().size()); Facet f1 = graphs.getFacetNameToFacet().get( "f1" ); Assert.assertNotNull( f1 ); Assert.assertEquals( "This is facet f1.\nAnd the desc spans over two lines.", fromDef.getTypeAnnotations().get( f1.getName())); Facet f2 = graphs.getFacetNameToFacet().get( "f2" ); Assert.assertNotNull( f2 ); Assert.assertEquals( "Simple comment.", fromDef.getTypeAnnotations().get( f2.getName()));
graph.getFacetNameToFacet().put( facetDeployable.getName(), facetDeployable ); graph.getFacetNameToFacet().put( facetVm.getName(), facetVm ); facetVm.addChild( facetDeployable ); facetVm.addExportedVariable( new ExportedVariable( Constants.SPECIFIC_VARIABLE_IP, null )); graph.getFacetNameToFacet().put( facetJee.getName(), facetJee ); facetJee.addExportedVariable( new ExportedVariable( "server-suffix", "/path" )); facetJee.extendFacet( facetDeployable ); graph.getFacetNameToFacet().put( facetWeb.getName(), facetWeb ); facetWeb.addExportedVariable( new ExportedVariable( "server-suffix", "/path" )); facetWeb.extendFacet( facetDeployable ); graph.getFacetNameToFacet().put( facetDb.getName(), facetDb ); facetDb.addExportedVariable( new ExportedVariable( "port", "3306" )); facetDb.extendFacet( facetDeployable ); graph.getFacetNameToFacet().put( facetStorage.getName(), facetStorage ); facetStorage.extendFacet( facetDb );