@Test
public void testInvalidChildInstance_1() throws Exception {

	Component vmComponent1 = new Component( "VM_type1" ).installerName( Constants.TARGET_INSTALLER );
	Component vmComponent2 = new Component( "VM_type2" ).installerName( Constants.TARGET_INSTALLER );
	Component tomcatComponent = new Component( "Tomcat" ).installerName( "puppet" );
	vmComponent1.addChild( tomcatComponent );
	vmComponent2.addChild( tomcatComponent );
	Graphs graphs = new Graphs();
	graphs.getRootComponents().add( vmComponent1 );
	graphs.getRootComponents().add( vmComponent2 );
	// We cannot instantiate a VM under a VM
	Instance vmInstance1 = new Instance("vm1" ).component( vmComponent1 );
	Instance vmInstance2 = new Instance("vm2" ).component( vmComponent1 );
	InstanceHelpers.insertChild( vmInstance1, vmInstance2 );
	ApplicationTemplate app = new ApplicationTemplate( "app" ).version( "2.4" ).graphs( graphs );
	app.getRootInstances().add( vmInstance1 );
	Iterator<ModelError> iterator = RuntimeModelValidator.validate( app ).iterator();
	Assert.assertEquals( ErrorCode.RM_INVALID_INSTANCE_PARENT, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	// We cannot have a Tomcat as a root instance
	Instance tomcatInstance = new Instance("tomcat" ).component( tomcatComponent );
	app.getRootInstances().clear();
	app.getRootInstances().add( tomcatInstance );
	iterator = RuntimeModelValidator.validate( app ).iterator();
	Assert.assertEquals( ErrorCode.RM_MISSING_INSTANCE_PARENT, iterator.next().getErrorCode());
	Assert.assertFalse( iterator.hasNext());
	// We can insert a Tomcat under a VM
	vmInstance1.getChildren().clear();
	InstanceHelpers.insertChild( vmInstance1, tomcatInstance );
	app.getRootInstances().clear();
	app.getRootInstances().add( vmInstance1 );
	Assert.assertEquals( 0, RuntimeModelValidator.validate( app ).size());
}