### Question:
LivePostDecomposer { public List<LivePost> decompose(LivePost livepost) throws DataMiningException { List<LivePost> liveposts = new ArrayList<LivePost>(); if (!livepost.hasTextualContent()) { throw new DataMiningException("Livepost "+livepost.asResource()+" cannot be decomposed, no textual content is provided."); } else { String text = livepost.getAllTextualContent().next(); Calendar timestamp = livepost.hasTimestamp() ? livepost.getTimestamp() : Calendar.getInstance(); LivePost superPost = dlpoFactory.createLivePost(livepost.asURI()); superPost.getModel().addAll(livepost.getModel().iterator()); try { LivePost subPost = null; for (String link : LinkExtractor.extract(text, true)) { URL url = null; try { url = new URL(link); } catch (MalformedURLException e) { logger.error(link+" is not a valid URL in livepost "+livepost.asResource(), e); continue; } superPost.addRelatedResource(new URIImpl(link)); ResourceModel linkMetadata = urlExtractor.extract(url); String type = linkMetadata.getString(OG.type); if (type == null) { continue; } else if ("audio".equals(type)) { subPost = dlpoFactory.createAudioPost(); } else if ("image".equals(type)) { subPost = dlpoFactory.createImagePost(); } else if ("video".equals(type)) { subPost = dlpoFactory.createVideoPost(); } superPost.addIsComposedOf(subPost.asResource()); subPost.setTimestamp(timestamp); subPost.setTextualContent(text); subPost.setDefiningResource(new URIImpl(link)); subPost.setDefiningResource(new URIImpl(link)); subPost.getModel().addAll(linkMetadata.getModel().iterator()); subPost.getModel().addAll(opengraphExtractor.extract(url).getModel().iterator()); liveposts.add(subPost); } } catch (ExtractionException e) { logger.error("Error occurred while decomposing livepost "+livepost.asResource(), e); } Status status = dlpoFactory.createStatus(); status.setTimestamp(timestamp); status.setTextualContent(text); superPost.addIsComposedOf(status); liveposts.add(status); liveposts.add(superPost); } return liveposts; } LivePostDecomposer(); List<LivePost> decompose(LivePost livepost);  }### Answer:
@Test public void testDecomposeVideoAndImage() throws Exception { LivePost livepost = buildLivePost("Love this song!! http: List<LivePost> liveposts = decomposer.decompose(livepost); assertEquals(4, liveposts.size()); assertTrue(liveposts.contains(livepost)); LivePost parent = null; ImagePost imagePost = null; VideoPost videoPost = null; for (LivePost lv : liveposts) { if (lv instanceof VideoPost) { videoPost = (VideoPost) lv; } else if (lv instanceof ImagePost) { imagePost = (ImagePost) lv; } else { parent = lv; } } assertEquals(2, parent.getAllRelatedResource_as().count()); assertEquals("http: assertEquals("http: }