OContentShareResource extends AbstractResource { public static CharSequence urlFor(ODocument document, String field, String contentType, boolean fullUrl) { return urlFor(getSharedResourceReference(), document, field, contentType, null, null, fullUrl); }  static SharedResourceReference getSharedResourceReference(); static CharSequence urlFor(ODocument document, String field, String contentType,  boolean fullUrl); static CharSequence urlFor(ODocument document, String field, String contentType, Integer imageSize, boolean fullUrl); static CharSequence urlFor(ODocument document, String field, String contentType, Integer imageSize, Double imageQuality, boolean fullUrl);  }
@Test public void testRetrieveContent() { tester.executeUrl(OContentShareResource.urlFor(doc, "name", null, false).toString()); MockHttpServletResponse response = tester.getLastResponse(); assertEquals(response.getStatus(), HttpServletResponse.SC_OK); }
@Test public void testRetrieveNotExistsContent() { tester.executeUrl(OContentShareResource.urlFor(doc, "notFound", "text/plain", false).toString()); MockHttpServletResponse response = tester.getLastResponse(); assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_FOUND); }
@Test public void testRetrieveEmptyContent() { tester.executeUrl(OContentShareResource.urlFor(doc, "phone", "text/plain", false).toString()); MockHttpServletResponse response = tester.getLastResponse(); assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_FOUND); }
@Test public void testUrls() { tester.setUseRequestUrlAsBase(true); System.out.println("Local URL: "+OContentShareResource.urlFor(doc, "phone", "text/plain", false)); System.out.println("Full URL: "+OContentShareResource.urlFor(doc, "phone", "text/plain", true)); tester.executeUrl("./api/echo/"+doc.getIdentity().toString().substring(1)+"/phone?full=false"); MockHttpServletResponse response = tester.getLastResponse(); String ret = response.getDocument(); assertEquals(excludeVersion(OContentShareResource.urlFor(doc, "phone", "text/plain", false)), excludeVersion(ret)); tester.executeUrl("./api/echo/"+doc.getIdentity().toString().substring(1)+"/phone?full=true"); response = tester.getLastResponse(); ret = response.getDocument(); assertEquals(excludeVersion(OContentShareResource.urlFor(doc, "phone", "text/plain", true)), excludeVersion(ret)); }