Search in sources :

Example 1 with BackpressureException

use of com.couchbase.client.core.BackpressureException in project nifi by apache.

the class TestGetCouchbaseKey method testCouchbaseTempClusterError.

@Test
public void testCouchbaseTempClusterError() throws Exception {
    String docIdExp = "doc-c";
    Bucket bucket = mock(Bucket.class);
    CouchbaseException exception = new BackpressureException();
    when(bucket.get(docIdExp, RawJsonDocument.class)).thenThrow(exception);
    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, 1);
    testRunner.assertTransferCount(REL_FAILURE, 0);
    MockFlowFile orgFile = testRunner.getFlowFilesForRelationship(REL_RETRY).get(0);
    orgFile.assertContentEquals(inputFileDataStr);
    orgFile.assertAttributeEquals(Exception.key(), exception.getClass().getName());
}
Also used : MockFlowFile(org.apache.nifi.util.MockFlowFile) CouchbaseException(com.couchbase.client.core.CouchbaseException) Bucket(com.couchbase.client.java.Bucket) BackpressureException(com.couchbase.client.core.BackpressureException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

BackpressureException (com.couchbase.client.core.BackpressureException)1 CouchbaseException (com.couchbase.client.core.CouchbaseException)1 Bucket (com.couchbase.client.java.Bucket)1 MockFlowFile (org.apache.nifi.util.MockFlowFile)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1