@Test public void changedSourceToNonNull() { NodeRef sourceNodeRef = createSource(ADMIN, "quick.jpg"); render(ADMIN, sourceNodeRef, DOC_LIB); NodeRef rendition1 = waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true); ContentData contentData1 = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(rendition1, PROP_CONTENT)); updateContent(ADMIN, sourceNodeRef, "quick.png"); render(ADMIN, sourceNodeRef, DOC_LIB); NodeRef rendition2 = waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true); ContentData contentData2 = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(rendition2, PROP_CONTENT)); assertEquals("The rendition node should not change", rendition1, rendition2); assertNotEquals("The content should have change", contentData1.toString(), contentData2.toString()); }
public void testToAndFromString() throws Exception { Locale locale = I18NUtil.getLocale(); String localeStr = DefaultTypeConverter.INSTANCE.convert(String.class, locale); ContentData property = new ContentData(null, null, 0L, null, null); // check null string String propertyStr = property.toString(); assertEquals("Null values not converted correctly", "contentUrl=|mimetype=|size=0|encoding=|locale=" + localeStr, propertyStr); // convert back ContentData checkProperty = ContentData.createContentProperty(propertyStr); assertEquals("Conversion from string failed", property, checkProperty); property = new ContentData("test://uuu", "mmm", 123L, "eee", I18NUtil.getLocale()); // convert to a string propertyStr = property.toString(); assertEquals("Incorrect property string representation", "contentUrl=test://uuu|mimetype=mmm|size=123|encoding=eee|locale=" + localeStr, propertyStr); // convert back checkProperty = ContentData.createContentProperty(propertyStr); assertEquals("Conversion from string failed", property, checkProperty); }