Package com.google.enterprise.connector.util.diffing

Examples of com.google.enterprise.connector.util.diffing.DocumentSnapshot


    return getObjectUnderTest(configMap).iterator().next();
  }

  private DocumentSnapshot getDeserializedSnapshot(DocumentSnapshot snapshot) {
    String serialSnapshot = snapshot.toString();
    DocumentSnapshot deserialSnapshot =
        new DBSnapshotFactory(getDbContext()).fromString(serialSnapshot);
    assertNotNull(deserialSnapshot);
    return deserialSnapshot;
  }
View Full Code Here


    return deserialSnapshot;
  }

  private void testSnapshotLifecycle(Map<String, String> configMap)
      throws Exception {
    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);
    DocumentSnapshot deserialSnapshot = getDeserializedSnapshot(snapshot);

    // This is the core assertion, that a deserialized snapshot
    // compares as identical to the repository source snapshot.
    DocumentHandle update = snapshot.getUpdate(deserialSnapshot);
    if (update != null) {
      fail(update.toString());
    }

    assertEquals(snapshot.getDocumentId(), deserialSnapshot.getDocumentId());
    assertEquals(snapshot.toString(), deserialSnapshot.toString());
  }
View Full Code Here

    testSnapshotLifecycle(getLobMap());
  }

  private void testSnapshotUnsupportedOperation(Map<String, String> configMap)
      throws Exception {
    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);
    DocumentSnapshot deserialSnapshot = getDeserializedSnapshot(snapshot);

    try {
      DocumentHandle update = deserialSnapshot.getUpdate(snapshot);
      fail("Expected an UnsupportedOperationException exception");
    } catch (UnsupportedOperationException expected) {
    }
  }
View Full Code Here

    testSnapshotUnsupportedOperation(getLobMap());
  }

  public void testHandleLifecycle(Map<String, String> configMap)
      throws Exception {
    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);

    DocumentHandle handle = snapshot.getUpdate(null);
    assertNotNull(handle);

    Document doc = handle.getDocument();
    assertNotNull(doc);
    Set<String> propertyNames = doc.getPropertyNames();
View Full Code Here

    verify(builder);
  }

  public void testGetUpdateNoChange() throws Exception {
    String serialSnapshot = documentSnapshot.toString();
    DocumentSnapshot deserialSnapshot =
        new DBSnapshot(valueOrdering, serialSnapshot);
    assertNull(documentSnapshot.getUpdate(deserialSnapshot));
  }
View Full Code Here

        new DBSnapshot(valueOrdering, serialSnapshot);
    assertNull(documentSnapshot.getUpdate(deserialSnapshot));
  }

  public void testGetUpdateChangedDocument() throws Exception {
    DocumentSnapshot onGsa = new DBSnapshot(null,
        builder.getJsonString(documentSnapshot.getDocumentId(), "9999"));

    // Assert that our DocumentHolder is used to create the DocumentHandle.
    expect(builder.getDocumentHandle(same(holder))).andReturn(null);
    replay(builder);
View Full Code Here

    dbContext.setPrimaryKeys(primaryKey);
    dbContext.setParameterizedQueryFlag(true);
    RepositoryHandler repositoryHandler = getObjectUnderTest(dbContext);
    List<DocumentSnapshot> snapshotList =
        repositoryHandler.executeQueryAndAddDocs();
    DocumentSnapshot snapshot = snapshotList.iterator().next();
    assertEquals(expectedDocid, snapshot.getDocumentId());
  }
View Full Code Here

        .andReturn(snapshotList)
        .andReturn(emptySnapshotList);
    replay(repositoryHandler);

    for (DocumentSnapshot expected : snapshotList) {
      DocumentSnapshot snapshot = repositoryHandlerIterator.next();
      assertSame(expected, snapshot);
    }
  }
View Full Code Here

  }

  public void testNext1() {
    expectExecuteAndReturn(snapshotList);

    DocumentSnapshot snapshot = repositoryHandlerIterator.next();
    assertSame(expectedSnapshot, snapshot);
    verify(repositoryHandler);
  }
View Full Code Here

    List<List<DocumentSnapshot>> batches = Lists.newArrayList();
    List<DocumentSnapshot> snapshotList = Lists.newArrayList();
    for (int i = 0; i < 3; i++) {
      List<DocumentSnapshot> batch = Lists.newArrayList();
      for (int j = 0; j < 3; j++) {
        DocumentSnapshot snapshot = createMock(DocumentSnapshot.class);
        batch.add(snapshot);
        snapshotList.add(snapshot);
      }
      batches.add(batch);
    }
    expect(repositoryHandler.executeQueryAndAddDocs());
    for (List<DocumentSnapshot> batch : batches) {
      expectLastCall().andReturn(batch);
    }
    expectLastCall().andReturn(emptySnapshotList);
    replay(repositoryHandler);

    for (DocumentSnapshot expected : snapshotList) {
      DocumentSnapshot snapshot = repositoryHandlerIterator.next();
      assertSame(expected, snapshot);
    }
    assertFalse(repositoryHandlerIterator.hasNext());
    verify(repositoryHandler);
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.util.diffing.DocumentSnapshot

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.