FacetData facetData = this.facetNameToFacetData.get( s ); if( facetData != null ) data.object.associateFacet( facetData.object ); else this.errors.addAll( data.error( ErrorCode.CO_INEXISTING_FACET, facet( s )));
@Test public void testAssociateFacet() { Component component = new Component( "comp" ); Facet facet = new Facet( "facet" ); Assert.assertEquals( 0, component.getFacets().size()); Assert.assertEquals( 0, facet.getAssociatedComponents().size()); component.associateFacet( facet ); Assert.assertEquals( 1, component.getFacets().size()); Assert.assertEquals( 1, facet.getAssociatedComponents().size()); Assert.assertEquals( facet, component.getFacets().iterator().next()); Assert.assertEquals( component, facet.getAssociatedComponents().iterator().next()); } }
tomcatComponent.associateFacet( facet );
Assert.assertFalse( iterator.hasNext()); component.associateFacet( new Facet( "my-facet" )); Assert.assertEquals( 0, RuntimeModelValidator.validate( component ).size());
@Test public void testFindPrefixesForExportedVariables_withComponentVariables() { Component component = new Component( "comp" ); component.addExportedVariable( new ExportedVariable( "comp.ip", "" )); component.addExportedVariable( new ExportedVariable( "comp.split.property", "" )); component.addExportedVariable( new ExportedVariable( "comp.port", "8000" )); Instance instance = new Instance( "inst" ).component( component ); Set<String> prefixes = VariableHelpers.findPrefixesForExportedVariables( instance ); Assert.assertEquals( 1, prefixes.size()); Assert.assertTrue( prefixes.contains( "comp" )); Facet facet = new Facet( "facet" ); facet.addExportedVariable( new ExportedVariable( "something", "value" )); component.associateFacet( facet ); prefixes = VariableHelpers.findPrefixesForExportedVariables( instance ); Assert.assertEquals( 2, prefixes.size()); Assert.assertTrue( prefixes.contains( "comp" )); Assert.assertTrue( prefixes.contains( "facet" )); }
Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size()); comp.associateFacet( new Facet( "" )); Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size()); comp.associateFacet( new Facet( "!nvalid-facet-n@me" )); Assert.assertEquals( 0, RuntimeModelValidator.validate( comp ).size());
component.associateFacet( f1 ); component.associateFacet( f2 ); component.associateFacet( f3 ); component.addExportedVariable( new ExportedVariable( "f3.param3", "component overrides facet" ));
facet.addExportedVariable( new ExportedVariable( "facet.data", "hello" )); Component component = new Component( "Component" ); component.associateFacet( facet );
@Test public void testFromGraphs_threeFacets() throws Exception { Graphs graphs = new Graphs(); Component cA = new Component( "A" ).installerName( Constants.TARGET_INSTALLER ); graphs.getRootComponents().add( cA ); Facet facet = new Facet( "my-facet-1" ); facet.addExportedVariable( new ExportedVariable( "data", "coucou" )); cA.associateFacet( facet ); cA.addExportedVariable( new ExportedVariable( "A.port", "9000" )); cA.addExportedVariable( new ExportedVariable( "A.ip", null )); cA.addImportedVariable( new ImportedVariable( "B.port", true, false )); cA.addImportedVariable( new ImportedVariable( "B.ip", true, false )); cA.addImportedVariable( new ImportedVariable( "facetF.props", false, false )); Component cB = new Component( "B" ).installerName( Constants.TARGET_INSTALLER ); graphs.getRootComponents().add( cB ); facet = new Facet( "facetF" ); facet.addExportedVariable( new ExportedVariable( "facetF.props", "some value" )); cB.associateFacet( facet ); facet = new Facet( "my-facet-2" ); facet.addExportedVariable( new ExportedVariable( "my-facet-2.woo", "woo" )); cB.associateFacet( facet ); cB.addExportedVariable( new ExportedVariable( "B.port", "9000" )); cB.addExportedVariable( new ExportedVariable( "B.ip", null )); compareGraphs( graphs, false ); }
serverFacet.addExportedVariable( new ExportedVariable( "url-suffix", "some/path" )); serverWithApp.associateFacet( anotherServerFacet ); serverWithApp.addExportedVariable( new ExportedVariable( "ip", null )); serverWithApp.addExportedVariable( new ExportedVariable( serverWithApp.getName() + ".port", "8080" ));
cA.associateFacet( facet ); cB.associateFacet( facet ); cB.associateFacet( facet ); cC.associateFacet( f );
root1.associateFacet( facetVm ); graph.getRootComponents().add( root1 ); root2.associateFacet( facetVm ); graph.getRootComponents().add( root2 ); glassfish.associateFacet( facetWeb ); glassfish.associateFacet( facetJee ); tomcat.associateFacet( facetWeb ); mySql.addExportedVariable( new ExportedVariable( "ip", null )); mySql.addExportedVariable( new ExportedVariable( "port", "3306" )); mySql.associateFacet( facetDb );
@Test public void testFromGraphs_oneFacet() throws Exception { Graphs graphs = new Graphs(); Component cA = new Component( "A" ).installerName( Constants.TARGET_INSTALLER ); graphs.getRootComponents().add( cA ); cA.addImportedVariable( new ImportedVariable( "facetF.props", false, false )); cA.addExportedVariable( new ExportedVariable( "A.port", "9000" )); cA.addExportedVariable( new ExportedVariable( "A.ip", null )); cA.addImportedVariable( new ImportedVariable( "B.port", true, false )); cA.addImportedVariable( new ImportedVariable( "B.ip", true, false )); Component cB = new Component( "B" ).installerName( Constants.TARGET_INSTALLER ); graphs.getRootComponents().add( cB ); Facet facetF = new Facet( "facetF" ); facetF.addExportedVariable( new ExportedVariable( "facetF.props", "something" )); cB.associateFacet( facetF ); cB.addExportedVariable( new ExportedVariable( "B.port", "9000" )); cB.addExportedVariable( new ExportedVariable( "B.ip", null )); compareGraphs( graphs, false ); }