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

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


        // 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");
View Full Code Here


  // Used by other test classes.
  static NotesDocumentMock addNotesUser(NotesConnectorSession connectorSession,
      NotesDatabaseMock namesDatabase, String notesname, String gsaname)
      throws Exception {
    NotesDocumentMock notesPerson = new NotesDocumentMock();
    notesPerson.addItem(new NotesItemMock("name", "unid",
            "type", NotesItem.TEXT, "values", gsaname));
    notesPerson.addItem(new NotesItemMock("name", NCCONST.NCITM_UNID,
            "type", NotesItem.TEXT, "values", gsaname));
    notesPerson.addItem(new NotesItemMock("name", NCCONST.PITM_FULLNAME,
            "type", NotesItem.TEXT, "values", notesname));
    notesPerson.addItem(new NotesItemMock("name", "HTTPPassword",
            "type", NotesItem.TEXT, "values", "password"));
    notesPerson.addItem(new NotesItemMock("name", NCCONST.ITMFORM,
            "type", NotesItem.TEXT, "values", NCCONST.DIRFORM_PERSON));
    notesPerson.addItem(new NotesItemMock("name",
            "evaluate_" + connectorSession.getUserNameFormula(),
            "type", NotesItem.TEXT, "values", gsaname));
    notesPerson.addItem(new NotesItemMock("name",
            "evaluate_" + connectorSession.getUserSelectionFormula(),
            "type", NotesItem.TEXT, "values", 1.0));
    namesDatabase.addDocument(notesPerson, NCCONST.DIRVIEW_USERS,
        NCCONST.DIRVIEW_PEOPLEGROUPFLAT, NCCONST.DIRVIEW_SERVERACCESS,
        NCCONST.DIRVIEW_VIMUSERS, "notesnamelookup");
View Full Code Here

  }

  static NotesDocumentMock addNotesGroup(
      NotesDatabaseMock namesDatabase, String groupName,
      String... members) throws Exception {
    NotesDocumentMock notesGroup = new NotesDocumentMock();
    notesGroup.addItem(new NotesItemMock("name", "unid",
            "type", NotesItem.TEXT, "values", groupName));
    notesGroup.addItem(new NotesItemMock("name", NCCONST.NCITM_UNID,
            "type", NotesItem.TEXT, "values", groupName));
    notesGroup.addItem(new NotesItemMock("name", NCCONST.GITM_LISTNAME,
            "type", NotesItem.TEXT, "values", groupName));
    notesGroup.addItem(new NotesItemMock("name", NCCONST.ITMFORM,
            "type", NotesItem.TEXT, "values", NCCONST.DIRFORM_GROUP));
    notesGroup.addItem(new NotesItemMock("name", NCCONST.GITM_GROUPTYPE,
            "type", NotesItem.TEXT, "values",
            NCCONST.DIR_ACCESSCONTROLGROUPTYPES));
    if (members != null && members.length > 0) {
      notesGroup.addItem(new NotesItemMock("name", NCCONST.GITM_MEMBERS,
              "type", NotesItem.TEXT, "values", members));
    }
    namesDatabase.addDocument(notesGroup,
        NCCONST.DIRVIEW_PEOPLEGROUPFLAT, NCCONST.DIRVIEW_SERVERACCESS,
        NCCONST.DIRVIEW_VIMGROUPS, "grouplookup");
View Full Code Here

    setUpRoles();

    // Find the Notes doc for the user to be deleted. Use a
    // user with a role.
    NotesView nameView = namesDatabase.getView("notesnamelookup");
    NotesDocumentMock doc = (NotesDocumentMock) nameView.getDocumentByKey(
        "cn=Yoda/ou=Tests/o=Tests");
    assertNotNull("No yoda", doc);
    try {
      Long id = assertUserExists("yoda");
      assertUserHasGroup("yoda", "jedi");
      assertUserHasRole("yoda", "jtmreplicaid0123/[philosopher]");

      // Delete the user from the Notes database. Call
      // checkUserDeletions and verify that the user was removed
      // from the user cache.
      doc.remove(true);
      userGroupManager.checkUserDeletions();
      getGroupData();
      getUserData();
      getRoleData();
      assertUserDoesNotExist("yoda");
View Full Code Here

    userGroupManager.updateUsers(userUnids);

    // Find the Notes doc for the group to be deleted.
    // Use a group with children.
    NotesView nameView = namesDatabase.getView("grouplookup");
    NotesDocumentMock doc = (NotesDocumentMock) nameView.getDocumentByKey(
        "jedi");
    assertNotNull("No jedi", doc);

    // Test group with canonical name
    NotesDocumentMock doc2 = (NotesDocumentMock) nameView.getDocumentByKey(
        "cn=west coast/ou=west/o=test");
    assertNotNull("cn=west coast/ou=west/o=test", doc2);

    try {
      // Get the current user/group data and verify that the group is there.
      getGroupData();
      getUserData();

      Long id = groups.get("jedi");
      assertNotNull("missing test group before test", id);

      // Delete the group from the Notes database. Call
      // checkGroupDeletions and verify that the group was removed
      // from the group cache.
      doc.remove(true);
      doc2.remove(true);
      userGroupManager.checkGroupDeletions();
      getGroupData();
      getUserData();
      assertGroupDoesNotExist("jedi");
      assertGroupDoesNotExist("cn=west coast/ou=west/o=test");
View Full Code Here

    userGroupManager.updateGroups(groupUnids);
    userGroupManager.updateUsers(userUnids);

    // Find the Notes doc for the user to be deleted.
    NotesView nameView = namesDatabase.getView("notesnamelookup");
    NotesDocumentMock doc = (NotesDocumentMock) nameView.getDocumentByKey(
        "cn=Anakin Skywalker/ou=Tests/o=Tests");
    assertNotNull("No anakin", doc);
    try {
      // Get the current user/group data and verify that the user is there.
      getGroupData();
      getUserData();

      Long id = assertUserExists("anakin");
      assertNotNull("user has no groups", userGroups.get(id));

      // Change the result of the user selection formula. Call
      // checkUserDeletions and verify that the user was removed
      // from the user cache.
      doc.replaceItemValue(
          "evaluate_" + connectorSession.getUserSelectionFormula(),
          new NotesItemMock("name",
              "evaluate_" + connectorSession.getUserSelectionFormula(),
              "type", NotesItem.TEXT, "values", 0.0));

      userGroupManager.checkUserDeletions();
      getGroupData();
      getUserData();
      assertUserDoesNotExist("anakin");
      assertNull("user still has groups", userGroups.get(id));
    } finally {
      doc.replaceItemValue(
          "evaluate_" + connectorSession.getUserSelectionFormula(),
          new NotesItemMock("name",
              "evaluate_" + connectorSession.getUserSelectionFormula(),
              "type", NotesItem.TEXT, "values", 1.0));
    }
View Full Code Here

  public void testChangeUserGsaName() throws Exception {
    setUpRoles();

    // Find the Notes doc for the user to be changed.
    NotesView nameView = namesDatabase.getView("notesnamelookup");
    NotesDocumentMock doc = (NotesDocumentMock) nameView.getDocumentByKey(
        "cn=Obi-Wan Kenobi/ou=Tests/o=Tests");
    assertNotNull("No kenobi", doc);
    try {
      assertUserExists("kenobi");
      assertUserDoesNotExist("ben");

      // Change the user name.
      doc.replaceItemValue(
          "evaluate_" + connectorSession.getUserNameFormula(),
          new NotesItemMock("name",
            "evaluate_" + connectorSession.getUserNameFormula(),
            "type", NotesItem.TEXT, "values", "ben"));

      setUpRoles();
      assertUserExists("ben");
      assertUserDoesNotExist("kenobi");
    } finally {
      doc.replaceItemValue(
          "evaluate_" + connectorSession.getUserNameFormula(),
          new NotesItemMock("name",
            "evaluate_" + connectorSession.getUserNameFormula(),
            "type", NotesItem.TEXT, "values", "kenobi"));
    }
View Full Code Here

  public void testSetMetaFieldsText() throws Exception {
    NotesConnectorDocument doc = new NotesConnectorDocument(null, null, null);
    doc.docProps = new HashMap<String, List<Value>>();

    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    crawlDoc.addItem(new NotesItemMock("name", "x.foo", "type", NotesItem.TEXT,
            "values", "this is the text for field foo"));
    doc.crawlDoc = crawlDoc;
    doc.setMetaFields();
    Property p = doc.findProperty("foo");
    assertNotNull("property foo missing", p);
View Full Code Here

  public void testSetMetaFieldsNumber() throws Exception {
    NotesConnectorDocument doc = new NotesConnectorDocument(null, null, null);
    doc.docProps = new HashMap<String, List<Value>>();

    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    crawlDoc.addItem(new NotesItemMock("name", "x.foo", "type",
            NotesItem.NUMBERS, "values", new Double(11)));
    doc.crawlDoc = crawlDoc;
    doc.setMetaFields();
    Property p = doc.findProperty("foo");
    assertNotNull("property foo missing", p);
View Full Code Here

    Date testDate = new Date();
    Calendar testCalendar = Calendar.getInstance();
    testCalendar.setTime(testDate);

    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    crawlDoc.addItem(new NotesItemMock("name", "x.foo", "type",
            NotesItem.NUMBERS, "values", new NotesDateTimeMock(testDate)));
    doc.crawlDoc = crawlDoc;
    doc.setMetaFields();
    Property p = doc.findProperty("foo");
    assertNotNull("property foo missing", p);
View Full Code Here

TOP

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

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.