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);
  }
コード例 #2
0
 private String getBandanaValue(
     BandanaContext bandanaContext, ConfigurationOption configurationOption) {
   Object fromBandana =
       bandanaManager.getValue(bandanaContext, configurationOption.getBandanaKey());
   if (fromBandana == null) {
     return "";
   }
   return fromBandana.toString();
 }