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

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


    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


        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("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",
View Full Code Here

    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();
    NotesSession session = connectorSession.createNotesSession();
View Full Code Here

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

    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"));
    NotesDocumentMock templateResponse = new NotesDocumentMock();
    templateResponse.addItem(new NotesItemMock("name", NCCONST.FITM_LASTALIAS,
            "type", NotesItem.TEXT, "values", "testtemplate1form"));
    template1.addResponse(templateResponse);

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

    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    assertEquals("",
        crawlDoc.getItemValueString(NCCONST.NCITM_DOCAUTHORREADERS));

    NotesItemMock item = new NotesItemMock("name", "readers",
        "type", NotesItem.TEXT, "values", "reader 1");
    item.setReaders(true);
    srcDoc.addItem(item);
    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    assertEquals("reader 1",
        crawlDoc.getItemValueString(NCCONST.NCITM_DOCAUTHORREADERS));

    item = new NotesItemMock("name", "readers",
        "type", NotesItem.TEXT, "values", "reader 1", "reader 2");
    item.setReaders(true);
    srcDoc.replaceItemValue("readers", item);
    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    assertEquals("reader 1;reader 2",
        crawlDoc.getFirstItem(NCCONST.NCITM_DOCAUTHORREADERS).getText(100));

    item = new NotesItemMock("name", "authors", "type", NotesItem.TEXT,
        "values", "author 1");
    item.setAuthors(true);
    srcDoc.addItem(item);
    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    Vector values = crawlDoc.getItemValue(NCCONST.NCITM_DOCAUTHORREADERS);
    assertEquals(3, values.size());
    assertTrue(values.contains("reader 1"));
View Full Code Here

    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    assertEquals("",
        crawlDoc.getItemValueString(NCCONST.NCITM_DOCAUTHORREADERS));

    // Check that the values from two Readers field are found.
    NotesItemMock item = new NotesItemMock("name", "readers",
        "type", NotesItem.TEXT, "values", "reader 1");
    item.setReaders(true);
    srcDoc.addItem(item);
    item = new NotesItemMock("name", "readers2",
        "type", NotesItem.TEXT, "values", "reader 2");
    item.setReaders(true);
    srcDoc.addItem(item);
    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    Vector values = crawlDoc.getItemValue(NCCONST.NCITM_DOCAUTHORREADERS);
    assertEquals(2, values.size());
    assertTrue(values.contains("reader 1"));
    assertTrue(values.contains("reader 2"));

    // Check that the Authors field is added.
    item = new NotesItemMock("name", "authors", "type", NotesItem.TEXT,
        "values", "author 1");
    item.setAuthors(true);
    srcDoc.addItem(item);
    item = new NotesItemMock("name", "authors2", "type", NotesItem.TEXT,
        "values", "author 2", "author 3");
    item.setAuthors(true);
    srcDoc.addItem(item);
    crawlerThread.getDocumentReaderNames(crawlDoc, srcDoc);
    values = crawlDoc.getItemValue(NCCONST.NCITM_DOCAUTHORREADERS);
    assertEquals(5, values.size());
    assertTrue(values.contains("reader 1"));
View Full Code Here

    assertTrue(values.contains("author 3"));
  }

  public void testSetDocumentSecurity() throws Exception {
    NotesDocumentMock crawlDoc = new NotesDocumentMock();
    NotesItemMock item = new NotesItemMock("name", NCCONST.NCITM_AUTHTYPE,
        "type", NotesItem.TEXT, "values", NCCONST.AUTH_NONE);
    crawlDoc.addItem(item);

    NotesCrawlerThread crawlerThread = new NotesCrawlerThread(null, null);
    crawlerThread.setDocumentSecurity(crawlDoc, null);
    assertEquals(Boolean.TRUE.toString(),
        crawlDoc.getItemValueString(NCCONST.ITM_ISPUBLIC));

    item = new NotesItemMock("name", NCCONST.NCITM_AUTHTYPE,
        "type", NotesItem.TEXT, "values", NCCONST.AUTH_ACL);
    crawlDoc.replaceItemValue(NCCONST.NCITM_AUTHTYPE, item);
    crawlerThread.setDocumentSecurity(crawlDoc, null);
    assertEquals(Boolean.FALSE.toString(),
        crawlDoc.getItemValueString(NCCONST.ITM_ISPUBLIC));

    item = new NotesItemMock("name", NCCONST.NCITM_AUTHTYPE,
        "type", NotesItem.TEXT, "values", NCCONST.AUTH_CONNECTOR);
    crawlDoc.replaceItemValue(NCCONST.NCITM_AUTHTYPE, item);
    crawlerThread.setDocumentSecurity(crawlDoc, null);
    assertEquals(Boolean.FALSE.toString(),
        crawlDoc.getItemValueString(NCCONST.ITM_ISPUBLIC));
View Full Code Here

        crawlDoc.getItemValueString(NCCONST.ITM_ISPUBLIC));
  }

  public void testGetContentFields() throws Exception {
    NotesDocumentMock srcDoc = new NotesDocumentMock();
    NotesItemMock item = new NotesItemMock("name", "field 1",
        "type", NotesItem.TEXT, "values", "value for field 1");
    srcDoc.addItem(item);
    item = new NotesItemMock("name", "field 2",
        "type", NotesItem.TEXT, "values", "value for field 2");
    srcDoc.addItem(item);
    item = new NotesItemMock("name", "form",
        "type", NotesItem.TEXT, "values", "form - should not appear");
    srcDoc.addItem(item);
    item = new NotesItemMock("name", "$field",
        "type", NotesItem.TEXT, "values", "$field - should not appear");
    srcDoc.addItem(item);

    NotesCrawlerThread crawlerThread = new NotesCrawlerThread(null, null);
    String content = crawlerThread.getContentFields(srcDoc);
    assertEquals("\nvalue for field 1\nvalue for field 2", content);

    NotesDocumentMock formDoc = new NotesDocumentMock();
    item = new NotesItemMock("name", NCCONST.FITM_FIELDSTOINDEX,
        "type", NotesItem.TEXT, "values", "field 2");
    formDoc.addItem(item);
    crawlerThread.formDoc = formDoc;
    content = crawlerThread.getContentFields(srcDoc);
    assertEquals("\nvalue for field 2", content);
View Full Code Here

TOP

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

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.