Assert.assertFalse( iterator.hasNext()); facet.addExportedVariable( new ExportedVariable( "", "value" )); iterator = RuntimeModelValidator.validate( facet ).iterator(); Assert.assertEquals( ErrorCode.RM_EMPTY_VARIABLE_NAME, iterator.next().getErrorCode()); facet.exportedVariables.clear(); facet.addExportedVariable( new ExportedVariable( "facet.inva!id", "value" )); iterator = RuntimeModelValidator.validate( facet ).iterator(); Assert.assertEquals( ErrorCode.RM_INVALID_VARIABLE_NAME, iterator.next().getErrorCode()); facet.exportedVariables.clear(); facet.addExportedVariable( new ExportedVariable( "toto", "" )); iterator = RuntimeModelValidator.validate( facet ).iterator(); Assert.assertFalse( iterator.hasNext()); facet.exportedVariables.clear(); facet.addExportedVariable( new ExportedVariable( "toto.ip", "" )); iterator = RuntimeModelValidator.validate( facet ).iterator(); Assert.assertFalse( iterator.hasNext());
facet.addExportedVariable( new ExportedVariable( "ip", null )); tomcatComponent.associateFacet( facet );
f.addExportedVariable( new ExportedVariable( "property", "value" )); comp.associateFacet( f );
f1.addExportedVariable( new ExportedVariable( "param1", "value1" )); component.associateFacet( f1 ); f2.addExportedVariable( new ExportedVariable( "param2", "value2" )); component.associateFacet( f2 ); f3.addExportedVariable( new ExportedVariable( "param3", "value3" )); component.associateFacet( f3 ); component.addExportedVariable( new ExportedVariable( "f3.param3", "component overrides facet" )); f4.addExportedVariable( new ExportedVariable( "param4-1", "value4" )); f4.addExportedVariable( new ExportedVariable( "param4-2", "value4" )); f2.extendFacet( f4 ); f2.addExportedVariable( new ExportedVariable( "f4.param4-1", "facet overrides facet" ));
@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" )); }
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 ); }
Facet anotherServerFacet = new Facet( "another server facet" ); anotherServerFacet.extendFacet( serverFacet ); serverFacet.addExportedVariable( new ExportedVariable( "url-suffix", "some/path" ));
@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 ); }
facet.addExportedVariable( new ExportedVariable( "my-facet-1.data", "coucou" )); cA.associateFacet( facet ); facet.addExportedVariable( new ExportedVariable( "facetF.props", "some value" )); cB.associateFacet( facet ); facet.addExportedVariable( new ExportedVariable( "my-facet-2.woo", "woo" )); cB.associateFacet( facet );
graph.getFacetNameToFacet().put( facetVm.getName(), facetVm ); facetVm.addChild( facetDeployable ); facetVm.addExportedVariable( new ExportedVariable( Constants.SPECIFIC_VARIABLE_IP, null )); facetJee.addExportedVariable( new ExportedVariable( "server-suffix", "/path" )); facetJee.extendFacet( facetDeployable ); facetWeb.addExportedVariable( new ExportedVariable( "server-suffix", "/path" )); facetWeb.extendFacet( facetDeployable ); facetDb.addExportedVariable( new ExportedVariable( "port", "3306" )); facetDb.extendFacet( facetDeployable );