Source:
public void importFile_success_when_lineContainsOneSidedSelfRelationship() throws DotSecurityException, DotDataException, IOException { ContentType parentContentType = null; com.dotcms.contenttype.model.field.Field field; final int cardinality = RELATIONSHIP_CARDINALITY.MANY_TO_MANY.ordinal(); try { parentContentType = createTestContentType("parentContentType", "parentContentType"); field = FieldBuilder.builder(RelationshipField.class).name("testRelationship") .variable("testRelationship") .contentTypeId(parentContentType.id()).values(String.valueOf(cardinality)) .relationType(parentContentType.variable()).build(); field = fieldAPI.save(field, user); final Relationship relationship = relationshipAPI.byTypeValue( parentContentType.variable() + StringPool.PERIOD + field.variable()); final ContentletDataGen contentletDataGen = new ContentletDataGen( parentContentType.id()); contentletDataGen.languageId(defaultLanguage.getId()); final Contentlet childContentlet = contentletDataGen .setProperty(TITLE_FIELD_NAME, "child contentlet") .setProperty(BODY_FIELD_NAME, "child contentlet").nextPersisted(); final Reader reader = createTempFile( TITLE_FIELD_NAME + ", " + BODY_FIELD_NAME + ", " + field.variable() + "\r\n" + "Import related content test, Import related content test, " + childContentlet.getIdentifier()); final HashMap<String, List<String>> results = importContentWithRelationships( parentContentType, reader, new String[]{parentContentType.fieldMap().get(TITLE_FIELD_NAME).inode(), parentContentType.fieldMap().get(BODY_FIELD_NAME).inode(), field.inode()}); validateRelationshipResults(relationship, null, childContentlet, results); } finally { if (parentContentType != null) { contentTypeApi.delete(parentContentType); } } }

Target:
public void importFile_success_when_lineContainsOneSidedSelfRelationship() throws DotSecurityException, DotDataException, IOException { ContentType parentContentType = null; com.dotcms.contenttype.model.field.Field field; final int cardinality = RELATIONSHIP_CARDINALITY.MANY_TO_MANY.ordinal(); try { parentContentType = createTestContentType("parentContentType", "parentContentType"); field = FieldBuilder.builder(RelationshipField.class).name("testRelationship") .variable("testRelationship") .contentTypeId(parentContentType.id()).values(String.valueOf(cardinality)) .relationType(parentContentType.variable()).build(); field = fieldAPI.save(field, user); final Relationship relationship = relationshipAPI.byTypeValue( parentContentType.variable() + StringPool.PERIOD + field.variable()); final ContentletDataGen contentletDataGen = new ContentletDataGen( parentContentType.id()); final Contentlet childContentlet = contentletDataGen.languageId(defaultLanguage.getId()) .setProperty(TITLE_FIELD_NAME, "child contentlet") .setProperty(BODY_FIELD_NAME, "child contentlet").nextPersisted(); final Reader reader = createTempFile( TITLE_FIELD_NAME + ", " + BODY_FIELD_NAME + ", " + field.variable() + "\r\n" + "Import related content test, Import related content test, " + childContentlet.getIdentifier()); final HashMap<String, List<String>> results = importContentWithRelationships( parentContentType, reader, new String[]{parentContentType.fieldMap().get(TITLE_FIELD_NAME).inode(), parentContentType.fieldMap().get(BODY_FIELD_NAME).inode(), field.inode()}); validateRelationshipResults(relationship, null, childContentlet, results); } finally { if (parentContentType != null) { contentTypeApi.delete(parentContentType); } } }