Source:
<code>public void testPopulateOneSidedRelationshipWithIdentifier() throws DotDataException, DotSecurityException { final MapToContentletPopulator populator = new MapToContentletPopulator(); ContentType parentContentType = null; ContentType childContentType = null; try { parentContentType = createAndSaveSimpleContentType("parentContentType"); childContentType = createAndSaveSimpleContentType("childContentType"); Contentlet contentlet = createContentlet(parentContentType); Field field = createAndSaveRelationshipField("newRel", parentContentType.id(), childContentType.variable()); final Map<String, Object> properties = new HashMap<>(); properties.put(Contentlet.STRUCTURE_INODE_KEY, parentContentType.id()); properties.put(field.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(parentContentType.inode(), result.getKey().getParentStructureInode()); 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 testPopulateOneSidedRelationshipWithIdentifier() throws DotDataException, DotSecurityException { final MapToContentletPopulator populator = new MapToContentletPopulator(); ContentType parentContentType = null; ContentType childContentType = null; try { parentContentType = createAndSaveSimpleContentType("parentContentType"); childContentType = createAndSaveSimpleContentType("childContentType"); Contentlet contentlet = createContentlet(parentContentType); Field field = createAndSaveRelationshipField("newRel", parentContentType.id(), childContentType.variable()); final Map<String, Object> properties = new HashMap<>(); properties.put(Contentlet.STRUCTURE_INODE_KEY, parentContentType.id()); properties.put(field.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(parentContentType.inode(), result.getKey().getParentStructureInode()); 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); } } }