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

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


    return crawlDoc;
  }

  private NotesDocumentMock getCrawlDoc(boolean hasReaders)
      throws Exception {
    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_ACTION,
            "type", NotesItem.TEXT, "values", ActionType.ADD));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_DOCID, "type",
            NotesItem.TEXT, "values", "http://host:42/replicaid/0/docid"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_DISPLAYURL, "type",
            NotesItem.TEXT, "values", "http://host:42/replicaid/0/docid"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_REPLICAID,
            "type", NotesItem.TEXT, "values", "replicaid"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_TITLE, "type",
            NotesItem.TEXT, "values", "This is the title"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_MIMETYPE, "type",
            NotesItem.TEXT, "values", "text/plain"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_ISPUBLIC, "type",
            NotesItem.TEXT, "values", "true"));
    crawlDoc.addItem(new NotesItemMock("name",
            NCCONST.ITM_GMETADESCRIPTION, "type",
            NotesItem.TEXT, "values", "This is the description"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETADATABASE,
            "type", NotesItem.TEXT, "values", "crawled database"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETACATEGORIES,
            "type", NotesItem.TEXT, "values", "CATEGORY 1", "CATEGORY 2"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETAREPLICASERVERS,
            "type", NotesItem.TEXT, "values", "replica server"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETANOTESLINK,
            "type", NotesItem.TEXT, "values", "/notes/link"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETAWRITERNAME,
            "type", NotesItem.TEXT, "values", "An Author"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETAFORM, "type",
            NotesItem.TEXT, "values", "docform"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_CONTENT, "type",
            NotesItem.TEXT, "values", "This is the content"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_AUTHTYPE, "type",
            NotesItem.TEXT, "values", NCCONST.AUTH_ACL));
    if (hasReaders) {
      Vector<String> readers = new Vector<String>();
      readers.add("cn=John Smith/ou=Tests/o=Tests");
      readers.add("*");
      crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_DOCAUTHORREADERS,
              "type", NotesItem.TEXT, "values", readers,
              "readergroup", "[readerrole]"));
    }

    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETALASTUPDATE,
            "type", NotesItem.DATETIMES, "values", testDate));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETACREATEDATE,
            "type", NotesItem.DATETIMES, "values", testDate));

    return crawlDoc;
  }
View Full Code Here


    return crawlDoc;
  }

  private NotesDocumentMock getAttachmentDoc() throws Exception {
    NotesDocumentMock crawlDoc = getCrawlDoc(false);
    crawlDoc.replaceItemValue(NCCONST.ITM_DOCID,
        String.format(NCCONST.SITM_ATTACHMENTDOCID,
        "http://host:42/replicaid/0/unid", "attachmentUnid"));
    crawlDoc.replaceItemValue(NCCONST.ITM_DISPLAYURL,
        String.format(NCCONST.SITM_ATTACHMENTDISPLAYURL,
        "http://host:42/replicaid/0/unid", "filename.doc"));
    return crawlDoc;
  }
View Full Code Here

    // 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

        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 =
View Full Code Here

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

    connectorSession = (NotesConnectorSession) connector.login();
    session = connectorSession.createNotesSession();

    dbConfigMock =
        (NotesDatabaseMock) session.getDatabase("testserver", "testconfig.nsf");
    NotesDocumentMock docTemplateMock = new NotesDocumentMock();
    docTemplateMock.addItem(new NotesItemMock("name",
        NCCONST.TITM_TEMPLATENAME, "type", NotesItem.TEXT, "values",
        "Discussion"));
    docTemplateMock.addItem(new NotesItemMock("name",
        NCCONST.TITM_SEARCHRESULTSFIELDS, "type", NotesItem.TEXT, "values",
        "@True"));
    dbConfigMock.addDocument(docTemplateMock, NCCONST.VIEWTEMPLATES);
    dbConfigMock.setViewFields(NCCONST.VIEWTEMPLATES,
        NCCONST.TITM_TEMPLATENAME);
View Full Code Here

    NotesCrawlerThread crawler =
        new NotesCrawlerThread(connector, connectorSession);
    crawler.connectQueue();
    crawler.loadTemplateDoc("Discussion");

    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_SERVER, "type",
        NotesItem.TEXT, "values", "testserver"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_REPLICAID, "type",
        NotesItem.TEXT, "values", "replicaid"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_UNID, "type",
        NotesItem.TEXT, "values", "unid"));
    crawlDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_TEMPLATE, "type",
        NotesItem.TEXT, "values", "Discussion"));

    NotesDocumentMock sourceDoc = new NotesDocumentMock();
    sourceDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETAFORM, "type",
        NotesItem.TEXT, "values", "Main Topic"));
    sourceDoc.addItem(new NotesItemMock("name", NCCONST.ITM_LASTMODIFIED,
        "type", NotesItem.DATETIMES, "values", new Date()));
    sourceDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETAWRITERNAME,
        "type", NotesItem.TEXT, "values", "Mickey Mouse"));
    sourceDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETALASTUPDATE,
        "type", NotesItem.DATETIMES, "values", new Date()));
    sourceDoc.addItem(new NotesItemMock("name", NCCONST.ITM_GMETACREATEDATE,
        "type", NotesItem.DATETIMES, "values", new Date()));

    crawler.mapFields(crawlDoc, sourceDoc);
    assertNotNull(crawlDoc.getItemValueString(NCCONST.ITM_DISPLAYURL));
  }
View Full Code Here

    mf.add(new NotesCrawlerThread.MetaField("foo"));
    mf.add(new NotesCrawlerThread.MetaField("bar=mappedbar"));
    mf.add(new NotesCrawlerThread.MetaField("bazform===baz=mappedbaz"));
    crawler.metaFields = mf;

    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    NotesDocumentMock sourceDoc = new NotesDocumentMock();
    sourceDoc.addItem(new NotesItemMock("name", "foo", "type", NotesItem.TEXT,
        "values", "this is the text for field foo"));
    sourceDoc.addItem(new NotesItemMock("name", "bar", "type", NotesItem.TEXT,
        "values", "this is the text for field bar"));
    sourceDoc.addItem(new NotesItemMock("name", "baz", "type", NotesItem.TEXT,
        "values", "this is the text for field baz"));

    crawler.mapMetaFields(crawlDoc, sourceDoc);
    assertTrue("crawl doc missing x.foo", crawlDoc.hasItem("x.foo"));
    assertEquals("this is the text for field foo",
        crawlDoc.getItemValueString("x.foo"));
    assertTrue("crawl doc missing x.mappedbar",
        crawlDoc.hasItem("x.mappedbar"));
    assertEquals("this is the text for field bar",
        crawlDoc.getItemValueString("x.mappedbar"));
    assertFalse("crawl doc has x.mappedbaz", crawlDoc.hasItem("x.mappedbaz"));

    // Add a form name to the doc. Now the metafield mapping with
    // a form qualification should apply.
    sourceDoc.addItem(new NotesItemMock("name", "form", "type", NotesItem.TEXT,
        "values", "bazform"));
    crawlDoc = new NotesDocumentMock();
    crawler.mapMetaFields(crawlDoc, sourceDoc);
    assertTrue("crawl doc missing x.foo", crawlDoc.hasItem("x.foo"));
    assertEquals("this is the text for field foo",
        crawlDoc.getItemValueString("x.foo"));
    assertTrue("crawl doc missing x.mappedbar",
View Full Code Here

        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,
            "type", NotesItem.TEXT, "values", NCCONST.DEFAULT_DOCMIMETYPE));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.ITMFORM,
                "type", NotesItem.TEXT, "values", NCCONST.FORMCRAWLREQUEST));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_UNID,
            "type", NotesItem.TEXT, "values", "sourcedocunid"));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_REPLICAID,
            "type", NotesItem.TEXT, "values", "sourcedbreplicaid"));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_SERVER,
            "type", NotesItem.TEXT, "values", "testserver"));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_TEMPLATE,
            "type", NotesItem.TEXT, "values", "testtemplate"));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_DOMAIN,
            "type", NotesItem.TEXT, "values", "testdomain"));
    crawlRequestDoc.addItem(new NotesItemMock("name", NCCONST.NCITM_AUTHTYPE,
            "type", NotesItem.TEXT, "values", NCCONST.AUTH_CONNECTOR));
    crawlRequestDoc.addItem(
        new NotesItemMock("name", NCCONST.ITM_GMETANOTESLINK,
            "type", NotesItem.TEXT, "values", "notes url"));

    NotesConnectorSession connectorSession =
        (NotesConnectorSession) connector.login();
View Full Code Here

  public void testLoadTemplateDoc() throws Exception {
    NotesDatabaseMock configDatabase = factory.getDatabase("testconfig.nsf");
    configDatabase.setViewFields(NCCONST.VIEWTEMPLATES,
        NCCONST.TITM_TEMPLATENAME);
    NotesDocumentMock template1 = new NotesDocumentMock();
    configDatabase.addDocument(template1, NCCONST.VIEWTEMPLATES);
    template1.addItem(new NotesItemMock("name", NCCONST.TITM_TEMPLATENAME,
            "type", NotesItem.TEXT, "values", "testtemplate1"));
    template1.addItem(new NotesItemMock("name", NCCONST.TITM_METAFIELDS,
            "type", NotesItem.TEXT, "values", "foo", "bar=mappedbar"));
    NotesDocumentMock template2 = new NotesDocumentMock();
    configDatabase.addDocument(template2, NCCONST.VIEWTEMPLATES);
    template2.addItem(new NotesItemMock("name", NCCONST.TITM_TEMPLATENAME,
            "type", NotesItem.TEXT, "values", "testtemplate2"));
    template2.addItem(new NotesItemMock("name", NCCONST.TITM_METAFIELDS,
            "type", NotesItem.TEXT, "values", "foo", "bar=mappedbar"));
    NotesDocumentMock templateResponse = new NotesDocumentMock();
    template2.addResponse(templateResponse);

    NotesConnectorSession connectorSession =
        (NotesConnectorSession) connector.login();
    NotesCrawlerThread crawlerThread = new NotesCrawlerThread(connector,
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.