Exemplo n.º 1
0
 private void assertRendition(CMISRendition receivedRendition, CMISRendition expectedRendition) {
   assertEquals(expectedRendition.getStreamId(), receivedRendition.getStreamId());
   assertEquals(expectedRendition.getKind(), receivedRendition.getKind());
   assertEquals(expectedRendition.getMimeType(), receivedRendition.getMimeType());
   assertEquals(expectedRendition.getWidth(), receivedRendition.getWidth());
   assertEquals(expectedRendition.getHeight(), receivedRendition.getHeight());
 }
Exemplo n.º 2
0
  public void testGetRenditionsByMimetype() throws Exception {
    for (CMISRendition rendition : documentRenditions) {
      testGetRenditionsByMimetype(rendition.getMimeType());
    }
    testGetRenditionsByMimetype(icon16Rendition.getMimeType());
    testGetRenditionsByMimetype(icon32Rendition.getMimeType());

    String[] mimetypes = getDifferentMimetypes();
    testGetRenditionsByMimetype(mimetypes);
  }
Exemplo n.º 3
0
 private String[] getDifferentMimetypes() {
   List<CMISRendition> allRenditions = new ArrayList<CMISRendition>(documentRenditions);
   allRenditions.add(icon16Rendition);
   allRenditions.add(icon32Rendition);
   Set<String> mimetypes = new HashSet<String>();
   for (CMISRendition rendition : allRenditions) {
     mimetypes.add(rendition.getMimeType());
   }
   return mimetypes.toArray(new String[0]);
 }
Exemplo n.º 4
0
  private void assertRendiions(
      List<CMISRendition> receivedRenditions, List<CMISRendition> expectedRenditions) {
    assertNotNull(receivedRenditions);
    expectedRenditions = removeReplication(expectedRenditions);
    assertTrue(receivedRenditions.size() == expectedRenditions.size());

    for (CMISRendition rendition : receivedRenditions) {
      assertNotNull(rendition);
      assertNotNull(rendition.getStreamId());
    }

    Collections.sort(receivedRenditions, renditionsComparator);
    Collections.sort(expectedRenditions, renditionsComparator);

    for (int i = 0; i < expectedRenditions.size(); ++i) {
      assertRendition(receivedRenditions.get(i), expectedRenditions.get(i));
    }
  }
Exemplo n.º 5
0
 private boolean isRenditionSatisfyConditions(
     CMISRendition rendition, String kind, String mimetype) {
   if (kind != null) {
     if (!kind.equals(rendition.getKind())) {
       return false;
     }
   }
   if (mimetype != null) {
     if (mimetype.endsWith("/*")) {
       String baseMimetype = getBaseType(mimetype);
       if (!rendition.getMimeType().startsWith(baseMimetype)) {
         return false;
       }
     } else if (!mimetype.equals(rendition.getMimeType())) {
       return false;
     }
   }
   return true;
 }
Exemplo n.º 6
0
 public int compare(CMISRendition rendition1, CMISRendition rendition2) {
   return rendition1.getStreamId().compareTo(rendition2.getStreamId());
 }