@Test
public void testFindTargetAssociations_withTarget_defaultAssociation() throws Exception {

	// Setup
	List<Instance> scopedInstances = InstanceHelpers.findAllScopedInstances( this.app );
	Assert.assertEquals( 2, scopedInstances.size());
	List<Component> scopedComponents = new ArrayList<> ();
	for( Instance inst : scopedInstances ) {
		if( ! scopedComponents.contains( inst.getComponent()))
			scopedComponents.add( inst.getComponent());
	}
	// Create a default target for the application
	String targetId = this.manager.targetsMngr().createTarget( "id: tid\nhandler: h" );
	this.manager.targetsMngr().associateTargetWith( targetId, this.app, null );
	List<TargetAssociation> associations = this.resource.findTargetAssociations( this.app.getName());
	Assert.assertEquals( scopedInstances.size() + scopedComponents.size() + 1, associations.size());
	for( int i=0; i<scopedInstances.size(); i++ ) {
		TargetAssociation ta = associations.get( i + 1 );
		String path = InstanceHelpers.computeInstancePath( scopedInstances.get( i ));
		Assert.assertEquals( scopedInstances.get( i ).getComponent().getName(), ta.getInstanceComponent());
		Assert.assertEquals( path, ta.getInstancePathOrComponentName());
		Assert.assertNull( ta.getTargetDescriptor());
	}
	for( int i=0; i<scopedComponents.size(); i++ ) {
		TargetAssociation ta = associations.get( i + 1 + scopedInstances.size());
		Assert.assertEquals( "@" + scopedComponents.get( i ).getName(), ta.getInstancePathOrComponentName());
		Assert.assertNull( ta.getTargetDescriptor());
	}
	TargetAssociation ta = associations.get( 0 );
	Assert.assertEquals( "", ta.getInstancePathOrComponentName());
	Assert.assertEquals( targetId, ta.getTargetDescriptor().getId());
}