com.couchbase.client.java.error.DocumentDoesNotExistException Java Examples

The following examples show how to use com.couchbase.client.java.error.DocumentDoesNotExistException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestGetCouchbaseKey.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testDocumentNotFound() throws Exception {
    String docIdExp = "doc-n";

    Bucket bucket = mock(Bucket.class);
    when(bucket.get(docIdExp, RawJsonDocument.class))
        .thenReturn(null);
    setupMockBucket(bucket);

    testRunner.setProperty(DOC_ID, docIdExp);

    String inputFileDataStr = "input FlowFile data";
    byte[] inFileData = inputFileDataStr.getBytes(StandardCharsets.UTF_8);
    testRunner.enqueue(inFileData);
    testRunner.run();

    testRunner.assertTransferCount(REL_SUCCESS, 0);
    testRunner.assertTransferCount(REL_ORIGINAL, 0);
    testRunner.assertTransferCount(REL_RETRY, 0);
    testRunner.assertTransferCount(REL_FAILURE, 1);
    MockFlowFile orgFile = testRunner.getFlowFilesForRelationship(REL_FAILURE).get(0);
    orgFile.assertContentEquals(inputFileDataStr);
    orgFile.assertAttributeEquals(Exception.key(), DocumentDoesNotExistException.class.getName());
}
 
Example #2
Source File: TestGetCouchbaseKey.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testDocumentNotFound() throws Exception {
    String docIdExp = "doc-n";

    Bucket bucket = mock(Bucket.class);
    when(bucket.get(docIdExp, RawJsonDocument.class))
        .thenReturn(null);
    setupMockBucket(bucket);

    testRunner.setProperty(DOC_ID, docIdExp);

    String inputFileDataStr = "input FlowFile data";
    byte[] inFileData = inputFileDataStr.getBytes(StandardCharsets.UTF_8);
    testRunner.enqueue(inFileData);
    testRunner.run();

    testRunner.assertTransferCount(REL_SUCCESS, 0);
    testRunner.assertTransferCount(REL_ORIGINAL, 0);
    testRunner.assertTransferCount(REL_RETRY, 0);
    testRunner.assertTransferCount(REL_FAILURE, 1);
    MockFlowFile orgFile = testRunner.getFlowFilesForRelationship(REL_FAILURE).get(0);
    orgFile.assertContentEquals(inputFileDataStr);
    orgFile.assertAttributeEquals(Exception.key(), DocumentDoesNotExistException.class.getName());
}
 
Example #3
Source File: CouchbaseMapCacheClient.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public <K> boolean remove(K key, Serializer<K> serializer) throws IOException {
    try {
        bucket.remove(toDocumentId(key, serializer));
        return true;
    } catch (DocumentDoesNotExistException e) {
        return false;
    }
}