コード例 #1
1
  @Test
  public void testFolder() {
    List<String> cmisObjsNames = new ArrayList<String>();
    List<String> cmisObjsIds = new ArrayList<String>();

    try {
      CollectionIterable<CmisObject> cmisObjs =
          (CollectionIterable<CmisObject>)
              getConnector()
                  .folder(
                      null, folderObjectId.getId(), NavigationOptions.CHILDREN, 100, null, null);
      AbstractIterator<CmisObject> ai = cmisObjs.iterator();

      while (ai.hasNext()) {
        CmisObject cmisObj = ai.next();
        cmisObjsNames.add(cmisObj.getName());
        cmisObjsIds.add(cmisObj.getId());
      }

      assertTrue(cmisObjsNames.containsAll(subFoldersNames));
      assertTrue(cmisObjsIds.containsAll(subFoldersIds));
      assertEquals(cmisObjsNames.size(), subFoldersNames.size());

    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
コード例 #2
0
 @Test
 public void testDeleteTree() {
   List<String> objectsFailedToDelete;
   try {
     objectsFailedToDelete =
         getConnector()
             .deleteTree(
                 null,
                 folderObjectId.getId(),
                 UnfileObject.DELETE,
                 (Boolean) testData.get("allVersions"),
                 (Boolean) testData.get("continueOnFailure"));
     assertNotNull(objectsFailedToDelete);
     assertEquals(0, objectsFailedToDelete.size());
   } catch (Exception e) {
     fail(e.getMessage());
   }
   try {
     getConnector().getObjectById(documentObjectId.getId());
     fail("Object should not have been found");
   } catch (Exception e) {
     if (!(e instanceof CmisObjectNotFoundException)) {
       fail(e.getMessage());
     }
   }
 }
  public AbstractMacroBaseUnitTestCase() {
    // log4j:
    PropertyConfigurator.configure(
        AbstractMacroBaseUnitTestCase.class.getClassLoader().getResource("log4j.properties"));

    // CMIS Repository
    Map<String, ConfluenceCMISRepository> repoConfigs =
        new WeakHashMap<String, ConfluenceCMISRepository>();
    ConfluenceCMISRepository repoConfig =
        new ConfluenceCMISRepository(
            TEST_SERVER_NAME, TEST_REALM, TEST_USERNAME, TEST_PASSWORD, null);

    repoConfigs.put(TEST_SERVER_NAME, repoConfig);

    bandanaManager = mock(BandanaManager.class);
    when(bandanaManager.getValue((BandanaContext) anyObject(), anyString()))
        .thenReturn(repoConfigs);

    // CMIS
    ObjectId documentObjectId = mock(ObjectId.class);
    when(documentObjectId.getId()).thenReturn(TEST_DOCUMENT_ID);

    Document documentObject = getTestDocument();

    List<CmisObject> documentList = new ArrayList<CmisObject>();
    documentList.add(documentObject);

    ObjectId folderObjectId = mock(ObjectId.class);
    when(folderObjectId.getId()).thenReturn(TEST_FOLDER_ID);

    ItemIterable<CmisObject> children = mock(ItemIterable.class);
    when(children.getTotalNumItems()).thenReturn(1l);
    when(children.getHasMoreItems()).thenReturn(true).thenReturn(false);
    when(children.iterator()).thenReturn(documentList.iterator());

    Folder folderObject =
        createMockedCmisObject(
            new String[][] {
              {PropertyIds.NAME, "Name", "A folder"},
              {PropertyIds.BASE_TYPE_ID, "Base Type Id", "cmis:folder"},
              {PropertyIds.OBJECT_TYPE_ID, "Object Type Id", "cmis:folder"},
              {PropertyIds.OBJECT_ID, "Object Type Id", TEST_FOLDER_ID}
            },
            Folder.class);
    when(folderObject.getId()).thenReturn(TEST_FOLDER_ID);
    when(folderObject.getChildren()).thenReturn(children);

    Session session = mock(Session.class);

    when(session.createObjectId(TEST_DOCUMENT_ID)).thenReturn(documentObjectId);
    when(session.createObjectId(TEST_FOLDER_ID)).thenReturn(folderObjectId);
    when(session.getObject(documentObjectId)).thenReturn(documentObject);
    when(session.getObject(folderObjectId)).thenReturn(folderObject);

    confluenceCMISRepository = mock(ConfluenceCMISRepository.class);
    when(confluenceCMISRepository.getSession()).thenReturn(session);
  }
コード例 #4
0
  @Before
  public void setUp() throws Exception {
    testData = TestDataBuilder.getTestData("folderTestData");
    subFoldersNames = (List<String>) testData.get("subfolders");
    folderObjectId = getFolderObjectId();

    for (String subFolder : subFoldersNames) {
      ObjectId subFolderId = getConnector().createFolder(subFolder, folderObjectId.getId());
      subFoldersIds.add(subFolderId.getId());
    }
  }
コード例 #5
0
  /** Performs the update. */
  private boolean doUpdate() {
    try {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

      Map<String, Object> properties = new HashMap<String, Object>();
      for (PropertyInputPanel propertyPanel : propertyPanels) {
        if (propertyPanel.includeInUpdate()) {
          properties.put(propertyPanel.getId(), propertyPanel.getValue());
        }
      }

      if (properties.isEmpty()) {
        return false;
      }

      ObjectId newId = object.updateProperties(properties, false);

      if ((newId != null) && newId.getId().equals(model.getCurrentObject().getId())) {
        try {
          model.reloadObject();
          model.reloadFolder();
        } catch (Exception ex) {
          ClientHelper.showError(null, ex);
        }
      }

      return true;
    } catch (Exception ex) {
      ClientHelper.showError(this, ex);
      return false;
    } finally {
      setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
  }
コード例 #6
0
  private void updateFolder(Session session, Folder testFolder) {
    CmisTestResult f;

    Folder folder = createFolder(session, testFolder, FOLDER_NAME1);

    f = createResult(FAILURE, "Folder name doesn't match the given name!");
    addResult(assertEquals(FOLDER_NAME1, folder.getName(), null, f));

    // update
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.NAME, FOLDER_NAME2);

    ObjectId newId = folder.updateProperties(properties, false);

    f =
        createResult(
            WARNING, "Folder id changed after name update! The folder id should never change!");
    addResult(assertEquals(folder.getId(), newId.getId(), null, f));

    // get the new folder object and check the new name
    folder.refresh();

    f = createResult(FAILURE, "Folder name doesn't match updated value!");
    addResult(assertEquals(FOLDER_NAME2, folder.getName(), null, f));

    // update again with the same name
    folder.rename(FOLDER_NAME2, true);

    f = createResult(FAILURE, "Folder name doesn't match updated value!");
    addResult(assertEquals(FOLDER_NAME2, folder.getName(), null, f));

    deleteObject(folder);
  }
コード例 #7
0
 @Before
 public void setUp() throws Exception {
   testData = TestDataBuilder.getTestData("getObjectByPathTestData");
   folderObjectId = getFolderObjectId();
   documentObjectId = getDocumentObjectId(folderObjectId.getId());
   path = "/" + testData.get("folderName") + "/" + testData.get("filename");
 }
コード例 #8
0
  @Override
  public void singleClickAction(MouseEvent e, int rowIndex, int colIndex) {
    if (getColumnClass(colIndex) != ObjectId.class) {
      return;
    }

    ObjectId id = (ObjectId) getValueAt(rowIndex, colIndex);
    if ((id == null) || (id.getId() == null)) {
      return;
    }

    try {
      getClientModel().loadObject(id.getId());
      setTab(0);
    } catch (Exception ex) {
      ClientHelper.showError(this, ex);
    }
  }
コード例 #9
0
 @Test
 public void testGetObjectByPath() {
   try {
     CmisObject cmisObj = getConnector().getObjectByPath(path);
     assertNotNull(cmisObj);
     assertEquals(testData.get("filename"), cmisObj.getName());
     assertEquals(documentObjectId.getId(), cmisObj.getId());
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }
コード例 #10
0
 @Before
 public void setUp() throws Exception {
   testData = TestDataBuilder.getTestData("deleteTreeTestData");
   folderObjectId = getFolderObjectId();
   documentObjectId = getDocumentObjectId(folderObjectId.getId());
 }
コード例 #11
0
 @After
 public void tearDown() throws Exception {
   getConnector().deleteTree(null, folderObjectId.getId(), UnfileObject.DELETE, true, true);
 }