Package com.google.enterprise.connector.notes.client.mock

Examples of com.google.enterprise.connector.notes.client.mock.NotesDatabaseMock


        // First, create the connector database records, then
        // create the database. For the purposes of
        // NotesUserGroupManager, we only need a database, no
        // documents.
        NotesDatabaseMock configDatabase = (NotesDatabaseMock) session
            .getDatabase(connectorSession.getServer(),
            connectorSession.getDatabase());

        NotesDocumentMock databaseDocument = new NotesDocumentMock();
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_DBNAME,
            "type", NotesItem.TEXT, "values", "JediTrainingManuals.nsf"));
        databaseDocument.addItem(new NotesItemMock("name",
            NCCONST.DITM_REPLICAID, "type", NotesItem.TEXT,
            "values", "jtmreplicaid0123"));
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_SERVER,
            "type", NotesItem.TEXT, "values", "JediServer"));
        configDatabase.addDocument(databaseDocument, NCCONST.VIEWDATABASES);
        databaseDocument = new NotesDocumentMock();
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_DBNAME,
            "type", NotesItem.TEXT, "values", "SenateExpenseReports.nsf"));
        databaseDocument.addItem(new NotesItemMock("name",
            NCCONST.DITM_REPLICAID, "type", NotesItem.TEXT,
            "values", "serreplicaid0123"));
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_SERVER,
            "type", NotesItem.TEXT, "values", "SenateServer"));
        configDatabase.addDocument(databaseDocument, NCCONST.VIEWDATABASES);
        databaseDocument = new NotesDocumentMock();
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_DBNAME,
            "type", NotesItem.TEXT, "values", "EvilSeparatistPlots.nsf"));
        databaseDocument.addItem(new NotesItemMock("name",
            NCCONST.DITM_REPLICAID, "type", NotesItem.TEXT,
            "values", "espreplicaid0123"));
        databaseDocument.addItem(new NotesItemMock("name", NCCONST.DITM_SERVER,
            "type", NotesItem.TEXT, "values", "SenateServer"));
        configDatabase.addDocument(databaseDocument, NCCONST.VIEWDATABASES);

        NotesDatabaseMock notesDatabase = new NotesDatabaseMock(
            "JediServer", "JediTrainingManuals.nsf", "jtmreplicaid0123");
        ((NotesSessionMock) session).addDatabase(notesDatabase);
        NotesACLMock acl = new NotesACLMock();
        acl.addAclEntry(new NotesACLEntryMock(
            "cn=Ahsoka Tano/ou=Tests/o=Tests", NotesACLEntry.TYPE_PERSON,
            NotesACL.LEVEL_READER, "[student]"));
        acl.addAclEntry(new NotesACLEntryMock(
            "cn=Anakin Skywalker/ou=Tests/o=Tests", NotesACLEntry.TYPE_PERSON,
            NotesACL.LEVEL_AUTHOR, "[tacticsexpert]"));
        acl.addAclEntry(new NotesACLEntryMock(
            "cn=Yoda/ou=Tests/o=Tests", NotesACLEntry.TYPE_PERSON,
            NotesACL.LEVEL_AUTHOR, "[philosopher]"));
        acl.addAclEntry(new NotesACLEntryMock("masters",
            NotesACLEntry.TYPE_PERSON_GROUP, NotesACL.LEVEL_AUTHOR,
            "[holderofopinions]", "[duplicategroupname]"));
        acl.addAclEntry(new NotesACLEntryMock("bad guys",
            NotesACLEntry.TYPE_PERSON_GROUP, NotesACL.LEVEL_NOACCESS));
        notesDatabase.setACL(acl);

        notesDatabase = new NotesDatabaseMock(
            "SenateServer", "SenateExpenseReports.nsf", "serreplicaid0123");
        ((NotesSessionMock) session).addDatabase(notesDatabase);
        acl = new NotesACLMock();
        acl.addAclEntry(new NotesACLEntryMock(
            "cn=Chancellor Palpatine/ou=Tests/o=Tests",
            NotesACLEntry.TYPE_PERSON, NotesACL.LEVEL_READER,
            "[removablerole]"));
        acl.addAclEntry(new NotesACLEntryMock("senators",
            NotesACLEntry.TYPE_PERSON_GROUP, NotesACL.LEVEL_AUTHOR,
            "[creator]", "[duplicategroupname]"));
        notesDatabase.setACL(acl);

        notesDatabase = new NotesDatabaseMock(
            "SenateServer", "EvilSeparatistPlots.nsf", "espreplicaid0123");
        ((NotesSessionMock) session).addDatabase(notesDatabase);
        acl = new NotesACLMock();
        acl.addAclEntry(new NotesACLEntryMock(
            "cn=Chancellor Palpatine/ou=Tests/o=Tests",
            NotesACLEntry.TYPE_PERSON, NotesACL.LEVEL_MANAGER,
            "[evilmastermind]"));
        acl.addAclEntry(new NotesACLEntryMock(
            "Count Dooku", // Test a short name in the ACL
            NotesACLEntry.TYPE_PERSON, NotesACL.LEVEL_AUTHOR,
            "[henchman]"));
        acl.addAclEntry(new NotesACLEntryMock(
            "bad guys", NotesACLEntry.TYPE_PERSON_GROUP,
            NotesACL.LEVEL_READER));
        acl.addAclEntry(new NotesACLEntryMock("jedi",
            NotesACLEntry.TYPE_PERSON_GROUP,
            NotesACL.LEVEL_READER, "[reader]"));
        notesDatabase.setACL(acl);

        try {
          userGroupManager.setUpResources(true);
          userGroupManager.clearTables(userGroupManager.getConnection());
        } finally {
View Full Code Here


    setUpRoles();
    assertUserHasRole("palpatine", "serreplicaid0123/[removablerole]");

    // Modify one of the previously-created ACLs (we don't
    // actually have editing support, so just recreate it here).
    NotesDatabaseMock notesDatabase = (NotesDatabaseMock) session.getDatabase(
        "SenateServer", "SenateExpenseReports.nsf");
    NotesACLMock originalAcl = (NotesACLMock) notesDatabase.getACL();
    try {
      NotesACLMock acl = new NotesACLMock();
      // Remove Palpatine from this database's ACL
      acl.addAclEntry(new NotesACLEntryMock("senators",
              NotesACLEntry.TYPE_PERSON_GROUP, NotesACL.LEVEL_AUTHOR,
              "[creator]", "[duplicategroupname]"));
      notesDatabase.setACL(acl);
      setUpRoles();
      assertRoleDoesNotExist("serreplicaid0123/[removablerole]");
      assertUserDoesNotHaveRole("palpatine",
          "serreplicaid0123/[removablerole]");
    } finally {
      notesDatabase.setACL(originalAcl);
    }
  }
View Full Code Here

    SimpleTraversalContext context = new SimpleTraversalContext();
    context.setSupportsInheritedAcls(supportsInheritedAcls);
    ((NotesTraversalManager) connectorSession.getTraversalManager())
        .setTraversalContext(context);
    NotesSession session = connectorSession.createNotesSession();
    NotesDatabaseMock connectorDatabase =
        (NotesDatabaseMock) session.getDatabase(
        connectorSession.getServer(), connectorSession.getDatabase());

    NotesConnectorDocument document = new NotesConnectorDocument(
        connectorSession, session, connectorDatabase);
View Full Code Here

    }
    NotesDocumentMock crawlDoc = getCrawlDatabaseAcl();
    NotesConnectorSession connectorSession =
        (NotesConnectorSession) connector.login();
    NotesSession session = connectorSession.createNotesSession();
    NotesDatabaseMock connectorDatabase =
        (NotesDatabaseMock) session.getDatabase(
        connectorSession.getServer(), connectorSession.getDatabase());

    NotesConnectorDocument document = new NotesConnectorDocument(
        connectorSession, session, connectorDatabase);
View Full Code Here

    }
    NotesDocumentMock crawlDoc = getCrawlDatabaseAcl();
    NotesConnectorSession connectorSession =
        (NotesConnectorSession) connector.login();
    NotesSession session = connectorSession.createNotesSession();
    NotesDatabaseMock connectorDatabase =
        (NotesDatabaseMock) session.getDatabase(
        connectorSession.getServer(), connectorSession.getDatabase());
    NotesConnectorDocument document = new NotesConnectorDocument(
        connectorSession, session, connectorDatabase);
    document.setCrawlDoc("unid", crawlDoc);
View Full Code Here

  }

  public void testCheckForDeletions() throws Exception {
    // Setup deleted document
    String delUNID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX0000";
    NotesDatabaseMock srcDb = setupSourceDatabase("mickey1/mtv/us", "test.nsf",
        TESTCONST.DBSRC_REPLICAID, notesDocMgrDbTest.getDocuments(),
        NCCONST.VIEWINDEXED);
    NotesDocument delDoc = srcDb.getDocumentByUNID(delUNID);
    delDoc.remove(true);
    String docId = "http://" + TESTCONST.SERVER_DOMINO_WEB + TESTCONST.DOMAIN
        + "/" + TESTCONST.DBSRC_REPLICAID + "/0/" + delUNID;

    // Setup template document including formulas
    String searchString =
        "Select Form *= \"Main Topic\":\"MainTopic\":\"Response\"";
    NotesDatabaseMock configDatabase = factory.getDatabase("testconfig.nsf");
    NotesDocumentMock docTmpl = new NotesDocumentMock();
    docTmpl.addItem(new NotesItemMock("name", "Form", "type", NotesItem.TEXT,
        "values", "TEMPLATE"));
    docTmpl.addItem(new NotesItemMock("name", "TemplateName", "type",
        NotesItem.TEXT, "values", "Discussion"));
    docTmpl.addItem(new NotesItemMock("name", "SearchString", "type",
        NotesItem.TEXT, "values", searchString));
    configDatabase.addDocument(docTmpl, NCCONST.VIEWTEMPLATES);
    configDatabase.setViewFields(NCCONST.VIEWTEMPLATES, "TemplateName");

    // Run check for deletion
    Map<String, NotesDocId> docs =
        notesDocMgrDbTest.getIndexedDocument(null, null, 1);
    NotesDocId startUnid = docs.get(docs.keySet().iterator().next());
    maintenanceThread.checkForDeletions(startUnid.toString(), BATCH_SIZE);

    List<NotesDocumentMock> docList =
        configDatabase.getDocumentsByField(NCCONST.ITM_DOCID, docId);
    assertEquals(1, docList.size());
    NotesDocumentMock docDeletedReq = docList.get(0);
    assertEquals(ActionType.DELETE.toString(),
        docDeletedReq.getItemValueString(NCCONST.ITM_ACTION));
  }
View Full Code Here

    setupSourceDatabase("mickey1/mtv/us", "test.nsf",
        TESTCONST.DBSRC_REPLICAID, notesDocMgrDbTest.getDocuments(),
        NCCONST.VIEWINDEXED);

    // Create template document without formulas
    NotesDatabaseMock configDatabase = factory.getDatabase("testconfig.nsf");
    NotesDocumentMock docTmpl = new NotesDocumentMock();
    docTmpl.addItem(new NotesItemMock("name", "Form", "type", NotesItem.TEXT,
        "values", "TEMPLATE"));
    docTmpl.addItem(new NotesItemMock("name", "TemplateName", "type",
        NotesItem.TEXT, "values", "Discussion"));
    configDatabase.addDocument(docTmpl, NCCONST.VIEWTEMPLATES);

    // Run deletion check to capture error logs
    Map<String,NotesDocId> docs =
        notesDocMgrDbTest.getIndexedDocument(null, null, 1);
    NotesDocId startUnid = docs.get(docs.keySet().iterator().next());
View Full Code Here

        NCCONST.VIEWINDEXED);

    // Create template document including formulas
    String searchString =
        "Select Form *= \"Main Topic\":\"MainTopic\":\"Response\"";
    NotesDatabaseMock configDatabase = factory.getDatabase("testconfig.nsf");
    NotesDocumentMock docTmpl = new NotesDocumentMock();
    docTmpl.addItem(new NotesItemMock("name", "Form", "type", NotesItem.TEXT,
        "values", "TEMPLATE"));
    docTmpl.addItem(new NotesItemMock("name", "TemplateName", "type",
        NotesItem.TEXT, "values", "Discussion"));
    docTmpl.addItem(new NotesItemMock("name", "SearchString", "type",
        NotesItem.TEXT, "values", searchString));
    configDatabase.addDocument(docTmpl, NCCONST.VIEWTEMPLATES);
    configDatabase.setViewFields(NCCONST.VIEWTEMPLATES, "TemplateName");

    // Run deletion check to capture error logs
    Map<String,NotesDocId> docs =
        notesDocMgrDbTest.getIndexedDocument(null, null, 1);
    NotesDocId startUnid = docs.get(docs.keySet().iterator().next());
View Full Code Here

    assertTrue(logs.get(0).contains(searchString));
  }

  private NotesDatabaseMock setupSourceDatabase(String server, String filePath,
      String replicaId, List<NotesDocumentMock> docs, String viewName) {
    NotesDatabaseMock srcDb =
        new NotesDatabaseMock(server, filePath, replicaId);
    for (NotesDocumentMock doc : docs) {
      srcDb.addDocument(doc, viewName);
    }
    factory.addDatabase(srcDb);
    return srcDb;
  }
View Full Code Here

    assertEquals("this is the text for field baz",
        crawlDoc.getItemValueString("x.mappedbaz"));
  }

  public void testGetNextFromCrawlQueue() throws Exception {
    NotesDatabaseMock configDatabase = factory.getDatabase("testconfig.nsf");
    NotesDocumentMock crawlRequestDoc = new NotesDocumentMock();
    configDatabase.addDocument(crawlRequestDoc, NCCONST.VIEWCRAWLQ);

    // Mimic the creation of a crawl request doc in NotesDatabasePoller.
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_STATE,
            "type", NotesItem.TEXT, "values", NCCONST.STATENEW));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.ITM_MIMETYPE,
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.notes.client.mock.NotesDatabaseMock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.