Source:
<code>public void testPopulateTwoSidedRelationshipWithLuceneQuery() throws DotDataException, DotSecurityException { final MapToContentletPopulator populator = new MapToContentletPopulator(); ContentType parentContentType = null; ContentType childContentType = null; try { parentContentType = createAndSaveSimpleContentType("parentContentType"); childContentType = createAndSaveSimpleContentType("childContentType"); Contentlet contentlet = createContentlet(childContentType); final Field parentTypeRelationshipField = createAndSaveRelationshipField("newRel", parentContentType.id(), childContentType.variable()); final String fullFieldVar = parentContentType.variable() + StringPool.PERIOD + parentTypeRelationshipField.variable(); final Field childTypeRelationshipField = createAndSaveRelationshipField("otherSideRel", childContentType.id(), fullFieldVar); final Map<String, Object> properties = new HashMap<>(); properties.put(Contentlet.STRUCTURE_INODE_KEY, childContentType.id()); properties.put(childTypeRelationshipField.variable(), contentlet.getIdentifier()); contentlet = populator.populate(contentlet, properties); <START> assertTrue(UtilMethods.isSet(contentlet.get(Contentlet.RELATIONSHIP_KEY))); <END> Map<Relationship, List<Contentlet>> resultMap = (Map<Relationship, List<Contentlet>> ) contentlet .get(Contentlet.RELATIONSHIP_KEY); assertEquals(1, resultMap.size()); Entry<Relationship, List<Contentlet>> result = resultMap.entrySet().iterator().next(); assertEquals(childContentType.inode(), result.getKey().getChildStructureInode()); assertEquals(1, result.getValue().size()); assertEquals(contentlet.getInode(), result.getValue().get(0).getInode()); } finally { if (UtilMethods.isSet(parentContentType) && UtilMethods.isSet(parentContentType.id())) { contentTypeAPI.delete(parentContentType); } if (UtilMethods.isSet(childContentType) && UtilMethods.isSet(childContentType.id())) { contentTypeAPI.delete(childContentType); } } }</code><technical_language>assertNotNull</technical_language>

Target:
public void testPopulateTwoSidedRelationshipWithLuceneQuery() throws DotDataException, DotSecurityException { final MapToContentletPopulator populator = new MapToContentletPopulator(); ContentType parentContentType = null; ContentType childContentType = null; try { parentContentType = createAndSaveSimpleContentType("parentContentType"); childContentType = createAndSaveSimpleContentType("childContentType"); Contentlet contentlet = createContentlet(childContentType); final Field parentTypeRelationshipField = createAndSaveRelationshipField("newRel", parentContentType.id(), childContentType.variable()); final String fullFieldVar = parentContentType.variable() + StringPool.PERIOD + parentTypeRelationshipField.variable(); final Field childTypeRelationshipField = createAndSaveRelationshipField("otherSideRel", childContentType.id(), fullFieldVar); final Map<String, Object> properties = new HashMap<>(); properties.put(Contentlet.STRUCTURE_INODE_KEY, childContentType.id()); properties.put(childTypeRelationshipField.variable(), contentlet.getIdentifier()); contentlet = populator.populate(contentlet, properties); assertNotNull(contentlet.get(Contentlet.RELATIONSHIP_KEY)); Map<Relationship, List<Contentlet>> resultMap = (Map<Relationship, List<Contentlet>> ) contentlet .get(Contentlet.RELATIONSHIP_KEY); assertEquals(1, resultMap.size()); Entry<Relationship, List<Contentlet>> result = resultMap.entrySet().iterator().next(); assertEquals(childContentType.inode(), result.getKey().getChildStructureInode()); assertEquals(1, result.getValue().size()); assertEquals(contentlet.getInode(), result.getValue().get(0).getInode()); } finally { if (UtilMethods.isSet(parentContentType) && UtilMethods.isSet(parentContentType.id())) { contentTypeAPI.delete(parentContentType); } if (UtilMethods.isSet(childContentType) && UtilMethods.isSet(childContentType.id())) { contentTypeAPI.delete(childContentType); } } }