//Now a new test contentlets
Contentlet parentContentlet = createContentlet( testStructure, null, false );
Contentlet childContentlet = createContentlet( testStructure, null, false );
//Create the relationship
Relationship testRelationship = createRelationShip( testStructure, false );
//Create the contentlet relationships
List<Contentlet> contentRelationships = new ArrayList<Contentlet>();
contentRelationships.add( childContentlet );
ContentletRelationships contentletRelationships = createContentletRelationships( testRelationship, parentContentlet, testStructure, contentRelationships );
//Relate contents to our test contentlet
for ( ContentletRelationships.ContentletRelationshipRecords contentletRelationshipRecords : contentletRelationships.getRelationshipsRecords() ) {
//Testing the relate content...
contentletAPI.relateContent( parentContentlet, contentletRelationshipRecords, user, false );
}
//Try to find the related Contentlet
//List<Contentlet> foundContentlets = contentletAPI.getRelatedContent( parentContentlet, testRelationship, user, false );//TODO: This is not the correct method to test the relateContent?? (relateContent and getRelatedContent..., is should, some how it does work for me....)
/*//Validations
assertTrue( foundContentlets != null && !foundContentlets.isEmpty() );*/
//Verify if the content was related
Tree tree = TreeFactory.getTree( parentContentlet.getIdentifier(), childContentlet.getIdentifier(), testRelationship.getRelationTypeValue() );
//Validations
assertNotNull( tree );
assertNotNull( tree.getParent() );
assertNotNull( tree.getChild() );
assertEquals( tree.getParent(), parentContentlet.getIdentifier() );
assertEquals( tree.getChild(), childContentlet.getIdentifier() );
assertEquals( tree.getRelationType(), testRelationship.getRelationTypeValue() );
}