@Test
public void testGraphs() {

	Graphs graphs = new Graphs();
	Iterator<ModelError> iterator = RuntimeModelValidator.validate( graphs ).iterator();
	Assert.assertEquals( ErrorCode.RM_NO_ROOT_COMPONENT, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	Component comp1 = new Component( "comp1" ).installerName( Constants.TARGET_INSTALLER );
	graphs.getRootComponents().add( comp1 );
	Component duplicateComp1 = new Component( "comp1" ).installerName( Constants.TARGET_INSTALLER );
	graphs.getRootComponents().add( duplicateComp1 );
	// The validator checks something that cannot happen for the moment.
	// But we must keep it to prevent regressions.
	iterator = RuntimeModelValidator.validate( graphs ).iterator();
	if( iterator.hasNext()) {
		//Assert.assertEquals( ErrorCode.RM_DUPLICATE_COMPONENT, iterator.next().getErrorCode());
		Assert.assertFalse( iterator.hasNext());
	}
	// Unresolvable variable
	graphs.getRootComponents().clear();
	graphs.getRootComponents().add( comp1 );
	comp1.addImportedVariable( new ImportedVariable( "tomcat.port", false, false ));
	iterator = RuntimeModelValidator.validate( graphs ).iterator();
	Assert.assertEquals( ErrorCode.RM_UNRESOLVABLE_VARIABLE, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp1.addImportedVariable( new ImportedVariable( "tomcat.port", true, false ));
	iterator = RuntimeModelValidator.validate( graphs ).iterator();
	Assert.assertEquals( ErrorCode.RM_UNRESOLVABLE_VARIABLE, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	comp1.importedVariables.clear();
	// Test for loops: comp2 -> comp3 -> comp2
	Component comp2 = new Component( "comp2" ).installerName( "installer-2" );
	Component comp3 = new Component( "comp3" ).installerName( "installer-3" );
	comp1.addChild( comp2 );
	comp2.addChild( comp3 );
	comp3.addChild( comp2 );
	Collection<ModelError> errors = RuntimeModelValidator.validate( graphs );
	Assert.assertEquals( 2, errors.size());
	for( ModelError error: errors )
		Assert.assertEquals( ErrorCode.RM_CYCLE_IN_COMPONENTS, error.getErrorCode());
}