Java Code Examples for com.amazonaws.regions.Regions#AP_NORTHEAST_1
The following examples show how to use
com.amazonaws.regions.Regions#AP_NORTHEAST_1 .
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: DeleteDynamoDBTest.java From nifi with Apache License 2.0 | 6 votes |
@Before public void setUp() { outcome = new BatchWriteItemOutcome(result); result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>()); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { return outcome; } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; }
Example 2
Source File: PutDynamoDBTest.java From nifi with Apache License 2.0 | 6 votes |
@Before public void setUp() { outcome = new BatchWriteItemOutcome(result); result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>()); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { return outcome; } }; putDynamoDB = new PutDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; }
Example 3
Source File: PutDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangePutThrowsServiceException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonServiceException("serviceException"); } }; putDynamoDB = new PutDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner putRunner = TestRunners.newTestRunner(putDynamoDB); putRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); putRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); putRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); putRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document"); String document = "{\"name\":\"john\"}"; putRunner.enqueue(document.getBytes()); putRunner.run(1); putRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("serviceException (Service: null; Status Code: 0; Error Code: null; Request ID: null)", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 4
Source File: PutDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangePutThrowsRuntimeException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new RuntimeException("runtimeException"); } }; putDynamoDB = new PutDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner putRunner = TestRunners.newTestRunner(putDynamoDB); putRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); putRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); putRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); putRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document"); String document = "{\"name\":\"john\"}"; putRunner.enqueue(document.getBytes()); putRunner.run(1); putRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 5
Source File: PutDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangePutThrowsClientException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonClientException("clientException"); } }; putDynamoDB = new PutDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner putRunner = TestRunners.newTestRunner(putDynamoDB); putRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); putRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); putRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); putRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document"); String document = "{\"name\":\"john\"}"; putRunner.enqueue(document.getBytes()); putRunner.run(1); putRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("clientException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 6
Source File: PutDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangePutThrowsServiceException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonServiceException("serviceException"); } }; putDynamoDB = new PutDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner putRunner = TestRunners.newTestRunner(putDynamoDB); putRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); putRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); putRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); putRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); putRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); putRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document"); String document = "{\"name\":\"john\"}"; putRunner.enqueue(document.getBytes()); putRunner.run(1); putRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("serviceException (Service: null; Status Code: 0; Error Code: null; Request ID: null)", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 7
Source File: GetDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeGetThrowsClientException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { throw new AmazonClientException("clientException"); } }; final GetDynamoDB getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("clientException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 8
Source File: GetDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeGetThrowsRuntimeException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { throw new RuntimeException("runtimeException"); } }; final GetDynamoDB getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 9
Source File: GetDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeGetThrowsRuntimeException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { throw new RuntimeException("runtimeException"); } }; final GetDynamoDB getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 10
Source File: DeleteDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeDeleteThrowsRuntimeException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new RuntimeException("runtimeException"); } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner deleteRunner = TestRunners.newTestRunner(deleteDynamoDB); deleteRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); deleteRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); deleteRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); deleteRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); deleteRunner.enqueue(new byte[] {}); deleteRunner.run(1); deleteRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = deleteRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 11
Source File: DeleteDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeDeleteThrowsClientException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonClientException("clientException"); } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner deleteRunner = TestRunners.newTestRunner(deleteDynamoDB); deleteRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); deleteRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); deleteRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); deleteRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); deleteRunner.enqueue(new byte[] {}); deleteRunner.run(1); deleteRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = deleteRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("clientException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 12
Source File: DeleteDynamoDBTest.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeDeleteThrowsServiceException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonServiceException("serviceException"); } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner deleteRunner = TestRunners.newTestRunner(deleteDynamoDB); deleteRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); deleteRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); deleteRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); deleteRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); deleteRunner.enqueue(new byte[] {}); deleteRunner.run(1); deleteRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = deleteRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("serviceException (Service: null; Status Code: 0; Error Code: null; Request ID: null)", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 13
Source File: DeleteDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeDeleteThrowsClientException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new AmazonClientException("clientException"); } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner deleteRunner = TestRunners.newTestRunner(deleteDynamoDB); deleteRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); deleteRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); deleteRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); deleteRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); deleteRunner.enqueue(new byte[] {}); deleteRunner.run(1); deleteRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = deleteRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("clientException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 14
Source File: DeleteDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeDeleteThrowsRuntimeException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchWriteItemOutcome batchWriteItem(TableWriteItems... tableWriteItems) { throw new RuntimeException("runtimeException"); } }; deleteDynamoDB = new DeleteDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner deleteRunner = TestRunners.newTestRunner(deleteDynamoDB); deleteRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); deleteRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); deleteRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); deleteRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); deleteRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); deleteRunner.enqueue(new byte[] {}); deleteRunner.run(1); deleteRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = deleteRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 15
Source File: GetDynamoDBTest.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testStringHashStringRangeGetThrowsClientException() { final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { throw new AmazonClientException("clientException"); } }; final GetDynamoDB getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE); for (MockFlowFile flowFile : flowFiles) { assertEquals("clientException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE)); } }
Example 16
Source File: GetDynamoDBTest.java From localization_nifi with Apache License 2.0 | 4 votes |
@Test public void testStringHashStringRangeGetJsonObjectNull() { outcome = new BatchGetItemOutcome(result); KeysAndAttributes kaa = new KeysAndAttributes(); Map<String,AttributeValue> map = new HashMap<>(); map.put("hashS", new AttributeValue("h1")); map.put("rangeS", new AttributeValue("r1")); kaa.withKeys(map); unprocessed = new HashMap<>(); result.withUnprocessedKeys(unprocessed); Map<String,List<Map<String,AttributeValue>>> responses = new HashMap<>(); List<Map<String,AttributeValue>> items = new ArrayList<>(); Map<String,AttributeValue> item = new HashMap<String,AttributeValue>(); item.put("j1",null); item.put("hashS", new AttributeValue("h1")); item.put("rangeS", new AttributeValue("r1")); items.add(item); responses.put("StringHashStringRangeTable", items); result.withResponses(responses); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { return outcome; } }; getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS); for (MockFlowFile flowFile : flowFiles) { assertNull(flowFile.getContentClaim()); } }
Example 17
Source File: GetDynamoDBTest.java From localization_nifi with Apache License 2.0 | 4 votes |
@Test public void testStringHashStringRangeGetJsonObjectValid() throws IOException { outcome = new BatchGetItemOutcome(result); KeysAndAttributes kaa = new KeysAndAttributes(); Map<String,AttributeValue> map = new HashMap<>(); map.put("hashS", new AttributeValue("h1")); map.put("rangeS", new AttributeValue("r1")); kaa.withKeys(map); unprocessed = new HashMap<>(); result.withUnprocessedKeys(unprocessed); Map<String,List<Map<String,AttributeValue>>> responses = new HashMap<>(); List<Map<String,AttributeValue>> items = new ArrayList<>(); Map<String,AttributeValue> item = new HashMap<String,AttributeValue>(); String jsonDocument = "{\"name\": \"john\"}"; item.put("j1",new AttributeValue(jsonDocument)); item.put("hashS", new AttributeValue("h1")); item.put("rangeS", new AttributeValue("r1")); items.add(item); responses.put("StringHashStringRangeTable", items); result.withResponses(responses); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { return outcome; } }; getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1); }
Example 18
Source File: GetDynamoDBTest.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testStringHashStringRangeGetNotFound() { result.clearResponsesEntries(); result.clearUnprocessedKeysEntries(); final BatchGetItemOutcome notFoundOutcome = new BatchGetItemOutcome(result); Map<String,List<Map<String,AttributeValue>>> responses = new HashMap<>(); List<Map<String,AttributeValue>> items = new ArrayList<>(); responses.put(stringHashStringRangeTableName, items); result.withResponses(responses); final DynamoDB notFoundMockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { return notFoundOutcome; } }; final GetDynamoDB getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return notFoundMockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(GetDynamoDB.REL_NOT_FOUND, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_UNPROCESSED); for (MockFlowFile flowFile : flowFiles) { assertNotNull(flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND)); } }
Example 19
Source File: GetDynamoDBTest.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testStringHashStringRangeGetJsonObjectValid() throws IOException { outcome = new BatchGetItemOutcome(result); KeysAndAttributes kaa = new KeysAndAttributes(); Map<String,AttributeValue> map = new HashMap<>(); map.put("hashS", new AttributeValue("h1")); map.put("rangeS", new AttributeValue("r1")); kaa.withKeys(map); unprocessed = new HashMap<>(); result.withUnprocessedKeys(unprocessed); Map<String,List<Map<String,AttributeValue>>> responses = new HashMap<>(); List<Map<String,AttributeValue>> items = new ArrayList<>(); Map<String,AttributeValue> item = new HashMap<String,AttributeValue>(); String jsonDocument = "{\"name\": \"john\"}"; item.put("j1",new AttributeValue(jsonDocument)); item.put("hashS", new AttributeValue("h1")); item.put("rangeS", new AttributeValue("r1")); items.add(item); responses.put("StringHashStringRangeTable", items); result.withResponses(responses); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { return outcome; } }; getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1); }
Example 20
Source File: GetDynamoDBTest.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testStringHashStringRangeGetJsonObjectNull() { outcome = new BatchGetItemOutcome(result); KeysAndAttributes kaa = new KeysAndAttributes(); Map<String,AttributeValue> map = new HashMap<>(); map.put("hashS", new AttributeValue("h1")); map.put("rangeS", new AttributeValue("r1")); kaa.withKeys(map); unprocessed = new HashMap<>(); result.withUnprocessedKeys(unprocessed); Map<String,List<Map<String,AttributeValue>>> responses = new HashMap<>(); List<Map<String,AttributeValue>> items = new ArrayList<>(); Map<String,AttributeValue> item = new HashMap<String,AttributeValue>(); item.put("j1",null); item.put("hashS", new AttributeValue("h1")); item.put("rangeS", new AttributeValue("r1")); items.add(item); responses.put("StringHashStringRangeTable", items); result.withResponses(responses); final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) { @Override public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) { return outcome; } }; getDynamoDB = new GetDynamoDB() { @Override protected DynamoDB getDynamoDB() { return mockDynamoDB; } }; final TestRunner getRunner = TestRunners.newTestRunner(getDynamoDB); getRunner.setProperty(AbstractDynamoDBProcessor.ACCESS_KEY,"abcd"); getRunner.setProperty(AbstractDynamoDBProcessor.SECRET_KEY, "cdef"); getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION); getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS"); getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1"); getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1"); getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "j1"); getRunner.enqueue(new byte[] {}); getRunner.run(1); getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1); List<MockFlowFile> flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS); for (MockFlowFile flowFile : flowFiles) { assertNull(flowFile.getContentClaim()); } }