mirror of https://github.com/apache/nifi.git
NIFI-9085 Refactored the Elasticsearch bundle to use JUnit 5
- NIFI-9086 Refactored nifi-accumulo-bundle to use JUnit 5 - NIFI-9087 Updated nifi-ambari-bundle to use JUnit 5 - NIFI-9088 Refactored nifi-amqp-bundle to use JUnit 5 - NIFI-9089 Updated nifi-asn1-bundle to use JUnit 5 - NIFI-9090 Refactored nifi-atlas-bundle to use JUnit 5 - NIFI-9091 Refactored nifi-avro-bundle to use JUnit 5 - NIFI-9092 Refactored nifi-aws-bundle to use JUnit 5 - NIFI-9095 Refactored nifi-azure-bundle to use JUnit 5 - NIFI-9145 Refactored nifi-rethinkdb-bundle to use JUnit 5 - NIFI-9143 Refactored nifi-redis-bundle to use JUnit 5 This closes #5350 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
43bf2b5975
commit
f35f010deb
|
@ -29,20 +29,19 @@ import org.apache.accumulo.core.data.Value;
|
||||||
import org.apache.accumulo.core.security.Authorizations;
|
import org.apache.accumulo.core.security.Authorizations;
|
||||||
import org.apache.accumulo.core.security.ColumnVisibility;
|
import org.apache.accumulo.core.security.ColumnVisibility;
|
||||||
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
|
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
import org.apache.nifi.accumulo.controllerservices.AccumuloService;
|
||||||
|
import org.apache.nifi.accumulo.controllerservices.MockAccumuloService;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.serialization.record.MockRecordParser;
|
import org.apache.nifi.serialization.record.MockRecordParser;
|
||||||
import org.apache.nifi.serialization.record.RecordFieldType;
|
import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Assume;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
import org.apache.nifi.accumulo.controllerservices.AccumuloService;
|
|
||||||
import org.apache.nifi.accumulo.controllerservices.MockAccumuloService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -55,6 +54,10 @@ import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@DisabledOnOs(OS.WINDOWS)
|
||||||
public class PutRecordIT {
|
public class PutRecordIT {
|
||||||
|
|
||||||
public static final String DEFAULT_COLUMN_FAMILY = "family1";
|
public static final String DEFAULT_COLUMN_FAMILY = "family1";
|
||||||
|
@ -75,9 +78,8 @@ public class PutRecordIT {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setupInstance() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableExistsException {
|
public static void setupInstance() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableExistsException {
|
||||||
Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS);
|
|
||||||
Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories
|
Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories
|
||||||
accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password");
|
accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password");
|
||||||
accumulo.start();
|
accumulo.start();
|
||||||
|
@ -139,10 +141,10 @@ public class PutRecordIT {
|
||||||
ranges.add(new Range());
|
ranges.add(new Range());
|
||||||
scanner.setRanges(ranges);
|
scanner.setRanges(ranges);
|
||||||
for (Map.Entry<Key, Value> kv : scanner) {
|
for (Map.Entry<Key, Value> kv : scanner) {
|
||||||
Assert.assertTrue(kv.getKey() + " not in expected keys",expectedKeys.remove(kv.getKey()));
|
assertTrue(expectedKeys.remove(kv.getKey()), kv.getKey() + " not in expected keys");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert.assertEquals(0, expectedKeys.size());
|
assertEquals(0, expectedKeys.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,7 @@ public class PutRecordIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(PutAccumuloRecord.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(PutAccumuloRecord.REL_SUCCESS);
|
||||||
Assert.assertTrue("Wrong count", results.size() == 1);
|
assertTrue(results.size() == 1, "Wrong count");
|
||||||
verifyKey(tableName, expectedKeys, defaultVis);
|
verifyKey(tableName, expectedKeys, defaultVis);
|
||||||
if (deletes){
|
if (deletes){
|
||||||
runner.setProperty(PutAccumuloRecord.DELETE_KEY, "true");
|
runner.setProperty(PutAccumuloRecord.DELETE_KEY, "true");
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.accumulo.core.data.Value;
|
||||||
import org.apache.accumulo.core.security.Authorizations;
|
import org.apache.accumulo.core.security.Authorizations;
|
||||||
import org.apache.accumulo.core.security.ColumnVisibility;
|
import org.apache.accumulo.core.security.ColumnVisibility;
|
||||||
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
|
import org.apache.accumulo.minicluster.MiniAccumuloCluster;
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
import org.apache.nifi.accumulo.controllerservices.MockAccumuloService;
|
import org.apache.nifi.accumulo.controllerservices.MockAccumuloService;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
|
@ -36,10 +35,10 @@ import org.apache.nifi.serialization.record.MockRecordWriter;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Assume;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -48,6 +47,10 @@ import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
@DisabledOnOs(OS.WINDOWS)
|
||||||
public class ScanAccumuloIT {
|
public class ScanAccumuloIT {
|
||||||
|
|
||||||
public static final String DEFAULT_COLUMN_FAMILY = "family1";
|
public static final String DEFAULT_COLUMN_FAMILY = "family1";
|
||||||
|
@ -58,9 +61,8 @@ public class ScanAccumuloIT {
|
||||||
*/
|
*/
|
||||||
private static MiniAccumuloCluster accumulo;
|
private static MiniAccumuloCluster accumulo;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setupInstance() throws IOException, InterruptedException {
|
public static void setupInstance() throws IOException, InterruptedException {
|
||||||
Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS);
|
|
||||||
Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories
|
Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories
|
||||||
accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password");
|
accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password");
|
||||||
accumulo.start();
|
accumulo.start();
|
||||||
|
@ -75,7 +77,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +88,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +99,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 1);
|
assertRecordCount(results, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +110,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,41 +121,48 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError.class)
|
@Test
|
||||||
public void testSameRowCfValueInCqErrorCfEnd() throws Exception {
|
public void testSameRowCfValueInCqErrorCfEnd() {
|
||||||
TestRunner runner = createTestEnvironment("2019","2019","family1","",true,"",null);
|
assertThrows(AssertionError.class, () -> {
|
||||||
|
TestRunner runner = createTestEnvironment("2019","2019","family1","",true,"",null);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError.class)
|
@Test
|
||||||
public void testSameRowCfValueInCqErrorCf() throws Exception {
|
public void testSameRowCfValueInCqErrorCf() {
|
||||||
TestRunner runner = createTestEnvironment("2019","2019","","family2",true,"",null);
|
assertThrows(AssertionError.class, () -> {
|
||||||
|
TestRunner runner = createTestEnvironment("2019", "2019", "", "family2", true, "", null);
|
||||||
|
|
||||||
runner.run();
|
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
runner.run();
|
||||||
assertRecordCount(results, 5);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
|
assertRecordCount(results, 5);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError.class)
|
@Test
|
||||||
public void testSameRowCfValueInCqErrorNotLess() throws Exception {
|
public void testSameRowCfValueInCqErrorNotLess() {
|
||||||
TestRunner runner = createTestEnvironment("2019","2019","family1","family1",true,"",null);
|
assertThrows(AssertionError.class, () -> {
|
||||||
|
TestRunner runner = createTestEnvironment("2019", "2019", "family1", "family1", true, "", null);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertRecordCount(results, 5);
|
assertRecordCount(results, 5);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -163,7 +172,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertValueInResult(results, "\"Test\"\n");
|
assertValueInResult(results, "\"Test\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +184,7 @@ public class ScanAccumuloIT {
|
||||||
runner.run();
|
runner.run();
|
||||||
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ScanAccumulo.REL_SUCCESS);
|
||||||
|
|
||||||
Assert.assertEquals("Wrong count, received " + results.size(), 1, results.size());
|
assertEquals(1, results.size(), "Wrong count, received " + results.size());
|
||||||
assertValueInResult(results, "\n");
|
assertValueInResult(results, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,13 +260,13 @@ public class ScanAccumuloIT {
|
||||||
private void assertRecordCount(List<MockFlowFile> results, int expected) {
|
private void assertRecordCount(List<MockFlowFile> results, int expected) {
|
||||||
for (MockFlowFile ff : results){
|
for (MockFlowFile ff : results){
|
||||||
String attr = ff.getAttribute("record.count");
|
String attr = ff.getAttribute("record.count");
|
||||||
Assert.assertEquals(expected, Integer.valueOf(attr).intValue());
|
assertEquals(expected, Integer.valueOf(attr).intValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertValueInResult(List<MockFlowFile> results, String expected) {
|
private void assertValueInResult(List<MockFlowFile> results, String expected) {
|
||||||
for (MockFlowFile ff : results) {
|
for (MockFlowFile ff : results) {
|
||||||
Assert.assertEquals(expected, ff.getContent());
|
assertEquals(expected, ff.getContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ import org.apache.nifi.kerberos.KerberosCredentialsService;
|
||||||
import org.apache.nifi.kerberos.KerberosUserService;
|
import org.apache.nifi.kerberos.KerberosUserService;
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class TestAccumuloService {
|
||||||
@Mock
|
@Mock
|
||||||
private Processor dummyProcessor;
|
private Processor dummyProcessor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
public void init() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.reporting.ReportingContext;
|
import org.apache.nifi.reporting.ReportingContext;
|
||||||
import org.apache.nifi.reporting.ReportingInitializationContext;
|
import org.apache.nifi.reporting.ReportingInitializationContext;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class TestAmbariReportingTask {
|
||||||
|
|
||||||
private ProcessGroupStatus status;
|
private ProcessGroupStatus status;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
status = new ProcessGroupStatus();
|
status = new ProcessGroupStatus();
|
||||||
status.setId("1234");
|
status.setId("1234");
|
||||||
|
|
|
@ -18,8 +18,7 @@ package org.apache.nifi.reporting.ambari.api;
|
||||||
|
|
||||||
import org.apache.nifi.reporting.util.metrics.api.MetricFields;
|
import org.apache.nifi.reporting.util.metrics.api.MetricFields;
|
||||||
import org.apache.nifi.reporting.util.metrics.api.MetricsBuilder;
|
import org.apache.nifi.reporting.util.metrics.api.MetricsBuilder;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonArray;
|
import javax.json.JsonArray;
|
||||||
|
@ -29,6 +28,9 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestMetricsBuilder {
|
public class TestMetricsBuilder {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -55,22 +57,22 @@ public class TestMetricsBuilder {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final JsonArray metricsArray = metricsObject.getJsonArray("metrics");
|
final JsonArray metricsArray = metricsObject.getJsonArray("metrics");
|
||||||
Assert.assertNotNull(metricsArray);
|
assertNotNull(metricsArray);
|
||||||
Assert.assertEquals(2, metricsArray.size());
|
assertEquals(2, metricsArray.size());
|
||||||
|
|
||||||
JsonObject firstMetric = metricsArray.getJsonObject(0);
|
JsonObject firstMetric = metricsArray.getJsonObject(0);
|
||||||
if (!"a".equals(firstMetric.getString(MetricFields.METRIC_NAME))) {
|
if (!"a".equals(firstMetric.getString(MetricFields.METRIC_NAME))) {
|
||||||
firstMetric = metricsArray.getJsonObject(1);
|
firstMetric = metricsArray.getJsonObject(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("a", firstMetric.getString(MetricFields.METRIC_NAME));
|
assertEquals("a", firstMetric.getString(MetricFields.METRIC_NAME));
|
||||||
Assert.assertEquals(applicationId, firstMetric.getString(MetricFields.APP_ID));
|
assertEquals(applicationId, firstMetric.getString(MetricFields.APP_ID));
|
||||||
Assert.assertEquals(instanceId, firstMetric.getString(MetricFields.INSTANCE_ID));
|
assertEquals(instanceId, firstMetric.getString(MetricFields.INSTANCE_ID));
|
||||||
Assert.assertEquals(hostname, firstMetric.getString(MetricFields.HOSTNAME));
|
assertEquals(hostname, firstMetric.getString(MetricFields.HOSTNAME));
|
||||||
Assert.assertEquals(String.valueOf(timestamp), firstMetric.getString(MetricFields.TIMESTAMP));
|
assertEquals(String.valueOf(timestamp), firstMetric.getString(MetricFields.TIMESTAMP));
|
||||||
|
|
||||||
final JsonObject firstMetricValues = firstMetric.getJsonObject("metrics");
|
final JsonObject firstMetricValues = firstMetric.getJsonObject("metrics");
|
||||||
Assert.assertEquals("1", firstMetricValues.getString("" + timestamp));
|
assertEquals("1", firstMetricValues.getString("" + timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,14 @@ import org.apache.nifi.metrics.jvm.JmxJvmMetrics;
|
||||||
import org.apache.nifi.metrics.jvm.JvmMetrics;
|
import org.apache.nifi.metrics.jvm.JvmMetrics;
|
||||||
import org.apache.nifi.reporting.util.metrics.MetricNames;
|
import org.apache.nifi.reporting.util.metrics.MetricNames;
|
||||||
import org.apache.nifi.reporting.util.metrics.MetricsService;
|
import org.apache.nifi.reporting.util.metrics.MetricsService;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestMetricsService {
|
public class TestMetricsService {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -65,17 +66,17 @@ public class TestMetricsService {
|
||||||
|
|
||||||
final Map<String,String> metrics = service.getMetrics(status, false);
|
final Map<String,String> metrics = service.getMetrics(status, false);
|
||||||
|
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
|
assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
|
assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
|
assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
|
assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
|
assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
|
assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
|
assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
|
assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
|
assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
|
assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
|
assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -113,7 +114,7 @@ public class TestMetricsService {
|
||||||
|
|
||||||
final Map<String,String> metrics = service.getMetrics(status, true);
|
final Map<String,String> metrics = service.getMetrics(status, true);
|
||||||
|
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
|
assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -122,17 +123,17 @@ public class TestMetricsService {
|
||||||
final MetricsService service = new MetricsService();
|
final MetricsService service = new MetricsService();
|
||||||
|
|
||||||
final Map<String,String> metrics = service.getMetrics(virtualMachineMetrics);
|
final Map<String,String> metrics = service.getMetrics(virtualMachineMetrics);
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_UPTIME));
|
assertTrue(metrics.containsKey(MetricNames.JVM_UPTIME));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USED));
|
assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USAGE));
|
assertTrue(metrics.containsKey(MetricNames.JVM_HEAP_USAGE));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_NON_HEAP_USAGE));
|
assertTrue(metrics.containsKey(MetricNames.JVM_NON_HEAP_USAGE));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_RUNNABLE));
|
assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_RUNNABLE));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_BLOCKED));
|
assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_BLOCKED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TIMED_WAITING));
|
assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TIMED_WAITING));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TERMINATED));
|
assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_STATES_TERMINATED));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_COUNT));
|
assertTrue(metrics.containsKey(MetricNames.JVM_THREAD_COUNT));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_DAEMON_THREAD_COUNT));
|
assertTrue(metrics.containsKey(MetricNames.JVM_DAEMON_THREAD_COUNT));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.JVM_FILE_DESCRIPTOR_USAGE));
|
assertTrue(metrics.containsKey(MetricNames.JVM_FILE_DESCRIPTOR_USAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.amqp.processors;
|
package org.apache.nifi.amqp.processors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -32,18 +33,18 @@ import java.util.Map;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.apache.nifi.logging.ComponentLog;
|
import org.apache.nifi.logging.ComponentLog;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.rabbitmq.client.AMQP.BasicProperties;
|
import com.rabbitmq.client.AMQP.BasicProperties;
|
||||||
import com.rabbitmq.client.Connection;
|
import com.rabbitmq.client.Connection;
|
||||||
import com.rabbitmq.client.GetResponse;
|
import com.rabbitmq.client.GetResponse;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class AMQPConsumerTest {
|
public class AMQPConsumerTest {
|
||||||
|
|
||||||
private ComponentLog processorLog;
|
private ComponentLog processorLog;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
processorLog = mock(ComponentLog.class);
|
processorLog = mock(ComponentLog.class);
|
||||||
}
|
}
|
||||||
|
@ -77,29 +78,35 @@ public class AMQPConsumerTest {
|
||||||
assertTrue(consumer.closed);
|
assertTrue(consumer.closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void failOnNullConnection() throws IOException {
|
public void failOnNullConnection() {
|
||||||
new AMQPConsumer(null, null, true, processorLog);
|
assertThrows(IllegalArgumentException.class, () -> new AMQPConsumer(null, null, true, processorLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void failOnNullQueueName() throws Exception {
|
public void failOnNullQueueName() {
|
||||||
Connection conn = new TestConnection(null, null);
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new AMQPConsumer(conn, null, true, processorLog);
|
Connection conn = new TestConnection(null, null);
|
||||||
|
new AMQPConsumer(conn, null, true, processorLog);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void failOnEmptyQueueName() throws Exception {
|
public void failOnEmptyQueueName() {
|
||||||
Connection conn = new TestConnection(null, null);
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new AMQPConsumer(conn, " ", true, processorLog);
|
Connection conn = new TestConnection(null, null);
|
||||||
|
new AMQPConsumer(conn, " ", true, processorLog);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test
|
||||||
public void failOnNonExistingQueue() throws Exception {
|
public void failOnNonExistingQueue() {
|
||||||
Connection conn = new TestConnection(null, null);
|
assertThrows(IOException.class, () -> {
|
||||||
try (AMQPConsumer consumer = new AMQPConsumer(conn, "hello", true, processorLog)) {
|
Connection conn = new TestConnection(null, null);
|
||||||
consumer.consume();
|
try (AMQPConsumer consumer = new AMQPConsumer(conn, "hello", true, processorLog)) {
|
||||||
}
|
consumer.consume();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.amqp.processors;
|
package org.apache.nifi.amqp.processors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.atMost;
|
import static org.mockito.Mockito.atMost;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -28,7 +29,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.nifi.logging.ComponentLog;
|
import org.apache.nifi.logging.ComponentLog;
|
||||||
import org.apache.nifi.util.MockComponentLog;
|
import org.apache.nifi.util.MockComponentLog;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import com.rabbitmq.client.AMQP.BasicProperties;
|
import com.rabbitmq.client.AMQP.BasicProperties;
|
||||||
|
@ -38,27 +39,31 @@ import com.rabbitmq.client.ReturnListener;
|
||||||
public class AMQPPublisherTest {
|
public class AMQPPublisherTest {
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void failOnNullConnection() {
|
public void failOnNullConnection() {
|
||||||
new AMQPPublisher(null, null);
|
assertThrows(IllegalArgumentException.class, () -> new AMQPPublisher(null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AMQPRollbackException.class)
|
@Test
|
||||||
public void failPublishIfChannelClosed() throws Exception {
|
public void failPublishIfChannelClosed() {
|
||||||
Connection conn = new TestConnection(null, null);
|
assertThrows(AMQPRollbackException.class, () -> {
|
||||||
try (AMQPPublisher sender = new AMQPPublisher(conn, mock(ComponentLog.class))) {
|
Connection conn = new TestConnection(null, null);
|
||||||
conn.close();
|
try (AMQPPublisher sender = new AMQPPublisher(conn, mock(ComponentLog.class))) {
|
||||||
sender.publish("oleg".getBytes(), null, "foo", "");
|
conn.close();
|
||||||
}
|
sender.publish("oleg".getBytes(), null, "foo", "");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AMQPException.class)
|
@Test
|
||||||
public void failPublishIfChannelFails() throws Exception {
|
public void failPublishIfChannelFails() {
|
||||||
TestConnection conn = new TestConnection(null, null);
|
assertThrows(AMQPException.class, () -> {
|
||||||
try (AMQPPublisher sender = new AMQPPublisher(conn, mock(ComponentLog.class))) {
|
TestConnection conn = new TestConnection(null, null);
|
||||||
((TestChannel) conn.createChannel()).corruptChannel();
|
try (AMQPPublisher sender = new AMQPPublisher(conn, mock(ComponentLog.class))) {
|
||||||
sender.publish("oleg".getBytes(), null, "foo", "");
|
((TestChannel) conn.createChannel()).corruptChannel();
|
||||||
}
|
sender.publish("oleg".getBytes(), null, "foo", "");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.ssl.SSLContextService;
|
import org.apache.nifi.ssl.SSLContextService;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -34,7 +34,7 @@ public class AbstractAMQPProcessorTest {
|
||||||
|
|
||||||
private TestRunner testRunner;
|
private TestRunner testRunner;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
testRunner = TestRunners.newTestRunner(ConsumeAMQP.class);
|
testRunner = TestRunners.newTestRunner(ConsumeAMQP.class);
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.amqp.processors;
|
package org.apache.nifi.amqp.processors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -37,12 +38,11 @@ import org.apache.nifi.processor.exception.ProcessException;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.rabbitmq.client.AMQP;
|
import com.rabbitmq.client.AMQP;
|
||||||
import com.rabbitmq.client.Connection;
|
import com.rabbitmq.client.Connection;
|
||||||
import com.rabbitmq.client.MessageProperties;
|
import com.rabbitmq.client.MessageProperties;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ConsumeAMQPTest {
|
public class ConsumeAMQPTest {
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public class ConsumeAMQPTest {
|
||||||
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
||||||
String headers = successFF.getAttribute("amqp$headers");
|
String headers = successFF.getAttribute("amqp$headers");
|
||||||
Map<String, String> properties = convertStringToMap(headers.substring(1,headers.length()-1),"|");
|
Map<String, String> properties = convertStringToMap(headers.substring(1,headers.length()-1),"|");
|
||||||
Assert.assertEquals(headersMap,properties);
|
assertEquals(headersMap,properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
@ -260,7 +260,7 @@ public class ConsumeAMQPTest {
|
||||||
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
||||||
String headers = successFF.getAttribute("amqp$headers");
|
String headers = successFF.getAttribute("amqp$headers");
|
||||||
Map<String, String> properties = convertStringToMap(headers,"|");
|
Map<String, String> properties = convertStringToMap(headers,"|");
|
||||||
Assert.assertEquals(headersMap,properties);
|
assertEquals(headersMap,properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ public class ConsumeAMQPTest {
|
||||||
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
successFF.assertAttributeEquals("amqp$exchange", "myExchange");
|
||||||
String headers = successFF.getAttribute("amqp$headers");
|
String headers = successFF.getAttribute("amqp$headers");
|
||||||
Map<String, String> properties = convertStringToMap(headers.substring(1,headers.length()-1),",");
|
Map<String, String> properties = convertStringToMap(headers.substring(1,headers.length()-1),",");
|
||||||
Assert.assertEquals(headersMap,properties);
|
assertEquals(headersMap,properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ public class ConsumeAMQPTest {
|
||||||
String[] pairs = map.split(Pattern.quote(String.valueOf(splitCharacter)));
|
String[] pairs = map.split(Pattern.quote(String.valueOf(splitCharacter)));
|
||||||
for (String pair : pairs) {
|
for (String pair : pairs) {
|
||||||
String[] keyValue = pair.split("=", 2);
|
String[] keyValue = pair.split("=", 2);
|
||||||
Assert.assertEquals(2,keyValue.length);
|
assertEquals(2,keyValue.length);
|
||||||
headers.put(keyValue[0].trim(), keyValue[1].trim());
|
headers.put(keyValue[0].trim(), keyValue[1].trim());
|
||||||
}
|
}
|
||||||
return headers;
|
return headers;
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.amqp.processors;
|
package org.apache.nifi.amqp.processors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -33,11 +28,16 @@ import org.apache.nifi.processor.ProcessContext;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import com.rabbitmq.client.Connection;
|
import com.rabbitmq.client.Connection;
|
||||||
import com.rabbitmq.client.GetResponse;
|
import com.rabbitmq.client.GetResponse;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class PublishAMQPTest {
|
public class PublishAMQPTest {
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,16 @@ package org.apache.nifi.jasn1;
|
||||||
import org.apache.nifi.controller.ConfigurationContext;
|
import org.apache.nifi.controller.ConfigurationContext;
|
||||||
import org.apache.nifi.controller.ControllerServiceInitializationContext;
|
import org.apache.nifi.controller.ControllerServiceInitializationContext;
|
||||||
import org.apache.nifi.logging.ComponentLog;
|
import org.apache.nifi.logging.ComponentLog;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import static org.apache.nifi.jasn1.JASN1Reader.ASN_FILES;
|
import static org.apache.nifi.jasn1.JASN1Reader.ASN_FILES;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -41,7 +41,7 @@ public class JASN1ReaderTest {
|
||||||
@Mock
|
@Mock
|
||||||
private ComponentLog logger;
|
private ComponentLog logger;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ public class JASN1ReaderTest {
|
||||||
testSubject.initialize(context);
|
testSubject.initialize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() {
|
||||||
assertTrue(testSubject.asnOutDir.toFile().exists());
|
assertTrue(testSubject.asnOutDir.toFile().exists());
|
||||||
|
|
||||||
testSubject.deleteAsnOutDir();
|
testSubject.deleteAsnOutDir();
|
||||||
|
|
|
@ -22,21 +22,21 @@ import org.apache.nifi.serialization.record.RecordField;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.apache.nifi.serialization.record.type.RecordDataType;
|
import org.apache.nifi.serialization.record.type.RecordDataType;
|
||||||
import org.apache.nifi.util.MockComponentLog;
|
import org.apache.nifi.util.MockComponentLog;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestJASN1RecordReader implements JASN1ReadRecordTester {
|
public class TestJASN1RecordReader implements JASN1ReadRecordTester {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.jasn1", "DEBUG");
|
System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi.jasn1", "DEBUG");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.apache.nifi.serialization.record.type.ArrayDataType;
|
import org.apache.nifi.serialization.record.type.ArrayDataType;
|
||||||
import org.apache.nifi.serialization.record.type.RecordDataType;
|
import org.apache.nifi.serialization.record.type.RecordDataType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.nifi.serialization.SimpleRecordSchema;
|
||||||
import org.apache.nifi.serialization.record.RecordField;
|
import org.apache.nifi.serialization.record.RecordField;
|
||||||
import org.apache.nifi.serialization.record.RecordFieldType;
|
import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
@ -54,8 +54,8 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Depends on generated test classes
|
* Depends on generated test classes
|
||||||
|
|
|
@ -25,12 +25,13 @@ import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.apache.nifi.serialization.record.type.ArrayDataType;
|
import org.apache.nifi.serialization.record.type.ArrayDataType;
|
||||||
import org.apache.nifi.serialization.record.type.RecordDataType;
|
import org.apache.nifi.serialization.record.type.RecordDataType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Depends on generated test classes
|
* Depends on generated test classes
|
||||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.nifi.atlas.security.AtlasAuthN;
|
||||||
import org.apache.nifi.atlas.security.Basic;
|
import org.apache.nifi.atlas.security.Basic;
|
||||||
import org.apache.nifi.context.PropertyContext;
|
import org.apache.nifi.context.PropertyContext;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class ITNiFiAtlasClient {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ITNiFiAtlasClient.class);
|
private static final Logger logger = LoggerFactory.getLogger(ITNiFiAtlasClient.class);
|
||||||
private NiFiAtlasClient atlasClient;
|
private NiFiAtlasClient atlasClient;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
// Add your atlas server ip address into /etc/hosts as atlas.example.com
|
// Add your atlas server ip address into /etc/hosts as atlas.example.com
|
||||||
PropertyContext propertyContext = mock(PropertyContext.class);
|
PropertyContext propertyContext = mock(PropertyContext.class);
|
||||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.nifi.controller.status.PortStatus;
|
||||||
import org.apache.nifi.controller.status.ProcessGroupStatus;
|
import org.apache.nifi.controller.status.ProcessGroupStatus;
|
||||||
import org.apache.nifi.controller.status.ProcessorStatus;
|
import org.apache.nifi.controller.status.ProcessorStatus;
|
||||||
import org.apache.nifi.util.Tuple;
|
import org.apache.nifi.util.Tuple;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -32,7 +32,7 @@ import java.util.function.Function;
|
||||||
import static org.apache.nifi.atlas.AtlasUtils.toQualifiedName;
|
import static org.apache.nifi.atlas.AtlasUtils.toQualifiedName;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {@link NiFiFlowAnalyzer} with simple mock code.
|
* Test {@link NiFiFlowAnalyzer} with simple mock code.
|
||||||
|
@ -42,8 +42,8 @@ public class TestNiFiFlowAnalyzer {
|
||||||
|
|
||||||
private int componentId = 0;
|
private int componentId = 0;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() throws Exception {
|
public void before() {
|
||||||
componentId = 0;
|
componentId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class TestNiFiFlowAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyFlow() throws Exception {
|
public void testEmptyFlow() {
|
||||||
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
||||||
|
|
||||||
final NiFiFlowAnalyzer analyzer = new NiFiFlowAnalyzer();
|
final NiFiFlowAnalyzer analyzer = new NiFiFlowAnalyzer();
|
||||||
|
@ -145,7 +145,7 @@ public class TestNiFiFlowAnalyzer {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProcessorsWithinSinglePath() throws Exception {
|
public void testProcessorsWithinSinglePath() {
|
||||||
|
|
||||||
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ public class TestNiFiFlowAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiPaths() throws Exception {
|
public void testMultiPaths() {
|
||||||
|
|
||||||
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public class TestNiFiFlowAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiPathsJoint() throws Exception {
|
public void testMultiPathsJoint() {
|
||||||
|
|
||||||
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
ProcessGroupStatus rootPG = createEmptyProcessGroupStatus();
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,18 @@
|
||||||
package org.apache.nifi.atlas.hook;
|
package org.apache.nifi.atlas.hook;
|
||||||
|
|
||||||
import org.apache.atlas.model.notification.HookNotification;
|
import org.apache.atlas.model.notification.HookNotification;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class TestNiFiAtlasHook {
|
public class TestNiFiAtlasHook {
|
||||||
|
|
||||||
private NiFiAtlasHook hook;
|
private NiFiAtlasHook hook;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
hook = new NiFiAtlasHook() {
|
hook = new NiFiAtlasHook() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.atlas.v1.model.notification.HookNotificationV1;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.nifi.atlas.AtlasUtils;
|
import org.apache.nifi.atlas.AtlasUtils;
|
||||||
import org.apache.nifi.atlas.NiFiAtlasClient;
|
import org.apache.nifi.atlas.NiFiAtlasClient;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ import static org.apache.nifi.atlas.NiFiTypes.TYPE_DATASET;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_FLOW_PATH;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_FLOW_PATH;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
|
||||||
import static org.apache.nifi.atlas.hook.NiFiAtlasHook.NIFI_USER;
|
import static org.apache.nifi.atlas.hook.NiFiAtlasHook.NIFI_USER;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -114,7 +114,7 @@ public class TestNotificationSender {
|
||||||
assertIOReferences(expect, actual, ATTR_OUTPUTS);
|
assertIOReferences(expect, actual, ATTR_OUTPUTS);
|
||||||
hasFlowPathSeen = true;
|
hasFlowPathSeen = true;
|
||||||
} else {
|
} else {
|
||||||
assertFalse("Types other than nifi_flow_path should be created before any nifi_flow_path entity.", hasFlowPathSeen);
|
assertFalse(hasFlowPathSeen, "Types other than nifi_flow_path should be created before any nifi_flow_path entity.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.nifi.atlas.provenance.analyzer;
|
||||||
|
|
||||||
import org.apache.atlas.v1.model.instance.Referenceable;
|
import org.apache.atlas.v1.model.instance.Referenceable;
|
||||||
import org.apache.nifi.atlas.provenance.DataSetRefs;
|
import org.apache.nifi.atlas.provenance.DataSetRefs;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
|
@ -26,8 +26,8 @@ import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_BUCK
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_OBJECT_PREFIX_V1;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_OBJECT_PREFIX_V1;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_BUCKET_V1;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_BUCKET_V1;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_DIRECTORY_V1;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_DIRECTORY_V1;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestAwsS3DirectoryV1 extends AbstractTestAwsS3Directory {
|
public class TestAwsS3DirectoryV1 extends AbstractTestAwsS3Directory {
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ import org.apache.atlas.utils.AtlasPathExtractorUtil;
|
||||||
import org.apache.atlas.v1.model.instance.Referenceable;
|
import org.apache.atlas.v1.model.instance.Referenceable;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.nifi.atlas.provenance.DataSetRefs;
|
import org.apache.nifi.atlas.provenance.DataSetRefs;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_CONTAINER_V2;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_CONTAINER_V2;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_OBJECT_PREFIX_V2;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.ATTR_OBJECT_PREFIX_V2;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_BUCKET_V2;
|
import static org.apache.nifi.atlas.provenance.analyzer.AwsS3Directory.TYPE_BUCKET_V2;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestAwsS3DirectoryV2 extends AbstractTestAwsS3Directory {
|
public class TestAwsS3DirectoryV2 extends AbstractTestAwsS3Directory {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolver;
|
import org.apache.nifi.atlas.resolver.NamespaceResolver;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
|
@ -35,8 +35,8 @@ import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.ATTR_
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_ACCOUNT;
|
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_ACCOUNT;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_CONTAINER;
|
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_CONTAINER;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_DIRECTORY;
|
import static org.apache.nifi.atlas.provenance.analyzer.AzureADLSDirectory.TYPE_DIRECTORY;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_CLUSTER_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_CLUSTER_NAME;
|
||||||
|
@ -34,7 +34,7 @@ import static org.apache.nifi.atlas.NiFiTypes.ATTR_URI;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.ATTR_NAMESPACE;
|
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.ATTR_NAMESPACE;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.TYPE_HBASE_NAMESPACE;
|
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.TYPE_HBASE_NAMESPACE;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.TYPE_HBASE_TABLE;
|
import static org.apache.nifi.atlas.provenance.analyzer.HBaseTable.TYPE_HBASE_TABLE;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -34,9 +34,9 @@ import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_INPUT_TABLES;
|
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_INPUT_TABLES;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_OUTPUT_TABLES;
|
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_OUTPUT_TABLES;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
|
@ -24,13 +24,13 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.nifi.controller.status.ConnectionStatus;
|
||||||
import org.apache.nifi.flowfile.attributes.SiteToSiteAttributes;
|
import org.apache.nifi.flowfile.attributes.SiteToSiteAttributes;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -37,9 +37,9 @@ import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.controller.status.ConnectionStatus;
|
import org.apache.nifi.controller.status.ConnectionStatus;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -36,9 +36,9 @@ import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
|
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ import org.apache.nifi.atlas.provenance.NiFiProvenanceEventAnalyzerFactory;
|
||||||
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_OUTPUT_TABLES;
|
import static org.apache.nifi.atlas.provenance.analyzer.DatabaseAnalyzerUtil.ATTR_OUTPUT_TABLES;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.nifi.atlas.resolver.NamespaceResolvers;
|
||||||
import org.apache.nifi.controller.status.ConnectionStatus;
|
import org.apache.nifi.controller.status.ConnectionStatus;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -33,9 +33,9 @@ import java.util.List;
|
||||||
|
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
|
||||||
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.mockito.ArgumentMatchers.matches;
|
import static org.mockito.ArgumentMatchers.matches;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ public class TestUnknownDataSet {
|
||||||
assertNotNull(analyzer);
|
assertNotNull(analyzer);
|
||||||
|
|
||||||
final DataSetRefs refs = analyzer.analyze(context, record);
|
final DataSetRefs refs = analyzer.analyze(context, record);
|
||||||
assertNull("If the processor has incoming connections, no refs should be created", refs);
|
assertNull(refs, "If the processor has incoming connections, no refs should be created");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ import org.apache.nifi.util.MockComponentLog;
|
||||||
import org.apache.nifi.util.MockConfigurationContext;
|
import org.apache.nifi.util.MockConfigurationContext;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
@ -487,7 +487,7 @@ public class ITReportLineageToAtlas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void startEmulator() throws Exception {
|
public void startEmulator() throws Exception {
|
||||||
if (useEmbeddedEmulator) {
|
if (useEmbeddedEmulator) {
|
||||||
atlasAPIServer.start();
|
atlasAPIServer.start();
|
||||||
|
@ -503,7 +503,7 @@ public class ITReportLineageToAtlas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void stopEmulator() throws Exception {
|
public void stopEmulator() throws Exception {
|
||||||
if (useEmbeddedEmulator) {
|
if (useEmbeddedEmulator) {
|
||||||
atlasAPIServer.stop();
|
atlasAPIServer.stop();
|
||||||
|
|
|
@ -37,9 +37,9 @@ import org.apache.nifi.util.MockProcessContext;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.apache.nifi.util.MockValidationContext;
|
import org.apache.nifi.util.MockValidationContext;
|
||||||
import org.apache.nifi.util.file.FileUtils;
|
import org.apache.nifi.util.file.FileUtils;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -73,10 +73,11 @@ import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_URLS;
|
||||||
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_USER;
|
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.ATLAS_USER;
|
||||||
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.KAFKA_BOOTSTRAP_SERVERS;
|
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.KAFKA_BOOTSTRAP_SERVERS;
|
||||||
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.SSL_CONTEXT_SERVICE;
|
import static org.apache.nifi.atlas.reporting.ReportLineageToAtlas.SSL_CONTEXT_SERVICE;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -93,7 +94,7 @@ public class TestReportLineageToAtlas {
|
||||||
private ReportingContext reportingContext;
|
private ReportingContext reportingContext;
|
||||||
private String atlasConfDir;
|
private String atlasConfDir;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
testSubject = new ReportLineageToAtlas();
|
testSubject = new ReportLineageToAtlas();
|
||||||
componentLogger = new MockComponentLog("reporting-task-id", testSubject);
|
componentLogger = new MockComponentLog("reporting-task-id", testSubject);
|
||||||
|
@ -104,7 +105,7 @@ public class TestReportLineageToAtlas {
|
||||||
atlasConfDir = createAtlasConfDir();
|
atlasConfDir = createAtlasConfDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
cleanUpAtlasConfDir();
|
cleanUpAtlasConfDir();
|
||||||
}
|
}
|
||||||
|
@ -122,7 +123,7 @@ public class TestReportLineageToAtlas {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateAtlasUrlsFromProperty() throws Exception {
|
public void validateAtlasUrlsFromProperty() {
|
||||||
final MockProcessContext processContext = new MockProcessContext(testSubject);
|
final MockProcessContext processContext = new MockProcessContext(testSubject);
|
||||||
final MockValidationContext validationContext = new MockValidationContext(processContext);
|
final MockValidationContext validationContext = new MockValidationContext(processContext);
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ public class TestReportLineageToAtlas {
|
||||||
// Invalid URL.
|
// Invalid URL.
|
||||||
processContext.setProperty(ATLAS_URLS, "invalid");
|
processContext.setProperty(ATLAS_URLS, "invalid");
|
||||||
assertResults.accept(testSubject.validate(validationContext),
|
assertResults.accept(testSubject.validate(validationContext),
|
||||||
r -> assertTrue("Atlas URLs is invalid", !r.isValid()));
|
r -> assertTrue(!r.isValid(), "Atlas URLs is invalid"));
|
||||||
|
|
||||||
// Valid URL
|
// Valid URL
|
||||||
processContext.setProperty(ATLAS_URLS, "http://atlas.example.com:21000");
|
processContext.setProperty(ATLAS_URLS, "http://atlas.example.com:21000");
|
||||||
|
@ -167,7 +168,7 @@ public class TestReportLineageToAtlas {
|
||||||
// Invalid and Valid URLs
|
// Invalid and Valid URLs
|
||||||
processContext.setProperty(ATLAS_URLS, "invalid, http://atlas2.example.com:21000");
|
processContext.setProperty(ATLAS_URLS, "invalid, http://atlas2.example.com:21000");
|
||||||
assertResults.accept(testSubject.validate(validationContext),
|
assertResults.accept(testSubject.validate(validationContext),
|
||||||
r -> assertTrue("Atlas URLs is invalid", !r.isValid()));
|
r -> assertTrue(!r.isValid(), "Atlas URLs is invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -194,8 +195,8 @@ public class TestReportLineageToAtlas {
|
||||||
atlasConf.setProperty("atlas.rest.address", atlasUrls);
|
atlasConf.setProperty("atlas.rest.address", atlasUrls);
|
||||||
|
|
||||||
Consumer<Exception> assertion = e -> assertTrue(
|
Consumer<Exception> assertion = e -> assertTrue(
|
||||||
"Expected " + MalformedURLException.class.getSimpleName() + " for " + atlasUrls + ", got " + e,
|
e.getCause() instanceof MalformedURLException,
|
||||||
e.getCause() instanceof MalformedURLException
|
"Expected " + MalformedURLException.class.getSimpleName() + " for " + atlasUrls + ", got " + e
|
||||||
);
|
);
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
|
@ -217,7 +218,7 @@ public class TestReportLineageToAtlas {
|
||||||
propertiesAdjustment,
|
propertiesAdjustment,
|
||||||
() -> fail(),
|
() -> fail(),
|
||||||
e -> {
|
e -> {
|
||||||
assertTrue("Expected a " + ProcessException.class.getSimpleName() + ", got " + e, e instanceof ProcessException);
|
assertTrue(e instanceof ProcessException, "Expected a " + ProcessException.class.getSimpleName() + ", got " + e);
|
||||||
exceptionConsumer.accept(e);
|
exceptionConsumer.accept(e);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -496,7 +497,7 @@ public class TestReportLineageToAtlas {
|
||||||
assertFalse(isAsync);
|
assertFalse(isAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ProcessException.class)
|
@Test
|
||||||
public void testThrowExceptionWhenAtlasConfIsProvidedButSynchronousModeHasNotBeenSet() throws Exception {
|
public void testThrowExceptionWhenAtlasConfIsProvidedButSynchronousModeHasNotBeenSet() throws Exception {
|
||||||
Properties atlasConf = new Properties();
|
Properties atlasConf = new Properties();
|
||||||
saveAtlasConf(atlasConf);
|
saveAtlasConf(atlasConf);
|
||||||
|
@ -507,7 +508,7 @@ public class TestReportLineageToAtlas {
|
||||||
ConfigurationContext configurationContext = new MockConfigurationContext(properties, null);
|
ConfigurationContext configurationContext = new MockConfigurationContext(properties, null);
|
||||||
|
|
||||||
testSubject.initialize(initializationContext);
|
testSubject.initialize(initializationContext);
|
||||||
testSubject.setup(configurationContext);
|
assertThrows(ProcessException.class, () -> testSubject.setup(configurationContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAtlasConf(Properties atlasConf) throws IOException {
|
private void saveAtlasConf(Properties atlasConf) throws IOException {
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.apache.nifi.atlas.resolver;
|
||||||
import org.apache.nifi.components.ValidationContext;
|
import org.apache.nifi.components.ValidationContext;
|
||||||
import org.apache.nifi.components.ValidationResult;
|
import org.apache.nifi.components.ValidationResult;
|
||||||
import org.apache.nifi.context.PropertyContext;
|
import org.apache.nifi.context.PropertyContext;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -28,6 +27,9 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TestRegexNamespaceResolver {
|
public class TestRegexNamespaceResolver {
|
||||||
|
@ -49,10 +51,10 @@ public class TestRegexNamespaceResolver {
|
||||||
|
|
||||||
// It should be valid
|
// It should be valid
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(0, validationResults.size());
|
assertEquals(0, validationResults.size());
|
||||||
resolver.configure(context);
|
resolver.configure(context);
|
||||||
|
|
||||||
Assert.assertNull(resolver.fromHostNames("example.com"));
|
assertNull(resolver.fromHostNames("example.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,15 +65,11 @@ public class TestRegexNamespaceResolver {
|
||||||
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
||||||
|
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(1, validationResults.size());
|
assertEquals(1, validationResults.size());
|
||||||
final ValidationResult validationResult = validationResults.iterator().next();
|
final ValidationResult validationResult = validationResults.iterator().next();
|
||||||
Assert.assertEquals(RegexNamespaceResolver.PATTERN_PROPERTY_PREFIX, validationResult.getSubject());
|
assertEquals(RegexNamespaceResolver.PATTERN_PROPERTY_PREFIX, validationResult.getSubject());
|
||||||
|
|
||||||
try {
|
assertThrows(IllegalArgumentException.class, () -> resolver.configure(context));
|
||||||
resolver.configure(context);
|
|
||||||
Assert.fail("Configure method should fail, too");
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -83,15 +81,11 @@ public class TestRegexNamespaceResolver {
|
||||||
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
||||||
|
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(1, validationResults.size());
|
assertEquals(1, validationResults.size());
|
||||||
final ValidationResult validationResult = validationResults.iterator().next();
|
final ValidationResult validationResult = validationResults.iterator().next();
|
||||||
Assert.assertEquals(propertyName, validationResult.getSubject());
|
assertEquals(propertyName, validationResult.getSubject());
|
||||||
|
|
||||||
try {
|
assertThrows(IllegalArgumentException.class, () -> resolver.configure(context));
|
||||||
resolver.configure(context);
|
|
||||||
Assert.fail("Configure method should fail, too");
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -103,11 +97,11 @@ public class TestRegexNamespaceResolver {
|
||||||
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
||||||
|
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(0, validationResults.size());
|
assertEquals(0, validationResults.size());
|
||||||
|
|
||||||
resolver.configure(context);
|
resolver.configure(context);
|
||||||
|
|
||||||
Assert.assertEquals("Namespace1", resolver.fromHostNames("host1.example.com"));
|
assertEquals("Namespace1", resolver.fromHostNames("host1.example.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -120,14 +114,14 @@ public class TestRegexNamespaceResolver {
|
||||||
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
||||||
|
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(0, validationResults.size());
|
assertEquals(0, validationResults.size());
|
||||||
|
|
||||||
resolver.configure(context);
|
resolver.configure(context);
|
||||||
|
|
||||||
Assert.assertEquals("Namespace1", resolver.fromHostNames("host1.example.com"));
|
assertEquals("Namespace1", resolver.fromHostNames("host1.example.com"));
|
||||||
Assert.assertEquals("Namespace1", resolver.fromHostNames("192.168.1.10"));
|
assertEquals("Namespace1", resolver.fromHostNames("192.168.1.10"));
|
||||||
Assert.assertEquals("Namespace1", resolver.fromHostNames("192.168.1.22"));
|
assertEquals("Namespace1", resolver.fromHostNames("192.168.1.22"));
|
||||||
Assert.assertNull(resolver.fromHostNames("192.168.2.30"));
|
assertNull(resolver.fromHostNames("192.168.2.30"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -145,17 +139,17 @@ public class TestRegexNamespaceResolver {
|
||||||
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
final RegexNamespaceResolver resolver = new RegexNamespaceResolver();
|
||||||
|
|
||||||
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
final Collection<ValidationResult> validationResults = resolver.validate(validationContext);
|
||||||
Assert.assertEquals(0, validationResults.size());
|
assertEquals(0, validationResults.size());
|
||||||
|
|
||||||
resolver.configure(context);
|
resolver.configure(context);
|
||||||
|
|
||||||
Assert.assertEquals(namespace1, resolver.fromHostNames("host1.c1.example.com"));
|
assertEquals(namespace1, resolver.fromHostNames("host1.c1.example.com"));
|
||||||
Assert.assertEquals(namespace1, resolver.fromHostNames("192.168.1.10"));
|
assertEquals(namespace1, resolver.fromHostNames("192.168.1.10"));
|
||||||
Assert.assertEquals(namespace1, resolver.fromHostNames("192.168.1.22"));
|
assertEquals(namespace1, resolver.fromHostNames("192.168.1.22"));
|
||||||
Assert.assertEquals(namespace2, resolver.fromHostNames("host2.c2.example.com"));
|
assertEquals(namespace2, resolver.fromHostNames("host2.c2.example.com"));
|
||||||
Assert.assertEquals(namespace2, resolver.fromHostNames("192.168.2.10"));
|
assertEquals(namespace2, resolver.fromHostNames("192.168.2.10"));
|
||||||
Assert.assertEquals(namespace2, resolver.fromHostNames("192.168.2.22"));
|
assertEquals(namespace2, resolver.fromHostNames("192.168.2.22"));
|
||||||
Assert.assertNull(resolver.fromHostNames("192.168.3.30"));
|
assertNull(resolver.fromHostNames("192.168.3.30"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.avro;
|
package org.apache.nifi.processors.avro;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.avro.file.DataFileWriter;
|
import org.apache.avro.file.DataFileWriter;
|
||||||
import org.apache.avro.generic.GenericData;
|
import org.apache.avro.generic.GenericData;
|
||||||
|
@ -30,7 +27,11 @@ import org.apache.avro.io.EncoderFactory;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TestConvertAvroToJSON {
|
public class TestConvertAvroToJSON {
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.avro;
|
package org.apache.nifi.processors.avro;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.avro.file.CodecFactory;
|
import org.apache.avro.file.CodecFactory;
|
||||||
import org.apache.avro.file.DataFileWriter;
|
import org.apache.avro.file.DataFileWriter;
|
||||||
|
@ -30,7 +26,12 @@ import org.apache.avro.io.DatumWriter;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class TestExtractAvroMetadata {
|
public class TestExtractAvroMetadata {
|
||||||
|
|
||||||
|
|
|
@ -16,19 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.avro;
|
package org.apache.nifi.processors.avro;
|
||||||
|
|
||||||
import static org.apache.nifi.flowfile.attributes.FragmentAttributes.FRAGMENT_COUNT;
|
|
||||||
import static org.apache.nifi.flowfile.attributes.FragmentAttributes.FRAGMENT_ID;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.avro.file.DataFileStream;
|
import org.apache.avro.file.DataFileStream;
|
||||||
import org.apache.avro.file.DataFileWriter;
|
import org.apache.avro.file.DataFileWriter;
|
||||||
|
@ -43,9 +30,25 @@ import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import static org.apache.nifi.flowfile.attributes.FragmentAttributes.FRAGMENT_COUNT;
|
||||||
|
import static org.apache.nifi.flowfile.attributes.FragmentAttributes.FRAGMENT_ID;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestSplitAvro {
|
public class TestSplitAvro {
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ public class TestSplitAvro {
|
||||||
private Schema schema;
|
private Schema schema;
|
||||||
private ByteArrayOutputStream users;
|
private ByteArrayOutputStream users;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
this.users = new ByteArrayOutputStream();
|
this.users = new ByteArrayOutputStream();
|
||||||
this.schema = new Schema.Parser().parse(new File("src/test/resources/user.avsc"));
|
this.schema = new Schema.Parser().parse(new File("src/test/resources/user.avsc"));
|
||||||
|
@ -185,9 +188,9 @@ public class TestSplitAvro {
|
||||||
for (final MockFlowFile flowFile : flowFiles) {
|
for (final MockFlowFile flowFile : flowFiles) {
|
||||||
try (final ByteArrayInputStream in = new ByteArrayInputStream(flowFile.toByteArray());
|
try (final ByteArrayInputStream in = new ByteArrayInputStream(flowFile.toByteArray());
|
||||||
final DataFileStream<GenericRecord> reader = new DataFileStream<>(in, new GenericDatumReader<GenericRecord>())) {
|
final DataFileStream<GenericRecord> reader = new DataFileStream<>(in, new GenericDatumReader<GenericRecord>())) {
|
||||||
Assert.assertFalse(reader.getMetaKeys().contains(META_KEY1));
|
assertFalse(reader.getMetaKeys().contains(META_KEY1));
|
||||||
Assert.assertFalse(reader.getMetaKeys().contains(META_KEY2));
|
assertFalse(reader.getMetaKeys().contains(META_KEY2));
|
||||||
Assert.assertFalse(reader.getMetaKeys().contains(META_KEY3));
|
assertFalse(reader.getMetaKeys().contains(META_KEY3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,9 +252,9 @@ public class TestSplitAvro {
|
||||||
checkBareRecordsSplitSize(flowFiles, 20, false);
|
checkBareRecordsSplitSize(flowFiles, 20, false);
|
||||||
|
|
||||||
for (final MockFlowFile flowFile : flowFiles) {
|
for (final MockFlowFile flowFile : flowFiles) {
|
||||||
Assert.assertFalse(flowFile.getAttributes().containsKey(META_KEY1));
|
assertFalse(flowFile.getAttributes().containsKey(META_KEY1));
|
||||||
Assert.assertFalse(flowFile.getAttributes().containsKey(META_KEY2));
|
assertFalse(flowFile.getAttributes().containsKey(META_KEY2));
|
||||||
Assert.assertFalse(flowFile.getAttributes().containsKey(META_KEY3));
|
assertFalse(flowFile.getAttributes().containsKey(META_KEY3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,8 +281,8 @@ public class TestSplitAvro {
|
||||||
GenericRecord record = reader.read(null, decoder);
|
GenericRecord record = reader.read(null, decoder);
|
||||||
try {
|
try {
|
||||||
while (record != null) {
|
while (record != null) {
|
||||||
Assert.assertNotNull(record.get("name"));
|
assertNotNull(record.get("name"));
|
||||||
Assert.assertNotNull(record.get("favorite_number"));
|
assertNotNull(record.get("favorite_number"));
|
||||||
count++;
|
count++;
|
||||||
record = reader.read(record, decoder);
|
record = reader.read(record, decoder);
|
||||||
}
|
}
|
||||||
|
@ -290,9 +293,9 @@ public class TestSplitAvro {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkMetadata) {
|
if (checkMetadata) {
|
||||||
Assert.assertTrue(flowFile.getAttributes().containsKey(META_KEY1));
|
assertTrue(flowFile.getAttributes().containsKey(META_KEY1));
|
||||||
Assert.assertTrue(flowFile.getAttributes().containsKey(META_KEY2));
|
assertTrue(flowFile.getAttributes().containsKey(META_KEY2));
|
||||||
Assert.assertTrue(flowFile.getAttributes().containsKey(META_KEY3));
|
assertTrue(flowFile.getAttributes().containsKey(META_KEY3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,8 +309,8 @@ public class TestSplitAvro {
|
||||||
GenericRecord record = null;
|
GenericRecord record = null;
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
record = reader.next(record);
|
record = reader.next(record);
|
||||||
Assert.assertNotNull(record.get("name"));
|
assertNotNull(record.get("name"));
|
||||||
Assert.assertNotNull(record.get("favorite_number"));
|
assertNotNull(record.get("favorite_number"));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assertEquals(expectedRecordsPerSplit, count);
|
assertEquals(expectedRecordsPerSplit, count);
|
||||||
|
@ -330,8 +333,8 @@ public class TestSplitAvro {
|
||||||
GenericRecord record = null;
|
GenericRecord record = null;
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
record = reader.next(record);
|
record = reader.next(record);
|
||||||
Assert.assertNotNull(record.get("name"));
|
assertNotNull(record.get("name"));
|
||||||
Assert.assertNotNull(record.get("favorite_number"));
|
assertNotNull(record.get("favorite_number"));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws;
|
package org.apache.nifi.processors.aws;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
|
||||||
import org.apache.nifi.processor.ProcessSession;
|
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
import com.amazonaws.ClientConfiguration;
|
||||||
import com.amazonaws.auth.AWSCredentials;
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
|
@ -35,12 +24,21 @@ import com.amazonaws.auth.BasicAWSCredentials;
|
||||||
import com.amazonaws.auth.PropertiesCredentials;
|
import com.amazonaws.auth.PropertiesCredentials;
|
||||||
import com.amazonaws.internal.StaticCredentialsProvider;
|
import com.amazonaws.internal.StaticCredentialsProvider;
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
|
import org.apache.nifi.processor.ProcessContext;
|
||||||
|
import org.apache.nifi.processor.ProcessSession;
|
||||||
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.junit.Before;
|
import java.util.Arrays;
|
||||||
import org.junit.Test;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +53,7 @@ public class TestAWSCredentials {
|
||||||
private AWSCredentialsProvider awsCredentialsProvider = null;
|
private AWSCredentialsProvider awsCredentialsProvider = null;
|
||||||
private ClientConfiguration clientConfiguration = null;
|
private ClientConfiguration clientConfiguration = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockAwsProcessor = new AbstractAWSCredentialsProviderProcessor<AmazonS3Client>() {
|
mockAwsProcessor = new AbstractAWSCredentialsProviderProcessor<AmazonS3Client>() {
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.cloudwatch;
|
package org.apache.nifi.processors.aws.cloudwatch;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
import org.apache.nifi.processors.aws.sns.PutSNS;
|
import org.apache.nifi.processors.aws.sns.PutSNS;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides integration level testing with actual AWS CloudWatch resources for {@link PutCloudWatchMetric} and requires additional configuration and resources to work.
|
* Provides integration level testing with actual AWS CloudWatch resources for {@link PutCloudWatchMetric} and requires additional configuration and resources to work.
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.cloudwatch;
|
package org.apache.nifi.processors.aws.cloudwatch;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonClientException;
|
import com.amazonaws.AmazonClientException;
|
||||||
import com.amazonaws.services.cloudwatch.model.MetricDatum;
|
import com.amazonaws.services.cloudwatch.model.MetricDatum;
|
||||||
import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest;
|
import com.amazonaws.services.cloudwatch.model.PutMetricDataRequest;
|
||||||
import com.amazonaws.services.cloudwatch.model.PutMetricDataResult;
|
import com.amazonaws.services.cloudwatch.model.PutMetricDataResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple mock {@link PutCloudWatchMetric} processor for testing.
|
* Simple mock {@link PutCloudWatchMetric} processor for testing.
|
||||||
|
|
|
@ -16,20 +16,20 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.cloudwatch;
|
package org.apache.nifi.processors.aws.cloudwatch;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.services.cloudwatch.model.Dimension;
|
import com.amazonaws.services.cloudwatch.model.Dimension;
|
||||||
import com.amazonaws.services.cloudwatch.model.InvalidParameterValueException;
|
import com.amazonaws.services.cloudwatch.model.InvalidParameterValueException;
|
||||||
import com.amazonaws.services.cloudwatch.model.MetricDatum;
|
import com.amazonaws.services.cloudwatch.model.MetricDatum;
|
||||||
import org.junit.Test;
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
import org.junit.Assert;
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link PutCloudWatchMetric}.
|
* Unit tests for {@link PutCloudWatchMetric}.
|
||||||
|
@ -52,11 +52,11 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
||||||
Assert.assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
Assert.assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
||||||
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
||||||
Assert.assertEquals("TestMetric", datum.getMetricName());
|
assertEquals("TestMetric", datum.getMetricName());
|
||||||
Assert.assertEquals(1d, datum.getValue(), 0.0001d);
|
assertEquals(1d, datum.getValue(), 0.0001d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -143,11 +143,11 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
||||||
Assert.assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
Assert.assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
||||||
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
||||||
Assert.assertEquals("TestMetric", datum.getMetricName());
|
assertEquals("TestMetric", datum.getMetricName());
|
||||||
Assert.assertEquals(1.23d, datum.getValue(), 0.0001d);
|
assertEquals(1.23d, datum.getValue(), 0.0001d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -172,14 +172,14 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
||||||
Assert.assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
Assert.assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
||||||
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
||||||
Assert.assertEquals("TestMetric", datum.getMetricName());
|
assertEquals("TestMetric", datum.getMetricName());
|
||||||
Assert.assertEquals(1.0d, datum.getStatisticValues().getMinimum(), 0.0001d);
|
assertEquals(1.0d, datum.getStatisticValues().getMinimum(), 0.0001d);
|
||||||
Assert.assertEquals(2.0d, datum.getStatisticValues().getMaximum(), 0.0001d);
|
assertEquals(2.0d, datum.getStatisticValues().getMaximum(), 0.0001d);
|
||||||
Assert.assertEquals(3.0d, datum.getStatisticValues().getSum(), 0.0001d);
|
assertEquals(3.0d, datum.getStatisticValues().getSum(), 0.0001d);
|
||||||
Assert.assertEquals(2.0d, datum.getStatisticValues().getSampleCount(), 0.0001d);
|
assertEquals(2.0d, datum.getStatisticValues().getSampleCount(), 0.0001d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -202,19 +202,19 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_SUCCESS, 1);
|
||||||
Assert.assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
Assert.assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
assertEquals("TestNamespace", mockPutCloudWatchMetric.actualNamespace);
|
||||||
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
MetricDatum datum = mockPutCloudWatchMetric.actualMetricData.get(0);
|
||||||
Assert.assertEquals("TestMetric", datum.getMetricName());
|
assertEquals("TestMetric", datum.getMetricName());
|
||||||
Assert.assertEquals(1d, datum.getValue(), 0.0001d);
|
assertEquals(1d, datum.getValue(), 0.0001d);
|
||||||
|
|
||||||
List<Dimension> dimensions = datum.getDimensions();
|
List<Dimension> dimensions = datum.getDimensions();
|
||||||
Collections.sort(dimensions, (d1, d2) -> d1.getName().compareTo(d2.getName()));
|
Collections.sort(dimensions, (d1, d2) -> d1.getName().compareTo(d2.getName()));
|
||||||
Assert.assertEquals(2, dimensions.size());
|
assertEquals(2, dimensions.size());
|
||||||
Assert.assertEquals("dim1", dimensions.get(0).getName());
|
assertEquals("dim1", dimensions.get(0).getName());
|
||||||
Assert.assertEquals("1", dimensions.get(0).getValue());
|
assertEquals("1", dimensions.get(0).getValue());
|
||||||
Assert.assertEquals("dim2", dimensions.get(1).getName());
|
assertEquals("dim2", dimensions.get(1).getName());
|
||||||
Assert.assertEquals("val2", dimensions.get(1).getValue());
|
assertEquals("val2", dimensions.get(1).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -264,7 +264,7 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.enqueue(new byte[] {}, attributes);
|
runner.enqueue(new byte[] {}, attributes);
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
Assert.assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.enqueue(new byte[] {});
|
runner.enqueue(new byte[] {});
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
Assert.assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(1, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public class TestPutCloudWatchMetric {
|
||||||
runner.enqueue(new byte[] {}, attributes);
|
runner.enqueue(new byte[] {}, attributes);
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
Assert.assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
|
assertEquals(0, mockPutCloudWatchMetric.putMetricDataCallCount);
|
||||||
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutCloudWatchMetric.REL_FAILURE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,33 +16,31 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.credentials.provider.factory;
|
package org.apache.nifi.processors.aws.credentials.provider.factory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
import com.amazonaws.ClientConfiguration;
|
||||||
import com.amazonaws.auth.AWSCredentials;
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
import org.apache.nifi.components.ValidationContext;
|
import org.apache.nifi.components.ValidationContext;
|
||||||
import org.apache.nifi.components.ValidationResult;
|
import org.apache.nifi.components.ValidationResult;
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
import org.apache.nifi.processor.ProcessContext;
|
||||||
import org.apache.nifi.processor.ProcessSession;
|
import org.apache.nifi.processor.ProcessSession;
|
||||||
|
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
||||||
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.USE_DEFAULT_CREDENTIALS;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_ARN;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_EXTERNAL_ID;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_NAME;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_PROXY_HOST;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_PROXY_PORT;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_STS_ENDPOINT;
|
||||||
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.MAX_SESSION_TIME;
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.PROFILE_NAME;
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.PROFILE_NAME;
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.USE_ANONYMOUS_CREDENTIALS;
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.USE_ANONYMOUS_CREDENTIALS;
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_ARN;
|
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.USE_DEFAULT_CREDENTIALS;
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_PROXY_PORT;
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_PROXY_HOST;
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_NAME;
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.MAX_SESSION_TIME;
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_EXTERNAL_ID;
|
|
||||||
import static org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors.ASSUME_ROLE_STS_ENDPOINT;
|
|
||||||
|
|
||||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,25 +16,24 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.credentials.provider.factory;
|
package org.apache.nifi.processors.aws.credentials.provider.factory;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.auth.AnonymousAWSCredentials;
|
|
||||||
import com.amazonaws.auth.AWSCredentials;
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
|
import com.amazonaws.auth.AnonymousAWSCredentials;
|
||||||
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
||||||
import com.amazonaws.auth.PropertiesFileCredentialsProvider;
|
import com.amazonaws.auth.PropertiesFileCredentialsProvider;
|
||||||
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
|
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
|
||||||
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
|
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
|
||||||
import com.amazonaws.internal.StaticCredentialsProvider;
|
import com.amazonaws.internal.StaticCredentialsProvider;
|
||||||
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
|
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import java.util.Map;
|
||||||
import org.junit.Test;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests of the validation and credentials provider capabilities of CredentialsProviderFactory.
|
* Tests of the validation and credentials provider capabilities of CredentialsProviderFactory.
|
||||||
|
@ -49,9 +48,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", DefaultAWSCredentialsProviderChain.class,
|
assertEquals(DefaultAWSCredentialsProviderChain.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,9 +62,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", DefaultAWSCredentialsProviderChain.class,
|
assertEquals(DefaultAWSCredentialsProviderChain.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -87,9 +86,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", StaticCredentialsProvider.class,
|
assertEquals(StaticCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -115,9 +114,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", PropertiesFileCredentialsProvider.class,
|
assertEquals(PropertiesFileCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -131,9 +130,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", STSAssumeRoleSessionCredentialsProvider.class,
|
assertEquals(STSAssumeRoleSessionCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -179,9 +178,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
final AWSCredentials creds = credentialsProvider.getCredentials();
|
final AWSCredentials creds = credentialsProvider.getCredentials();
|
||||||
assertEquals("credentials should be equal", AnonymousAWSCredentials.class, creds.getClass());
|
assertEquals(AnonymousAWSCredentials.class, creds.getClass(), "credentials should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -202,9 +201,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", ProfileCredentialsProvider.class,
|
assertEquals(ProfileCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -220,9 +219,9 @@ public class TestCredentialsProviderFactory {
|
||||||
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
|
||||||
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
|
||||||
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", STSAssumeRoleSessionCredentialsProvider.class,
|
assertEquals(STSAssumeRoleSessionCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -16,21 +16,20 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.credentials.provider.service;
|
package org.apache.nifi.processors.aws.credentials.provider.service;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors;
|
|
||||||
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
||||||
import com.amazonaws.auth.PropertiesFileCredentialsProvider;
|
import com.amazonaws.auth.PropertiesFileCredentialsProvider;
|
||||||
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
|
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
|
||||||
import com.amazonaws.internal.StaticCredentialsProvider;
|
import com.amazonaws.internal.StaticCredentialsProvider;
|
||||||
|
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
|
import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors;
|
||||||
|
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class AWSCredentialsProviderControllerServiceTest {
|
public class AWSCredentialsProviderControllerServiceTest {
|
||||||
|
|
||||||
|
@ -45,11 +44,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", DefaultAWSCredentialsProviderChain.class,
|
assertEquals(DefaultAWSCredentialsProviderChain.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -64,11 +63,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", StaticCredentialsProvider.class,
|
assertEquals(StaticCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -85,11 +84,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", STSAssumeRoleSessionCredentialsProvider.class,
|
assertEquals(STSAssumeRoleSessionCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,11 +106,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", STSAssumeRoleSessionCredentialsProvider.class,
|
assertEquals(STSAssumeRoleSessionCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -208,11 +207,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", STSAssumeRoleSessionCredentialsProvider.class,
|
assertEquals(STSAssumeRoleSessionCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -227,11 +226,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
runner.assertValid(serviceImpl);
|
runner.assertValid(serviceImpl);
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
Assert.assertNotNull(service);
|
assertNotNull(service);
|
||||||
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
final AWSCredentialsProvider credentialsProvider = service.getCredentialsProvider();
|
||||||
Assert.assertNotNull(credentialsProvider);
|
assertNotNull(credentialsProvider);
|
||||||
assertEquals("credentials provider should be equal", PropertiesFileCredentialsProvider.class,
|
assertEquals(PropertiesFileCredentialsProvider.class,
|
||||||
credentialsProvider.getClass());
|
credentialsProvider.getClass(), "credentials provider should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -316,9 +315,11 @@ public class AWSCredentialsProviderControllerServiceTest {
|
||||||
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
final AWSCredentialsProviderService service = (AWSCredentialsProviderService) runner.getProcessContext()
|
||||||
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
.getControllerServiceLookup().getControllerService("awsCredentialsProvider");
|
||||||
|
|
||||||
assertEquals("Expression language should be supported for " + CredentialPropertyDescriptors.ACCESS_KEY.getName(),
|
assertEquals(
|
||||||
"awsAccessKey", service.getCredentialsProvider().getCredentials().getAWSAccessKeyId());
|
"awsAccessKey", service.getCredentialsProvider().getCredentials().getAWSAccessKeyId(),
|
||||||
assertEquals("Expression language should be supported for " + CredentialPropertyDescriptors.SECRET_KEY.getName(),
|
"Expression language should be supported for " + CredentialPropertyDescriptors.ACCESS_KEY.getName());
|
||||||
"awsSecretKey", service.getCredentialsProvider().getCredentials().getAWSSecretKey());
|
assertEquals(
|
||||||
|
"awsSecretKey", service.getCredentialsProvider().getCredentials().getAWSSecretKey(),
|
||||||
|
"Expression language should be supported for " + CredentialPropertyDescriptors.SECRET_KEY.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,22 +20,22 @@ import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class AWSProcessorProxyTest {
|
public class AWSProcessorProxyTest {
|
||||||
|
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void testSetup() throws Throwable {
|
public void testSetup() throws Throwable {
|
||||||
runner = TestRunners.newTestRunner(FetchS3Object.class);
|
runner = TestRunners.newTestRunner(FetchS3Object.class);
|
||||||
runner.setProperty(FetchS3Object.BUCKET, "bucket");
|
runner.setProperty(FetchS3Object.BUCKET, "bucket");
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void testTearDown() throws Throwable {
|
public void testTearDown() throws Throwable {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,24 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.dynamodb;
|
package org.apache.nifi.processors.aws.dynamodb;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentMatchers;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonClientException;
|
import com.amazonaws.AmazonClientException;
|
||||||
import com.amazonaws.AmazonServiceException;
|
import com.amazonaws.AmazonServiceException;
|
||||||
import com.amazonaws.regions.Regions;
|
import com.amazonaws.regions.Regions;
|
||||||
|
@ -44,6 +26,23 @@ import com.amazonaws.services.dynamodbv2.model.AttributeValue;
|
||||||
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult;
|
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult;
|
||||||
import com.amazonaws.services.dynamodbv2.model.DeleteRequest;
|
import com.amazonaws.services.dynamodbv2.model.DeleteRequest;
|
||||||
import com.amazonaws.services.dynamodbv2.model.WriteRequest;
|
import com.amazonaws.services.dynamodbv2.model.WriteRequest;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
||||||
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class DeleteDynamoDBTest extends AbstractDynamoDBTest {
|
public class DeleteDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class DeleteDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
protected BatchWriteItemResult result = new BatchWriteItemResult();
|
protected BatchWriteItemResult result = new BatchWriteItemResult();
|
||||||
BatchWriteItemOutcome outcome;
|
BatchWriteItemOutcome outcome;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
outcome = new BatchWriteItemOutcome(result);
|
outcome = new BatchWriteItemOutcome(result);
|
||||||
result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>());
|
result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>());
|
||||||
|
@ -379,6 +378,5 @@ public class DeleteDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
for (MockFlowFile flowFile : flowFiles) {
|
||||||
assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE));
|
assertEquals("runtimeException", flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_EXCEPTION_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,31 +27,33 @@ import com.amazonaws.services.dynamodbv2.model.AttributeValue;
|
||||||
import com.amazonaws.services.dynamodbv2.model.BatchGetItemResult;
|
import com.amazonaws.services.dynamodbv2.model.BatchGetItemResult;
|
||||||
import com.amazonaws.services.dynamodbv2.model.KeysAndAttributes;
|
import com.amazonaws.services.dynamodbv2.model.KeysAndAttributes;
|
||||||
import org.apache.nifi.components.ConfigVerificationResult;
|
import org.apache.nifi.components.ConfigVerificationResult;
|
||||||
import org.apache.nifi.components.ConfigVerificationResult.Outcome;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
import org.apache.nifi.processor.ProcessContext;
|
||||||
import org.apache.nifi.processor.VerifiableProcessor;
|
import org.apache.nifi.processor.VerifiableProcessor;
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.apache.nifi.components.ConfigVerificationResult.Outcome.FAILED;
|
||||||
|
import static org.apache.nifi.components.ConfigVerificationResult.Outcome.SUCCESSFUL;
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class GetDynamoDBTest extends AbstractDynamoDBTest {
|
public class GetDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
protected GetDynamoDB getDynamoDB;
|
protected GetDynamoDB getDynamoDB;
|
||||||
|
@ -59,7 +61,7 @@ public class GetDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
protected BatchGetItemResult result = new BatchGetItemResult();
|
protected BatchGetItemResult result = new BatchGetItemResult();
|
||||||
private HashMap unprocessed;
|
private HashMap unprocessed;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
outcome = new BatchGetItemOutcome(result);
|
outcome = new BatchGetItemOutcome(result);
|
||||||
KeysAndAttributes kaa = new KeysAndAttributes();
|
KeysAndAttributes kaa = new KeysAndAttributes();
|
||||||
|
@ -78,12 +80,10 @@ public class GetDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
result.withResponses(responses);
|
result.withResponses(responses);
|
||||||
|
|
||||||
final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) {
|
final DynamoDB mockDynamoDB = new DynamoDB(Regions.AP_NORTHEAST_1) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) {
|
public BatchGetItemOutcome batchGetItem(TableKeysAndAttributes... tableKeysAndAttributes) {
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
getDynamoDB = mockDynamoDB(mockDynamoDB);
|
getDynamoDB = mockDynamoDB(mockDynamoDB);
|
||||||
|
@ -545,16 +545,16 @@ public class GetDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
final List<ConfigVerificationResult> results = ((VerifiableProcessor) runner.getProcessor())
|
final List<ConfigVerificationResult> results = ((VerifiableProcessor) runner.getProcessor())
|
||||||
.verify(runner.getProcessContext(), runner.getLogger(), Collections.emptyMap());
|
.verify(runner.getProcessContext(), runner.getLogger(), Collections.emptyMap());
|
||||||
assertEquals(3, results.size());
|
assertEquals(3, results.size());
|
||||||
assertEquals(Outcome.SUCCESSFUL, results.get(0).getOutcome());
|
assertEquals(SUCCESSFUL, results.get(0).getOutcome());
|
||||||
assertEquals(Outcome.SUCCESSFUL, results.get(1).getOutcome());
|
assertEquals(SUCCESSFUL, results.get(1).getOutcome());
|
||||||
assertEquals(Outcome.FAILED, results.get(2).getOutcome());
|
assertEquals(FAILED, results.get(2).getOutcome());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertVerificationResults(final TestRunner runner, final int expectedTotalCount, final int expectedJsonDocumentCount) {
|
private void assertVerificationResults(final TestRunner runner, final int expectedTotalCount, final int expectedJsonDocumentCount) {
|
||||||
final List<ConfigVerificationResult> results = ((VerifiableProcessor) runner.getProcessor())
|
final List<ConfigVerificationResult> results = ((VerifiableProcessor) runner.getProcessor())
|
||||||
.verify(runner.getProcessContext(), runner.getLogger(), Collections.emptyMap());
|
.verify(runner.getProcessContext(), runner.getLogger(), Collections.emptyMap());
|
||||||
assertEquals(3, results.size());
|
assertEquals(3, results.size());
|
||||||
results.forEach(result -> assertEquals(Outcome.SUCCESSFUL, result.getOutcome()));
|
results.forEach(result -> assertEquals(SUCCESSFUL, result.getOutcome()));
|
||||||
assertTrue(results.get(2).getExplanation().contains("retrieved " + expectedTotalCount + " items"));
|
assertTrue(results.get(2).getExplanation().contains("retrieved " + expectedTotalCount + " items"));
|
||||||
assertTrue(results.get(2).getExplanation().contains(expectedJsonDocumentCount + " JSON"));
|
assertTrue(results.get(2).getExplanation().contains(expectedJsonDocumentCount + " JSON"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.dynamodb;
|
package org.apache.nifi.processors.aws.dynamodb;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.apache.nifi.flowfile.FlowFile;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
|
|
||||||
import com.amazonaws.auth.PropertiesCredentials;
|
import com.amazonaws.auth.PropertiesCredentials;
|
||||||
import com.amazonaws.regions.Region;
|
import com.amazonaws.regions.Region;
|
||||||
import com.amazonaws.regions.Regions;
|
import com.amazonaws.regions.Regions;
|
||||||
|
@ -37,6 +28,14 @@ import com.amazonaws.services.dynamodbv2.model.DeleteTableResult;
|
||||||
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
|
import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
|
||||||
import com.amazonaws.services.dynamodbv2.model.KeyType;
|
import com.amazonaws.services.dynamodbv2.model.KeyType;
|
||||||
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
|
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
|
||||||
|
import org.apache.nifi.flowfile.FlowFile;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class ITAbstractDynamoDBTest {
|
public class ITAbstractDynamoDBTest {
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ public class ITAbstractDynamoDBTest {
|
||||||
protected static String numberHashOnlyTableName = "NumberHashOnlyTable";
|
protected static String numberHashOnlyTableName = "NumberHashOnlyTable";
|
||||||
protected final static String REGION = "us-west-2";
|
protected final static String REGION = "us-west-2";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
|
FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
|
||||||
final PropertiesCredentials credentials = new PropertiesCredentials(fis);
|
final PropertiesCredentials credentials = new PropertiesCredentials(fis);
|
||||||
|
@ -128,7 +127,7 @@ public class ITAbstractDynamoDBTest {
|
||||||
assertNotNull(flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_RETRYABLE));
|
assertNotNull(flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_ERROR_RETRYABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void afterClass() {
|
public static void afterClass() {
|
||||||
DeleteTableResult result = amazonDynamoDBClient.deleteTable(stringHashStringRangeTableName);
|
DeleteTableResult result = amazonDynamoDBClient.deleteTable(stringHashStringRangeTableName);
|
||||||
result = amazonDynamoDBClient.deleteTable(numberHashNumberRangeTableName);
|
result = amazonDynamoDBClient.deleteTable(numberHashNumberRangeTableName);
|
||||||
|
|
|
@ -1,435 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.nifi.processors.aws.dynamodb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.components.ConfigVerificationResult;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
public class ITPutGetDeleteGetDynamoDBTest extends ITAbstractDynamoDBTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringHashStringRangePutGetDeleteGetSuccess() {
|
|
||||||
final TestRunner putRunner = TestRunners.newTestRunner(PutDynamoDB.class);
|
|
||||||
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.REGION, REGION);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
String document = "{\"name\":\"john\"}";
|
|
||||||
putRunner.enqueue(document.getBytes());
|
|
||||||
|
|
||||||
putRunner.run(1);
|
|
||||||
|
|
||||||
putRunner.assertAllFlowFilesTransferred(AbstractWriteDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractWriteDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner getRunner = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunner.run(1);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final GetDynamoDB getDynamoDB = (GetDynamoDB) getRunner.getProcessor();
|
|
||||||
final List<ConfigVerificationResult> results = getDynamoDB.verify(getRunner.getProcessContext(), getRunner.getLogger(), Collections.emptyMap());
|
|
||||||
assertEquals(2, results.size());
|
|
||||||
assertEquals("Successfully retrieved 1 items, including 1 JSON documents, from DynamoDB", results.get(1).getExplanation());
|
|
||||||
|
|
||||||
final TestRunner deleteRunner = TestRunners.newTestRunner(DeleteDynamoDB.class);
|
|
||||||
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.REGION, REGION);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.TABLE, stringHashStringRangeTableName);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_NAME, "hashS");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.RANGE_KEY_NAME, "rangeS");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_VALUE, "h1");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.RANGE_KEY_VALUE, "r1");
|
|
||||||
deleteRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
deleteRunner.run(1);
|
|
||||||
|
|
||||||
deleteRunner.assertAllFlowFilesTransferred(DeleteDynamoDB.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = deleteRunner.getFlowFilesForRelationship(DeleteDynamoDB.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals("", new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final check after delete
|
|
||||||
final TestRunner getRunnerAfterDelete = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunnerAfterDelete.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunnerAfterDelete.run(1);
|
|
||||||
getRunnerAfterDelete.assertAllFlowFilesTransferred(GetDynamoDB.REL_NOT_FOUND, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunnerAfterDelete.getFlowFilesForRelationship(GetDynamoDB.REL_NOT_FOUND);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
String error = flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND);
|
|
||||||
assertTrue(error.startsWith(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringHashStringRangePutDeleteWithHashOnlyFailure() {
|
|
||||||
final TestRunner putRunner = TestRunners.newTestRunner(PutDynamoDB.class);
|
|
||||||
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.REGION, REGION);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
String document = "{\"name\":\"john\"}";
|
|
||||||
putRunner.enqueue(document.getBytes());
|
|
||||||
|
|
||||||
putRunner.run(1);
|
|
||||||
|
|
||||||
putRunner.assertAllFlowFilesTransferred(AbstractWriteDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractWriteDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner getRunner = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunner.run(1);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner deleteRunner = TestRunners.newTestRunner(DeleteDynamoDB.class);
|
|
||||||
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.REGION, REGION);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.TABLE, stringHashStringRangeTableName);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_NAME, "hashS");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_VALUE, "h1");
|
|
||||||
deleteRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
deleteRunner.run(1);
|
|
||||||
|
|
||||||
deleteRunner.assertAllFlowFilesTransferred(DeleteDynamoDB.REL_FAILURE, 1);
|
|
||||||
|
|
||||||
flowFiles = deleteRunner.getFlowFilesForRelationship(DeleteDynamoDB.REL_FAILURE);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
validateServiceExceptionAttribute(flowFile);
|
|
||||||
assertEquals("", new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringHashStringRangePutGetWithHashOnlyKeyFailure() {
|
|
||||||
final TestRunner putRunner = TestRunners.newTestRunner(PutDynamoDB.class);
|
|
||||||
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.REGION, REGION);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_NAME, "rangeS");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE, "r1");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
String document = "{\"name\":\"john\"}";
|
|
||||||
putRunner.enqueue(document.getBytes());
|
|
||||||
|
|
||||||
putRunner.run(1);
|
|
||||||
|
|
||||||
putRunner.assertAllFlowFilesTransferred(AbstractWriteDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractWriteDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner getRunner = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, stringHashStringRangeTableName);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashS");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "h1");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunner.run(1);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_FAILURE, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_FAILURE);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
validateServiceExceptionAttribute(flowFile);
|
|
||||||
assertEquals("", new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNumberHashOnlyPutGetDeleteGetSuccess() {
|
|
||||||
final TestRunner putRunner = TestRunners.newTestRunner(PutDynamoDB.class);
|
|
||||||
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.REGION, REGION);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.TABLE, numberHashOnlyTableName);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
String document = "{\"age\":40}";
|
|
||||||
putRunner.enqueue(document.getBytes());
|
|
||||||
|
|
||||||
putRunner.run(1);
|
|
||||||
|
|
||||||
putRunner.assertAllFlowFilesTransferred(AbstractWriteDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractWriteDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner getRunner = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, numberHashOnlyTableName);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunner.run(1);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner deleteRunner = TestRunners.newTestRunner(DeleteDynamoDB.class);
|
|
||||||
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.REGION, REGION);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.TABLE, numberHashOnlyTableName);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_NAME, "hashN");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_VALUE, "40");
|
|
||||||
deleteRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
deleteRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
deleteRunner.run(1);
|
|
||||||
|
|
||||||
deleteRunner.assertAllFlowFilesTransferred(DeleteDynamoDB.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = deleteRunner.getFlowFilesForRelationship(DeleteDynamoDB.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals("", new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final check after delete
|
|
||||||
final TestRunner getRunnerAfterDelete = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.TABLE, numberHashOnlyTableName);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunnerAfterDelete.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunnerAfterDelete.run(1);
|
|
||||||
getRunnerAfterDelete.assertAllFlowFilesTransferred(GetDynamoDB.REL_NOT_FOUND, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunnerAfterDelete.getFlowFilesForRelationship(GetDynamoDB.REL_NOT_FOUND);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
String error = flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND);
|
|
||||||
assertTrue(error.startsWith(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNumberHashNumberRangePutGetDeleteGetSuccess() {
|
|
||||||
final TestRunner putRunner = TestRunners.newTestRunner(PutDynamoDB.class);
|
|
||||||
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.REGION, REGION);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.TABLE, numberHashNumberRangeTableName);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_NAME, "rangeN");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE, "50");
|
|
||||||
putRunner.setProperty(AbstractWriteDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
String document = "{\"40\":\"50\"}";
|
|
||||||
putRunner.enqueue(document.getBytes());
|
|
||||||
|
|
||||||
putRunner.run(1);
|
|
||||||
|
|
||||||
putRunner.assertAllFlowFilesTransferred(AbstractWriteDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = putRunner.getFlowFilesForRelationship(AbstractWriteDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner getRunner = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.TABLE, numberHashNumberRangeTableName);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeN");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "50");
|
|
||||||
getRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunner.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunner.run(1);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(AbstractDynamoDBProcessor.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunner.getFlowFilesForRelationship(AbstractDynamoDBProcessor.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
assertEquals(document, new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final TestRunner deleteRunner = TestRunners.newTestRunner(DeleteDynamoDB.class);
|
|
||||||
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.REGION, REGION);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.TABLE, numberHashNumberRangeTableName);
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_NAME, "hashN");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.RANGE_KEY_NAME, "rangeN");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.HASH_KEY_VALUE, "40");
|
|
||||||
deleteRunner.setProperty(DeleteDynamoDB.RANGE_KEY_VALUE, "50");
|
|
||||||
deleteRunner.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
deleteRunner.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
deleteRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
deleteRunner.run(1);
|
|
||||||
|
|
||||||
deleteRunner.assertAllFlowFilesTransferred(DeleteDynamoDB.REL_SUCCESS, 1);
|
|
||||||
|
|
||||||
flowFiles = deleteRunner.getFlowFilesForRelationship(DeleteDynamoDB.REL_SUCCESS);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
System.out.println(flowFile.getAttributes());
|
|
||||||
assertEquals("", new String(flowFile.toByteArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final check after delete
|
|
||||||
final TestRunner getRunnerAfterDelete = TestRunners.newTestRunner(GetDynamoDB.class);
|
|
||||||
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.REGION, REGION);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.TABLE, numberHashNumberRangeTableName);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_NAME, "hashN");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_NAME, "rangeN");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.HASH_KEY_VALUE, "40");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.RANGE_KEY_VALUE, "50");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractDynamoDBProcessor.JSON_DOCUMENT, "document");
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractWriteDynamoDBProcessor.HASH_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunnerAfterDelete.setProperty(AbstractWriteDynamoDBProcessor.RANGE_KEY_VALUE_TYPE, AbstractWriteDynamoDBProcessor.ALLOWABLE_VALUE_NUMBER);
|
|
||||||
getRunnerAfterDelete.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getRunnerAfterDelete.run(1);
|
|
||||||
getRunnerAfterDelete.assertAllFlowFilesTransferred(GetDynamoDB.REL_NOT_FOUND, 1);
|
|
||||||
|
|
||||||
flowFiles = getRunnerAfterDelete.getFlowFilesForRelationship(GetDynamoDB.REL_NOT_FOUND);
|
|
||||||
for (MockFlowFile flowFile : flowFiles) {
|
|
||||||
String error = flowFile.getAttribute(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND);
|
|
||||||
assertTrue(error.startsWith(AbstractDynamoDBProcessor.DYNAMODB_KEY_ERROR_NOT_FOUND_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,10 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.dynamodb;
|
package org.apache.nifi.processors.aws.dynamodb;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
|
||||||
public class ItemKeysTest {
|
public class ItemKeysTest {
|
||||||
|
|
||||||
|
|
|
@ -16,24 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.dynamodb;
|
package org.apache.nifi.processors.aws.dynamodb;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
|
||||||
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentMatchers;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonClientException;
|
import com.amazonaws.AmazonClientException;
|
||||||
import com.amazonaws.AmazonServiceException;
|
import com.amazonaws.AmazonServiceException;
|
||||||
import com.amazonaws.regions.Regions;
|
import com.amazonaws.regions.Regions;
|
||||||
|
@ -44,6 +26,23 @@ import com.amazonaws.services.dynamodbv2.model.AttributeValue;
|
||||||
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult;
|
import com.amazonaws.services.dynamodbv2.model.BatchWriteItemResult;
|
||||||
import com.amazonaws.services.dynamodbv2.model.PutRequest;
|
import com.amazonaws.services.dynamodbv2.model.PutRequest;
|
||||||
import com.amazonaws.services.dynamodbv2.model.WriteRequest;
|
import com.amazonaws.services.dynamodbv2.model.WriteRequest;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.REGION;
|
||||||
|
import static org.apache.nifi.processors.aws.dynamodb.ITAbstractDynamoDBTest.stringHashStringRangeTableName;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class PutDynamoDBTest extends AbstractDynamoDBTest {
|
public class PutDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class PutDynamoDBTest extends AbstractDynamoDBTest {
|
||||||
protected BatchWriteItemResult result = new BatchWriteItemResult();
|
protected BatchWriteItemResult result = new BatchWriteItemResult();
|
||||||
BatchWriteItemOutcome outcome;
|
BatchWriteItemOutcome outcome;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
outcome = new BatchWriteItemOutcome(result);
|
outcome = new BatchWriteItemOutcome(result);
|
||||||
result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>());
|
result.setUnprocessedItems(new HashMap<String, List<WriteRequest>>());
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.kinesis.firehose;
|
package org.apache.nifi.processors.aws.kinesis.firehose;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test contains both unit and integration test (integration tests are ignored by default)
|
* This test contains both unit and integration test (integration tests are ignored by default)
|
||||||
|
@ -37,7 +37,7 @@ public class ITPutKinesisFirehose {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
||||||
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "abcd");
|
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "abcd");
|
||||||
|
@ -46,7 +46,7 @@ public class ITPutKinesisFirehose {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.kinesis.firehose;
|
package org.apache.nifi.processors.aws.kinesis.firehose;
|
||||||
|
|
||||||
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
import org.apache.nifi.processors.aws.s3.FetchS3Object;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
||||||
|
|
||||||
// This integration test can be run against a mock Kenesis Firehose such as
|
// This integration test can be run against a mock Kenesis Firehose such as
|
||||||
// https://github.com/localstack/localstack
|
// https://github.com/localstack/localstack
|
||||||
|
@ -34,7 +34,7 @@ public class ITPutKinesisFirehoseWithEndpointOverride {
|
||||||
|
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
||||||
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "access key");
|
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "access key");
|
||||||
|
@ -44,7 +44,7 @@ public class ITPutKinesisFirehoseWithEndpointOverride {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
|
|
||||||
|
|
|
@ -16,22 +16,22 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.kinesis.firehose;
|
package org.apache.nifi.processors.aws.kinesis.firehose;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestPutKinesisFirehose {
|
public class TestPutKinesisFirehose {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
runner = TestRunners.newTestRunner(PutKinesisFirehose.class);
|
||||||
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "abcd");
|
runner.setProperty(PutKinesisFirehose.ACCESS_KEY, "abcd");
|
||||||
|
@ -40,7 +40,7 @@ public class TestPutKinesisFirehose {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import com.amazonaws.services.kinesis.model.ListStreamsResult;
|
||||||
import org.apache.nifi.processors.aws.kinesis.stream.record.AbstractKinesisRecordProcessor;
|
import org.apache.nifi.processors.aws.kinesis.stream.record.AbstractKinesisRecordProcessor;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -101,7 +101,7 @@ public abstract class ITConsumeKinesisStream {
|
||||||
Thread.sleep(30_000);
|
Thread.sleep(30_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws InterruptedException {
|
public void tearDown() throws InterruptedException {
|
||||||
cleanupKinesis();
|
cleanupKinesis();
|
||||||
cleanupDynamoDB();
|
cleanupDynamoDB();
|
||||||
|
|
|
@ -20,7 +20,7 @@ import com.amazonaws.auth.PropertiesFileCredentialsProvider;
|
||||||
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
|
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
|
||||||
import com.amazonaws.services.kinesis.AmazonKinesisClient;
|
import com.amazonaws.services.kinesis.AmazonKinesisClient;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class ITConsumeKinesisStreamConnectAWS extends ITConsumeKinesisStream {
|
||||||
private final static String CREDENTIALS_FILE =
|
private final static String CREDENTIALS_FILE =
|
||||||
System.getProperty("user.home") + "/aws-credentials.properties";
|
System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws InterruptedException {
|
public void setUp() throws InterruptedException {
|
||||||
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import com.amazonaws.client.builder.AwsClientBuilder;
|
||||||
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
|
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
|
||||||
import com.amazonaws.services.kinesis.AmazonKinesisClient;
|
import com.amazonaws.services.kinesis.AmazonKinesisClient;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
import static com.amazonaws.SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ITConsumeKinesisStreamEndpointOverride extends ITConsumeKinesisStre
|
||||||
private final AwsClientBuilder.EndpointConfiguration dynamoDBEndpointConfig =
|
private final AwsClientBuilder.EndpointConfiguration dynamoDBEndpointConfig =
|
||||||
new AwsClientBuilder.EndpointConfiguration(LOCAL_STACK_DYNAMODB_ENDPOINT_OVERRIDE, REGION);
|
new AwsClientBuilder.EndpointConfiguration(LOCAL_STACK_DYNAMODB_ENDPOINT_OVERRIDE, REGION);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws InterruptedException {
|
public void setUp() throws InterruptedException {
|
||||||
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,16 @@ package org.apache.nifi.processors.aws.kinesis.stream;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test contains both unit and integration test (integration tests are ignored by default).
|
* This test contains both unit and integration test (integration tests are ignored by default).
|
||||||
|
@ -41,7 +41,7 @@ public class ITPutKinesisStream {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutKinesisStream.class);
|
runner = TestRunners.newTestRunner(PutKinesisStream.class);
|
||||||
runner.setProperty(PutKinesisStream.KINESIS_STREAM_NAME, "kstream");
|
runner.setProperty(PutKinesisStream.KINESIS_STREAM_NAME, "kstream");
|
||||||
|
@ -49,7 +49,7 @@ public class ITPutKinesisStream {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ package org.apache.nifi.processors.aws.kinesis.stream;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class ITPutKinesisStreamWithEndpointOverride {
|
||||||
|
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
System.setProperty(AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ITPutKinesisStreamWithEndpointOverride {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.util.MockProcessContext;
|
import org.apache.nifi.util.MockProcessContext;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
@ -49,13 +49,13 @@ import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.hamcrest.CoreMatchers.startsWith;
|
import static org.hamcrest.CoreMatchers.startsWith;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestConsumeKinesisStream {
|
public class TestConsumeKinesisStream {
|
||||||
private final TestRunner runner = TestRunners.newTestRunner(ConsumeKinesisStream.class);
|
private final TestRunner runner = TestRunners.newTestRunner(ConsumeKinesisStream.class);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws InitializationException {
|
public void setUp() throws InitializationException {
|
||||||
runner.setProperty(ConsumeKinesisStream.KINESIS_STREAM_NAME, "test-stream");
|
runner.setProperty(ConsumeKinesisStream.KINESIS_STREAM_NAME, "test-stream");
|
||||||
runner.setProperty(ConsumeKinesisStream.APPLICATION_NAME, "test-application");
|
runner.setProperty(ConsumeKinesisStream.APPLICATION_NAME, "test-application");
|
||||||
|
|
|
@ -19,19 +19,19 @@ package org.apache.nifi.processors.aws.kinesis.stream;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestPutKinesisStream {
|
public class TestPutKinesisStream {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutKinesisStream.class);
|
runner = TestRunners.newTestRunner(PutKinesisStream.class);
|
||||||
runner.setProperty(PutKinesisStream.ACCESS_KEY, "abcd");
|
runner.setProperty(PutKinesisStream.ACCESS_KEY, "abcd");
|
||||||
|
@ -40,7 +40,7 @@ public class TestPutKinesisStream {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ import org.apache.nifi.util.SharedSessionState;
|
||||||
import org.apache.nifi.util.StopWatch;
|
import org.apache.nifi.util.StopWatch;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class TestAbstractKinesisRecordProcessor {
|
||||||
@Mock
|
@Mock
|
||||||
private Record kinesisRecord;
|
private Record kinesisRecord;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class TestAbstractKinesisRecordProcessor {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
reset(checkpointer, kinesisRecord, processSessionFactory);
|
reset(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.apache.nifi.util.MockProcessSession;
|
||||||
import org.apache.nifi.util.SharedSessionState;
|
import org.apache.nifi.util.SharedSessionState;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -76,7 +76,7 @@ public class TestKinesisRecordProcessorRaw {
|
||||||
@Mock
|
@Mock
|
||||||
private Record kinesisRecord;
|
private Record kinesisRecord;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class TestKinesisRecordProcessorRaw {
|
||||||
"endpoint-prefix", null, 10_000L, 1L, 2, DATE_TIME_FORMATTER);
|
"endpoint-prefix", null, 10_000L, 1L, 2, DATE_TIME_FORMATTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
reset(checkpointer, kinesisRecord, processSessionFactory);
|
reset(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
|
|
|
@ -36,9 +36,9 @@ import org.apache.nifi.util.MockProcessSession;
|
||||||
import org.apache.nifi.util.SharedSessionState;
|
import org.apache.nifi.util.SharedSessionState;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -87,7 +87,7 @@ public class TestKinesisRecordProcessorRecord {
|
||||||
@Mock
|
@Mock
|
||||||
private Record kinesisRecord;
|
private Record kinesisRecord;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws InitializationException {
|
public void setUp() throws InitializationException {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class TestKinesisRecordProcessorRecord {
|
||||||
reader, writer);
|
reader, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
verifyNoMoreInteractions(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
reset(checkpointer, kinesisRecord, processSessionFactory);
|
reset(checkpointer, kinesisRecord, processSessionFactory);
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.lambda;
|
package org.apache.nifi.processors.aws.lambda;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Ignore;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test contains both unit and integration test (integration tests are ignored by default)
|
* This test contains both unit and integration test (integration tests are ignored by default)
|
||||||
|
@ -38,7 +38,7 @@ public class ITPutLambda {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
protected final static String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(PutLambda.class);
|
runner = TestRunners.newTestRunner(PutLambda.class);
|
||||||
runner.setProperty(PutLambda.ACCESS_KEY, "abcd");
|
runner.setProperty(PutLambda.ACCESS_KEY, "abcd");
|
||||||
|
@ -47,13 +47,13 @@ public class ITPutLambda {
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
runner = null;
|
runner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSizeGreaterThan6MB() throws Exception {
|
public void testSizeGreaterThan6MB() {
|
||||||
runner = TestRunners.newTestRunner(PutLambda.class);
|
runner = TestRunners.newTestRunner(PutLambda.class);
|
||||||
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
||||||
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
||||||
|
@ -72,8 +72,7 @@ public class ITPutLambda {
|
||||||
* Comment out ignore for integration tests (requires creds files)
|
* Comment out ignore for integration tests (requires creds files)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testIntegrationSuccess() {
|
||||||
public void testIntegrationSuccess() throws Exception {
|
|
||||||
runner = TestRunners.newTestRunner(PutLambda.class);
|
runner = TestRunners.newTestRunner(PutLambda.class);
|
||||||
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
||||||
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
||||||
|
@ -86,17 +85,16 @@ public class ITPutLambda {
|
||||||
|
|
||||||
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_SUCCESS);
|
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_SUCCESS);
|
||||||
final MockFlowFile out = ffs.iterator().next();
|
final MockFlowFile out = ffs.iterator().next();
|
||||||
assertNull("Function error should be null " + out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
assertNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), "Function error should be null " + out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
||||||
assertNotNull("log should not be null", out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG));
|
assertNotNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG), "log should not be null");
|
||||||
assertEquals("Status should be equal", "200",out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE));
|
assertEquals("200",out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE), "Status should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment out ignore for integration tests (requires creds files)
|
* Comment out ignore for integration tests (requires creds files)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testIntegrationClientErrorBadMessageBody() {
|
||||||
public void testIntegrationClientErrorBadMessageBody() throws Exception {
|
|
||||||
runner = TestRunners.newTestRunner(PutLambda.class);
|
runner = TestRunners.newTestRunner(PutLambda.class);
|
||||||
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
||||||
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "hello");
|
||||||
|
@ -108,23 +106,22 @@ public class ITPutLambda {
|
||||||
runner.assertAllFlowFilesTransferred(PutLambda.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutLambda.REL_FAILURE, 1);
|
||||||
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_FAILURE);
|
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_FAILURE);
|
||||||
final MockFlowFile out = ffs.iterator().next();
|
final MockFlowFile out = ffs.iterator().next();
|
||||||
assertNull("Function error should be null since there is exception"
|
assertNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), "Function error should be null since there is exception"
|
||||||
+ out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
+ out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
||||||
assertNull("log should not be null", out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG));
|
assertNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG), "log should not be null");
|
||||||
assertEquals("Status should be equal", null,out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE));
|
assertEquals(null,out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE), "Status should be equal");
|
||||||
assertEquals("exception error code should be equal", "InvalidRequestContentException",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_ERROR_CODE));
|
assertEquals("InvalidRequestContentException",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_ERROR_CODE), "exception error code should be equal");
|
||||||
assertEquals("exception exception error type should be equal", "Client",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_ERROR_TYPE));
|
assertEquals("Client",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_ERROR_TYPE), "exception exception error type should be equal");
|
||||||
assertEquals("exception exception error code should be equal", "400",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_STATUS_CODE));
|
assertEquals("400",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_STATUS_CODE), "exception exception error code should be equal");
|
||||||
assertTrue("exception exception error message should be start with",out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_MESSAGE)
|
assertTrue(out.getAttribute(PutLambda.AWS_LAMBDA_EXCEPTION_MESSAGE)
|
||||||
.startsWith("Could not parse request body into json: Unrecognized token 'badbod': was expecting ('true', 'false' or 'null')"));
|
.startsWith("Could not parse request body into json: Unrecognized token 'badbod': was expecting ('true', 'false' or 'null')"), "exception exception error message should be start with");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment out ignore for integration tests (requires creds files)
|
* Comment out ignore for integration tests (requires creds files)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testIntegrationFailedBadStreamName() {
|
||||||
public void testIntegrationFailedBadStreamName() throws Exception {
|
|
||||||
runner = TestRunners.newTestRunner(PutLambda.class);
|
runner = TestRunners.newTestRunner(PutLambda.class);
|
||||||
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
runner.setProperty(PutLambda.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
||||||
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "bad-function-name");
|
runner.setProperty(PutLambda.AWS_LAMBDA_FUNCTION_NAME, "bad-function-name");
|
||||||
|
@ -136,10 +133,10 @@ public class ITPutLambda {
|
||||||
runner.assertAllFlowFilesTransferred(PutLambda.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutLambda.REL_FAILURE, 1);
|
||||||
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_FAILURE);
|
final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutLambda.REL_FAILURE);
|
||||||
final MockFlowFile out = ffs.iterator().next();
|
final MockFlowFile out = ffs.iterator().next();
|
||||||
assertNull("Function error should be null since there is exception"
|
assertNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), "Function error should be null since there is exception"
|
||||||
+ out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR), out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
+ out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_FUNCTION_ERROR));
|
||||||
assertNull("log should not be null", out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG));
|
assertNull(out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_LOG), "log should not be null");
|
||||||
assertEquals("Status should be equal", null,out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE));
|
assertEquals(null,out.getAttribute(PutLambda.AWS_LAMBDA_RESULT_STATUS_CODE), "Status should be equal");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.lambda;
|
package org.apache.nifi.processors.aws.lambda;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonServiceException;
|
import com.amazonaws.AmazonServiceException;
|
||||||
import com.amazonaws.services.lambda.AWSLambdaClient;
|
import com.amazonaws.services.lambda.AWSLambdaClient;
|
||||||
import com.amazonaws.services.lambda.model.InvalidParameterValueException;
|
import com.amazonaws.services.lambda.model.InvalidParameterValueException;
|
||||||
|
@ -30,14 +23,19 @@ import com.amazonaws.services.lambda.model.InvokeRequest;
|
||||||
import com.amazonaws.services.lambda.model.InvokeResult;
|
import com.amazonaws.services.lambda.model.InvokeResult;
|
||||||
import com.amazonaws.services.lambda.model.TooManyRequestsException;
|
import com.amazonaws.services.lambda.model.TooManyRequestsException;
|
||||||
import com.amazonaws.util.Base64;
|
import com.amazonaws.util.Base64;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.junit.Before;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.junit.Test;
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.nio.ByteBuffer;
|
||||||
import static org.junit.Assert.assertTrue;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestPutLambda {
|
public class TestPutLambda {
|
||||||
|
@ -47,7 +45,7 @@ public class TestPutLambda {
|
||||||
private AWSLambdaClient actualLambdaClient = null;
|
private AWSLambdaClient actualLambdaClient = null;
|
||||||
private AWSLambdaClient mockLambdaClient = null;
|
private AWSLambdaClient mockLambdaClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockLambdaClient = Mockito.mock(AWSLambdaClient.class);
|
mockLambdaClient = Mockito.mock(AWSLambdaClient.class);
|
||||||
mockPutLambda = new PutLambda() {
|
mockPutLambda = new PutLambda() {
|
||||||
|
|
|
@ -38,9 +38,8 @@ import com.amazonaws.services.s3.model.PutObjectResult;
|
||||||
import com.amazonaws.services.s3.model.S3ObjectSummary;
|
import com.amazonaws.services.s3.model.S3ObjectSummary;
|
||||||
import com.amazonaws.services.s3.model.Tag;
|
import com.amazonaws.services.s3.model.Tag;
|
||||||
import org.apache.nifi.util.file.FileUtils;
|
import org.apache.nifi.util.file.FileUtils;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -78,7 +77,7 @@ public abstract class AbstractS3IT {
|
||||||
protected static AmazonS3Client client;
|
protected static AmazonS3Client client;
|
||||||
protected static AWSKMS kmsClient;
|
protected static AWSKMS kmsClient;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void oneTimeSetup() {
|
public static void oneTimeSetup() {
|
||||||
// Creates a client and bucket for this test
|
// Creates a client and bucket for this test
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ public abstract class AbstractS3IT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void oneTimeTearDown() {
|
public static void oneTimeTearDown() {
|
||||||
// Empty the bucket before deleting it.
|
// Empty the bucket before deleting it.
|
||||||
try {
|
try {
|
||||||
|
@ -146,9 +145,8 @@ public abstract class AbstractS3IT {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client.doesBucketExist(BUCKET_NAME)) {
|
if (client.doesBucketExist(BUCKET_NAME)) {
|
||||||
Assert.fail("Incomplete teardown, subsequent tests might fail");
|
fail("Incomplete teardown, subsequent tests might fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putTestFile(String key, File file) throws AmazonS3Exception {
|
protected void putTestFile(String key, File file) throws AmazonS3Exception {
|
||||||
|
@ -185,7 +183,7 @@ public abstract class AbstractS3IT {
|
||||||
try {
|
try {
|
||||||
path = Paths.get(getClass().getResource(resourceName).toURI());
|
path = Paths.get(getClass().getResource(resourceName).toURI());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
Assert.fail("Resource: " + resourceName + " does not exist" + e.getLocalizedMessage());
|
fail("Resource: " + resourceName + " does not exist" + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
@ -196,7 +194,7 @@ public abstract class AbstractS3IT {
|
||||||
try {
|
try {
|
||||||
uri = this.getClass().getResource(resourceName).toURI();
|
uri = this.getClass().getResource(resourceName).toURI();
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
Assert.fail("Cannot proceed without File : " + resourceName);
|
fail("Cannot proceed without File : " + resourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new File(uri);
|
return new File(uri);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredential
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredential
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -16,23 +16,19 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.s3;
|
package org.apache.nifi.processors.aws.s3;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import com.amazonaws.AmazonClientException;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonServiceException;
|
import com.amazonaws.AmazonServiceException;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
import com.amazonaws.services.s3.model.GetObjectTaggingRequest;
|
import com.amazonaws.services.s3.model.GetObjectTaggingRequest;
|
||||||
import com.amazonaws.services.s3.model.GetObjectTaggingResult;
|
import com.amazonaws.services.s3.model.GetObjectTaggingResult;
|
||||||
|
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
|
||||||
import com.amazonaws.services.s3.model.ListMultipartUploadsRequest;
|
import com.amazonaws.services.s3.model.ListMultipartUploadsRequest;
|
||||||
|
import com.amazonaws.services.s3.model.MultipartUpload;
|
||||||
|
import com.amazonaws.services.s3.model.MultipartUploadListing;
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
|
import com.amazonaws.services.s3.model.PartETag;
|
||||||
|
import com.amazonaws.services.s3.model.Region;
|
||||||
|
import com.amazonaws.services.s3.model.StorageClass;
|
||||||
import com.amazonaws.services.s3.model.Tag;
|
import com.amazonaws.services.s3.model.Tag;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -53,23 +49,28 @@ import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.amazonaws.AmazonClientException;
|
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
|
||||||
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
|
|
||||||
import com.amazonaws.services.s3.model.MultipartUpload;
|
|
||||||
import com.amazonaws.services.s3.model.MultipartUploadListing;
|
|
||||||
import com.amazonaws.services.s3.model.PartETag;
|
|
||||||
import com.amazonaws.services.s3.model.Region;
|
|
||||||
import com.amazonaws.services.s3.model.StorageClass;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
private static String randomKeyMaterial = "";
|
private static String randomKeyMaterial = "";
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setupClass() {
|
public static void setupClass() {
|
||||||
byte[] keyRawBytes = new byte[32];
|
byte[] keyRawBytes = new byte[32];
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
@ -104,7 +105,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
kmsKeyId = getKMSKey();
|
kmsKeyId = getKMSKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void teardownClass() {
|
public static void teardownClass() {
|
||||||
if (StringUtils.isNotEmpty(kmsKeyId)) {
|
if (StringUtils.isNotEmpty(kmsKeyId)) {
|
||||||
deleteKMSKey(kmsKeyId);
|
deleteKMSKey(kmsKeyId);
|
||||||
|
@ -115,7 +116,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
public void testSimplePut() throws IOException {
|
public void testSimplePut() throws IOException {
|
||||||
TestRunner runner = initTestRunner();
|
TestRunner runner = initTestRunner();
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -133,7 +134,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
runner.setProperty(PutS3Object.SERVER_SIDE_ENCRYPTION, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
|
runner.setProperty(PutS3Object.SERVER_SIDE_ENCRYPTION, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -236,7 +237,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.setProperty(PutS3Object.REGION, REGION);
|
runner.setProperty(PutS3Object.REGION, REGION);
|
||||||
runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);
|
runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -374,7 +375,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
public void testPutInFolder() throws IOException {
|
public void testPutInFolder() throws IOException {
|
||||||
TestRunner runner = initTestRunner();
|
TestRunner runner = initTestRunner();
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
runner.assertValid();
|
runner.assertValid();
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -390,7 +391,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
public void testStorageClasses() throws IOException {
|
public void testStorageClasses() throws IOException {
|
||||||
TestRunner runner = initTestRunner();
|
TestRunner runner = initTestRunner();
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
for (StorageClass storageClass : StorageClass.values()) {
|
for (StorageClass storageClass : StorageClass.values()) {
|
||||||
if (storageClass == StorageClass.Outposts) {
|
if (storageClass == StorageClass.Outposts) {
|
||||||
|
@ -408,7 +409,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
|
||||||
FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
|
FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
|
||||||
Assert.assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));
|
assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));
|
||||||
|
|
||||||
runner.clearTransferState();
|
runner.clearTransferState();
|
||||||
}
|
}
|
||||||
|
@ -421,7 +422,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.setProperty(PutS3Object.MULTIPART_THRESHOLD, "50 MB");
|
runner.setProperty(PutS3Object.MULTIPART_THRESHOLD, "50 MB");
|
||||||
runner.setProperty(PutS3Object.MULTIPART_PART_SIZE, "50 MB");
|
runner.setProperty(PutS3Object.MULTIPART_PART_SIZE, "50 MB");
|
||||||
|
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
for (StorageClass storageClass : StorageClass.values()) {
|
for (StorageClass storageClass : StorageClass.values()) {
|
||||||
if (storageClass == StorageClass.Outposts) {
|
if (storageClass == StorageClass.Outposts) {
|
||||||
|
@ -439,7 +440,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
|
||||||
FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
|
FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
|
||||||
Assert.assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));
|
assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));
|
||||||
|
|
||||||
runner.clearTransferState();
|
runner.clearTransferState();
|
||||||
}
|
}
|
||||||
|
@ -485,7 +486,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, successFiles.size());
|
assertEquals(1, successFiles.size());
|
||||||
MockFlowFile ff1 = successFiles.get(0);
|
MockFlowFile ff1 = successFiles.get(0);
|
||||||
|
|
||||||
Long now = System.currentTimeMillis();
|
Long now = System.currentTimeMillis();
|
||||||
|
@ -495,8 +496,8 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
String[] usermetaLine0 = usermeta.split(System.lineSeparator())[0].split("=");
|
String[] usermetaLine0 = usermeta.split(System.lineSeparator())[0].split("=");
|
||||||
String usermetaKey0 = usermetaLine0[0];
|
String usermetaKey0 = usermetaLine0[0];
|
||||||
String usermetaValue0 = usermetaLine0[1];
|
String usermetaValue0 = usermetaLine0[1];
|
||||||
Assert.assertEquals(DYNAMIC_ATTRIB_KEY, usermetaKey0);
|
assertEquals(DYNAMIC_ATTRIB_KEY, usermetaKey0);
|
||||||
Assert.assertTrue(usermetaValue0.compareTo(millisOneSecAgo) >=0 && usermetaValue0.compareTo(millisNow) <= 0);
|
assertTrue(usermetaValue0.compareTo(millisOneSecAgo) >=0 && usermetaValue0.compareTo(millisNow) <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -519,29 +520,29 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, successFiles.size());
|
assertEquals(1, successFiles.size());
|
||||||
|
|
||||||
final List<ProvenanceEventRecord> provenanceEvents = runner.getProvenanceEvents();
|
final List<ProvenanceEventRecord> provenanceEvents = runner.getProvenanceEvents();
|
||||||
Assert.assertEquals(1, provenanceEvents.size());
|
assertEquals(1, provenanceEvents.size());
|
||||||
ProvenanceEventRecord provRec1 = provenanceEvents.get(0);
|
ProvenanceEventRecord provRec1 = provenanceEvents.get(0);
|
||||||
Assert.assertEquals(ProvenanceEventType.SEND, provRec1.getEventType());
|
assertEquals(ProvenanceEventType.SEND, provRec1.getEventType());
|
||||||
Assert.assertEquals(processor.getIdentifier(), provRec1.getComponentId());
|
assertEquals(processor.getIdentifier(), provRec1.getComponentId());
|
||||||
client.setRegion(Region.fromValue(REGION).toAWSRegion());
|
client.setRegion(Region.fromValue(REGION).toAWSRegion());
|
||||||
String targetUri = client.getUrl(BUCKET_NAME, PROV1_FILE).toString();
|
String targetUri = client.getUrl(BUCKET_NAME, PROV1_FILE).toString();
|
||||||
Assert.assertEquals(targetUri, provRec1.getTransitUri());
|
assertEquals(targetUri, provRec1.getTransitUri());
|
||||||
Assert.assertEquals(8, provRec1.getUpdatedAttributes().size());
|
assertEquals(8, provRec1.getUpdatedAttributes().size());
|
||||||
Assert.assertEquals(BUCKET_NAME, provRec1.getUpdatedAttributes().get(PutS3Object.S3_BUCKET_KEY));
|
assertEquals(BUCKET_NAME, provRec1.getUpdatedAttributes().get(PutS3Object.S3_BUCKET_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStateDefaults() {
|
public void testStateDefaults() {
|
||||||
PutS3Object.MultipartState state1 = new PutS3Object.MultipartState();
|
PutS3Object.MultipartState state1 = new PutS3Object.MultipartState();
|
||||||
Assert.assertEquals(state1.getUploadId(), "");
|
assertEquals(state1.getUploadId(), "");
|
||||||
Assert.assertEquals(state1.getFilePosition(), (Long) 0L);
|
assertEquals(state1.getFilePosition(), (Long) 0L);
|
||||||
Assert.assertEquals(state1.getPartETags().size(), 0L);
|
assertEquals(state1.getPartETags().size(), 0L);
|
||||||
Assert.assertEquals(state1.getPartSize(), (Long) 0L);
|
assertEquals(state1.getPartSize(), (Long) 0L);
|
||||||
Assert.assertEquals(state1.getStorageClass().toString(), StorageClass.Standard.toString());
|
assertEquals(state1.getStorageClass().toString(), StorageClass.Standard.toString());
|
||||||
Assert.assertEquals(state1.getContentLength(), (Long) 0L);
|
assertEquals(state1.getContentLength(), (Long) 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -557,7 +558,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
state2.setPartSize(20002L);
|
state2.setPartSize(20002L);
|
||||||
state2.setStorageClass(StorageClass.ReducedRedundancy);
|
state2.setStorageClass(StorageClass.ReducedRedundancy);
|
||||||
state2.setContentLength(30003L);
|
state2.setContentLength(30003L);
|
||||||
Assert.assertEquals(target, state2.toString());
|
assertEquals(target, state2.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -575,12 +576,12 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
Assert.assertEquals(BUCKET_NAME, context.getProperty(PutS3Object.BUCKET).toString());
|
assertEquals(BUCKET_NAME, context.getProperty(PutS3Object.BUCKET).toString());
|
||||||
Assert.assertEquals(TESTKEY, context.getProperty(PutS3Object.KEY).evaluateAttributeExpressions().toString());
|
assertEquals(TESTKEY, context.getProperty(PutS3Object.KEY).evaluateAttributeExpressions().toString());
|
||||||
Assert.assertEquals(TEST_ENDPOINT, context.getProperty(PutS3Object.ENDPOINT_OVERRIDE).toString());
|
assertEquals(TEST_ENDPOINT, context.getProperty(PutS3Object.ENDPOINT_OVERRIDE).toString());
|
||||||
|
|
||||||
String s3url = ((TestablePutS3Object)processor).testable_getClient().getResourceUrl(BUCKET_NAME, TESTKEY);
|
String s3url = ((TestablePutS3Object)processor).testable_getClient().getResourceUrl(BUCKET_NAME, TESTKEY);
|
||||||
Assert.assertEquals(TEST_ENDPOINT + "/" + BUCKET_NAME + "/" + TESTKEY, s3url);
|
assertEquals(TEST_ENDPOINT + "/" + BUCKET_NAME + "/" + TESTKEY, s3url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -596,9 +597,9 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);
|
runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);
|
||||||
runner.setProperty(PutS3Object.KEY, AbstractS3IT.SAMPLE_FILE_RESOURCE_NAME);
|
runner.setProperty(PutS3Object.KEY, AbstractS3IT.SAMPLE_FILE_RESOURCE_NAME);
|
||||||
|
|
||||||
Assert.assertEquals(BUCKET_NAME, context.getProperty(PutS3Object.BUCKET).toString());
|
assertEquals(BUCKET_NAME, context.getProperty(PutS3Object.BUCKET).toString());
|
||||||
Assert.assertEquals(SAMPLE_FILE_RESOURCE_NAME, context.getProperty(PutS3Object.KEY).evaluateAttributeExpressions().toString());
|
assertEquals(SAMPLE_FILE_RESOURCE_NAME, context.getProperty(PutS3Object.KEY).evaluateAttributeExpressions().toString());
|
||||||
Assert.assertEquals(TEST_PARTSIZE_LONG.longValue(),
|
assertEquals(TEST_PARTSIZE_LONG.longValue(),
|
||||||
context.getProperty(PutS3Object.MULTIPART_PART_SIZE).asDataSize(DataUnit.B).longValue());
|
context.getProperty(PutS3Object.MULTIPART_PART_SIZE).asDataSize(DataUnit.B).longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,28 +652,28 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
* reload and validate stored state
|
* reload and validate stored state
|
||||||
*/
|
*/
|
||||||
final PutS3Object.MultipartState state1new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey1);
|
final PutS3Object.MultipartState state1new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey1);
|
||||||
Assert.assertEquals("", state1new.getUploadId());
|
assertEquals("", state1new.getUploadId());
|
||||||
Assert.assertEquals(0L, state1new.getFilePosition().longValue());
|
assertEquals(0L, state1new.getFilePosition().longValue());
|
||||||
Assert.assertEquals(new ArrayList<PartETag>(), state1new.getPartETags());
|
assertEquals(new ArrayList<PartETag>(), state1new.getPartETags());
|
||||||
Assert.assertEquals(0L, state1new.getPartSize().longValue());
|
assertEquals(0L, state1new.getPartSize().longValue());
|
||||||
Assert.assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state1new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state1new.getStorageClass());
|
||||||
Assert.assertEquals(0L, state1new.getContentLength().longValue());
|
assertEquals(0L, state1new.getContentLength().longValue());
|
||||||
|
|
||||||
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
||||||
Assert.assertEquals("1234", state2new.getUploadId());
|
assertEquals("1234", state2new.getUploadId());
|
||||||
Assert.assertEquals(0L, state2new.getFilePosition().longValue());
|
assertEquals(0L, state2new.getFilePosition().longValue());
|
||||||
Assert.assertEquals(new ArrayList<PartETag>(), state2new.getPartETags());
|
assertEquals(new ArrayList<PartETag>(), state2new.getPartETags());
|
||||||
Assert.assertEquals(0L, state2new.getPartSize().longValue());
|
assertEquals(0L, state2new.getPartSize().longValue());
|
||||||
Assert.assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state2new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state2new.getStorageClass());
|
||||||
Assert.assertEquals(1234L, state2new.getContentLength().longValue());
|
assertEquals(1234L, state2new.getContentLength().longValue());
|
||||||
|
|
||||||
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
||||||
Assert.assertEquals("5678", state3new.getUploadId());
|
assertEquals("5678", state3new.getUploadId());
|
||||||
Assert.assertEquals(0L, state3new.getFilePosition().longValue());
|
assertEquals(0L, state3new.getFilePosition().longValue());
|
||||||
Assert.assertEquals(new ArrayList<PartETag>(), state3new.getPartETags());
|
assertEquals(new ArrayList<PartETag>(), state3new.getPartETags());
|
||||||
Assert.assertEquals(0L, state3new.getPartSize().longValue());
|
assertEquals(0L, state3new.getPartSize().longValue());
|
||||||
Assert.assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state3new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state3new.getStorageClass());
|
||||||
Assert.assertEquals(5678L, state3new.getContentLength().longValue());
|
assertEquals(5678L, state3new.getContentLength().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -743,12 +744,12 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
* 2. v3 restore shows 2 tags
|
* 2. v3 restore shows 2 tags
|
||||||
*/
|
*/
|
||||||
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
||||||
Assert.assertEquals("1234", state2new.getUploadId());
|
assertEquals("1234", state2new.getUploadId());
|
||||||
Assert.assertEquals(4, state2new.getPartETags().size());
|
assertEquals(4, state2new.getPartETags().size());
|
||||||
|
|
||||||
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
||||||
Assert.assertEquals("5678", state3new.getUploadId());
|
assertEquals("5678", state3new.getUploadId());
|
||||||
Assert.assertEquals(2, state3new.getPartETags().size());
|
assertEquals(2, state3new.getPartETags().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -779,12 +780,12 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
processor.persistLocalState(cacheKey, stateOrig);
|
processor.persistLocalState(cacheKey, stateOrig);
|
||||||
|
|
||||||
PutS3Object.MultipartState state1 = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey);
|
PutS3Object.MultipartState state1 = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey);
|
||||||
Assert.assertEquals("1234", state1.getUploadId());
|
assertEquals("1234", state1.getUploadId());
|
||||||
Assert.assertEquals(1234L, state1.getContentLength().longValue());
|
assertEquals(1234L, state1.getContentLength().longValue());
|
||||||
|
|
||||||
processor.persistLocalState(cacheKey, null);
|
processor.persistLocalState(cacheKey, null);
|
||||||
PutS3Object.MultipartState state2 = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey);
|
PutS3Object.MultipartState state2 = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey);
|
||||||
Assert.assertNull(state2);
|
assertNull(state2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -801,10 +802,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
}
|
}
|
||||||
tempOut.close();
|
tempOut.close();
|
||||||
System.out.println("file size: " + tempByteCount);
|
System.out.println("file size: " + tempByteCount);
|
||||||
Assert.assertTrue(tempByteCount < S3_MINIMUM_PART_SIZE);
|
assertTrue(tempByteCount < S3_MINIMUM_PART_SIZE);
|
||||||
|
|
||||||
Assert.assertTrue(megabyte.length < S3_MINIMUM_PART_SIZE);
|
assertTrue(megabyte.length < S3_MINIMUM_PART_SIZE);
|
||||||
Assert.assertTrue(TEST_PARTSIZE_LONG >= S3_MINIMUM_PART_SIZE && TEST_PARTSIZE_LONG <= S3_MAXIMUM_OBJECT_SIZE);
|
assertTrue(TEST_PARTSIZE_LONG >= S3_MINIMUM_PART_SIZE && TEST_PARTSIZE_LONG <= S3_MAXIMUM_OBJECT_SIZE);
|
||||||
|
|
||||||
final PutS3Object processor = new PutS3Object();
|
final PutS3Object processor = new PutS3Object();
|
||||||
final TestRunner runner = TestRunners.newTestRunner(processor);
|
final TestRunner runner = TestRunners.newTestRunner(processor);
|
||||||
|
@ -822,16 +823,16 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, successFiles.size());
|
assertEquals(1, successFiles.size());
|
||||||
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
||||||
Assert.assertEquals(0, failureFiles.size());
|
assertEquals(0, failureFiles.size());
|
||||||
MockFlowFile ff1 = successFiles.get(0);
|
MockFlowFile ff1 = successFiles.get(0);
|
||||||
Assert.assertEquals(PutS3Object.S3_API_METHOD_PUTOBJECT, ff1.getAttribute(PutS3Object.S3_API_METHOD_ATTR_KEY));
|
assertEquals(PutS3Object.S3_API_METHOD_PUTOBJECT, ff1.getAttribute(PutS3Object.S3_API_METHOD_ATTR_KEY));
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
||||||
Assert.assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
||||||
Assert.assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
||||||
Assert.assertEquals(tempByteCount, ff1.getSize());
|
assertEquals(tempByteCount, ff1.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -848,8 +849,8 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
}
|
}
|
||||||
tempOut.close();
|
tempOut.close();
|
||||||
System.out.println("file size: " + tempByteCount);
|
System.out.println("file size: " + tempByteCount);
|
||||||
Assert.assertTrue(tempByteCount > S3_MINIMUM_PART_SIZE && tempByteCount < S3_MAXIMUM_OBJECT_SIZE);
|
assertTrue(tempByteCount > S3_MINIMUM_PART_SIZE && tempByteCount < S3_MAXIMUM_OBJECT_SIZE);
|
||||||
Assert.assertTrue(tempByteCount > TEST_PARTSIZE_LONG);
|
assertTrue(tempByteCount > TEST_PARTSIZE_LONG);
|
||||||
|
|
||||||
final PutS3Object processor = new PutS3Object();
|
final PutS3Object processor = new PutS3Object();
|
||||||
final TestRunner runner = TestRunners.newTestRunner(processor);
|
final TestRunner runner = TestRunners.newTestRunner(processor);
|
||||||
|
@ -868,19 +869,18 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, successFiles.size());
|
assertEquals(1, successFiles.size());
|
||||||
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
||||||
Assert.assertEquals(0, failureFiles.size());
|
assertEquals(0, failureFiles.size());
|
||||||
MockFlowFile ff1 = successFiles.get(0);
|
MockFlowFile ff1 = successFiles.get(0);
|
||||||
Assert.assertEquals(PutS3Object.S3_API_METHOD_MULTIPARTUPLOAD, ff1.getAttribute(PutS3Object.S3_API_METHOD_ATTR_KEY));
|
assertEquals(PutS3Object.S3_API_METHOD_MULTIPARTUPLOAD, ff1.getAttribute(PutS3Object.S3_API_METHOD_ATTR_KEY));
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
||||||
Assert.assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
||||||
Assert.assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
||||||
Assert.assertEquals(tempByteCount, ff1.getSize());
|
assertEquals(tempByteCount, ff1.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipartLargerThanObjectMaximum() throws IOException {
|
public void testMultipartLargerThanObjectMaximum() throws IOException {
|
||||||
final String FILE1_NAME = "file1";
|
final String FILE1_NAME = "file1";
|
||||||
|
@ -909,15 +909,15 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, successFiles.size());
|
assertEquals(1, successFiles.size());
|
||||||
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
final List<MockFlowFile> failureFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE);
|
||||||
Assert.assertEquals(0, failureFiles.size());
|
assertEquals(0, failureFiles.size());
|
||||||
MockFlowFile ff1 = successFiles.get(0);
|
MockFlowFile ff1 = successFiles.get(0);
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
assertEquals(FILE1_NAME, ff1.getAttribute(CoreAttributes.FILENAME.key()));
|
||||||
Assert.assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
assertEquals(BUCKET_NAME, ff1.getAttribute(PutS3Object.S3_BUCKET_KEY));
|
||||||
Assert.assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
assertEquals(FILE1_NAME, ff1.getAttribute(PutS3Object.S3_OBJECT_KEY));
|
||||||
Assert.assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
assertTrue(reS3ETag.matcher(ff1.getAttribute(PutS3Object.S3_ETAG_ATTR_KEY)).matches());
|
||||||
Assert.assertTrue(ff1.getSize() > S3_MAXIMUM_OBJECT_SIZE);
|
assertTrue(ff1.getSize() > S3_MAXIMUM_OBJECT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -937,12 +937,8 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
// create some dummy uploads
|
// create some dummy uploads
|
||||||
for (Integer i = 0; i < 3; i++) {
|
for (Integer i = 0; i < 3; i++) {
|
||||||
final InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest(
|
final InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest(
|
||||||
BUCKET_NAME, "file" + i.toString() + ".txt");
|
BUCKET_NAME, "file" + i + ".txt");
|
||||||
try {
|
assertDoesNotThrow(() -> client.initiateMultipartUpload(initiateRequest));
|
||||||
client.initiateMultipartUpload(initiateRequest);
|
|
||||||
} catch (AmazonClientException e) {
|
|
||||||
Assert.fail("Failed to initiate upload: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Age off is time dependent, so test has some timing constraints. This
|
// Age off is time dependent, so test has some timing constraints. This
|
||||||
|
@ -956,13 +952,13 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
Long now = System.currentTimeMillis();
|
Long now = System.currentTimeMillis();
|
||||||
|
|
||||||
MultipartUploadListing uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now, BUCKET_NAME);
|
MultipartUploadListing uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now, BUCKET_NAME);
|
||||||
Assert.assertEquals(3, uploadList.getMultipartUploads().size());
|
assertEquals(3, uploadList.getMultipartUploads().size());
|
||||||
|
|
||||||
MultipartUpload upload0 = uploadList.getMultipartUploads().get(0);
|
MultipartUpload upload0 = uploadList.getMultipartUploads().get(0);
|
||||||
processor.abortS3MultipartUpload(client, BUCKET_NAME, upload0);
|
processor.abortS3MultipartUpload(client, BUCKET_NAME, upload0);
|
||||||
|
|
||||||
uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now+1000, BUCKET_NAME);
|
uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now+1000, BUCKET_NAME);
|
||||||
Assert.assertEquals(2, uploadList.getMultipartUploads().size());
|
assertEquals(2, uploadList.getMultipartUploads().size());
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
attrs.put("filename", "test-upload.txt");
|
attrs.put("filename", "test-upload.txt");
|
||||||
|
@ -970,7 +966,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.run();
|
runner.run();
|
||||||
|
|
||||||
uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now+2000, BUCKET_NAME);
|
uploadList = processor.getS3AgeoffListAndAgeoffLocalState(context, client, now+2000, BUCKET_NAME);
|
||||||
Assert.assertEquals(0, uploadList.getMultipartUploads().size());
|
assertEquals(0, uploadList.getMultipartUploads().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -995,9 +991,9 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
System.out.println("Tag Key : " + tag.getKey() + ", Tag Value : " + tag.getValue());
|
System.out.println("Tag Key : " + tag.getKey() + ", Tag Value : " + tag.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(objectTags.size() == 1);
|
assertTrue(objectTags.size() == 1);
|
||||||
Assert.assertEquals("PII", objectTags.get(0).getKey());
|
assertEquals("PII", objectTags.get(0).getKey());
|
||||||
Assert.assertEquals("true", objectTags.get(0).getValue());
|
assertEquals("true", objectTags.get(0).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1023,10 +1019,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, flowFiles.size());
|
assertEquals(1, flowFiles.size());
|
||||||
Assert.assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
||||||
MockFlowFile putSuccess = flowFiles.get(0);
|
MockFlowFile putSuccess = flowFiles.get(0);
|
||||||
Assert.assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_S3);
|
assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_S3);
|
||||||
|
|
||||||
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_S3, null);
|
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_S3, null);
|
||||||
flowFile.assertContentEquals(data);
|
flowFile.assertContentEquals(data);
|
||||||
|
@ -1057,10 +1053,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, flowFiles.size());
|
assertEquals(1, flowFiles.size());
|
||||||
Assert.assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
||||||
MockFlowFile putSuccess = flowFiles.get(0);
|
MockFlowFile putSuccess = flowFiles.get(0);
|
||||||
Assert.assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_KMS);
|
assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_KMS);
|
||||||
|
|
||||||
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_KMS, kmsKeyId);
|
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_KMS, kmsKeyId);
|
||||||
flowFile.assertContentEquals(data);
|
flowFile.assertContentEquals(data);
|
||||||
|
@ -1091,10 +1087,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, flowFiles.size());
|
assertEquals(1, flowFiles.size());
|
||||||
Assert.assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
||||||
MockFlowFile putSuccess = flowFiles.get(0);
|
MockFlowFile putSuccess = flowFiles.get(0);
|
||||||
Assert.assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_C);
|
assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_SSE_C);
|
||||||
|
|
||||||
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_C, randomKeyMaterial);
|
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_SSE_C, randomKeyMaterial);
|
||||||
flowFile.assertContentEquals(data);
|
flowFile.assertContentEquals(data);
|
||||||
|
@ -1127,10 +1123,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, flowFiles.size());
|
assertEquals(1, flowFiles.size());
|
||||||
Assert.assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
||||||
MockFlowFile putSuccess = flowFiles.get(0);
|
MockFlowFile putSuccess = flowFiles.get(0);
|
||||||
Assert.assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS);
|
assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS);
|
||||||
|
|
||||||
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS, kmsKeyId);
|
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS, kmsKeyId);
|
||||||
flowFile.assertContentEquals(data);
|
flowFile.assertContentEquals(data);
|
||||||
|
@ -1161,10 +1157,10 @@ public class ITPutS3Object extends AbstractS3IT {
|
||||||
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS);
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS);
|
||||||
Assert.assertEquals(1, flowFiles.size());
|
assertEquals(1, flowFiles.size());
|
||||||
Assert.assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
assertEquals(0, runner.getFlowFilesForRelationship(PutS3Object.REL_FAILURE).size());
|
||||||
MockFlowFile putSuccess = flowFiles.get(0);
|
MockFlowFile putSuccess = flowFiles.get(0);
|
||||||
Assert.assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_CSE_C);
|
assertEquals(putSuccess.getAttribute(PutS3Object.S3_ENCRYPTION_STRATEGY), AmazonS3EncryptionService.STRATEGY_NAME_CSE_C);
|
||||||
|
|
||||||
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_CSE_C, randomKeyMaterial);
|
MockFlowFile flowFile = fetchEncryptedFlowFile(attrs, AmazonS3EncryptionService.STRATEGY_NAME_CSE_C, randomKeyMaterial);
|
||||||
flowFile.assertAttributeEquals(PutS3Object.S3_ENCRYPTION_STRATEGY, AmazonS3EncryptionService.STRATEGY_NAME_CSE_C);
|
flowFile.assertAttributeEquals(PutS3Object.S3_ENCRYPTION_STRATEGY, AmazonS3EncryptionService.STRATEGY_NAME_CSE_C);
|
||||||
|
|
|
@ -22,14 +22,14 @@ import com.amazonaws.services.s3.model.Tag;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class ITTagS3Object extends AbstractS3IT {
|
public class ITTagS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleTag() throws Exception {
|
public void testSimpleTag() {
|
||||||
String objectKey = "test-file";
|
String objectKey = "test-file";
|
||||||
String tagKey = "nifi-key";
|
String tagKey = "nifi-key";
|
||||||
String tagValue = "nifi-val";
|
String tagValue = "nifi-val";
|
||||||
|
@ -67,11 +67,11 @@ public class ITTagS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
// Verify tag exists on S3 object
|
// Verify tag exists on S3 object
|
||||||
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
||||||
assertTrue("Expected tag not found on S3 object", res.getTagSet().contains(new Tag(tagKey, tagValue)));
|
assertTrue(res.getTagSet().contains(new Tag(tagKey, tagValue)), "Expected tag not found on S3 object");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendTag() throws Exception {
|
public void testAppendTag() {
|
||||||
String objectKey = "test-file";
|
String objectKey = "test-file";
|
||||||
String tagKey = "nifi-key";
|
String tagKey = "nifi-key";
|
||||||
String tagValue = "nifi-val";
|
String tagValue = "nifi-val";
|
||||||
|
@ -101,12 +101,12 @@ public class ITTagS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
// Verify new tag and existing exist on S3 object
|
// Verify new tag and existing exist on S3 object
|
||||||
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
||||||
assertTrue("Expected new tag not found on S3 object", res.getTagSet().contains(new Tag(tagKey, tagValue)));
|
assertTrue(res.getTagSet().contains(new Tag(tagKey, tagValue)), "Expected new tag not found on S3 object");
|
||||||
assertTrue("Expected existing tag not found on S3 object", res.getTagSet().contains(existingTag));
|
assertTrue(res.getTagSet().contains(existingTag), "Expected existing tag not found on S3 object");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplaceTags() throws Exception {
|
public void testReplaceTags() {
|
||||||
String objectKey = "test-file";
|
String objectKey = "test-file";
|
||||||
String tagKey = "nifi-key";
|
String tagKey = "nifi-key";
|
||||||
String tagValue = "nifi-val";
|
String tagValue = "nifi-val";
|
||||||
|
@ -143,8 +143,8 @@ public class ITTagS3Object extends AbstractS3IT {
|
||||||
|
|
||||||
// Verify new tag exists on S3 object and prior tag removed
|
// Verify new tag exists on S3 object and prior tag removed
|
||||||
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
GetObjectTaggingResult res = client.getObjectTagging(new GetObjectTaggingRequest(BUCKET_NAME, objectKey));
|
||||||
assertTrue("Expected new tag not found on S3 object", res.getTagSet().contains(new Tag(tagKey, tagValue)));
|
assertTrue(res.getTagSet().contains(new Tag(tagKey, tagValue)), "Expected new tag not found on S3 object");
|
||||||
assertFalse("Existing tag not replaced on S3 object", res.getTagSet().contains(existingTag));
|
assertFalse(res.getTagSet().contains(existingTag), "Existing tag not replaced on S3 object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,43 +16,38 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.s3;
|
package org.apache.nifi.processors.aws.s3;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.proxy.ProxyConfigurationService;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
||||||
import com.amazonaws.services.s3.model.DeleteObjectRequest;
|
import com.amazonaws.services.s3.model.DeleteObjectRequest;
|
||||||
import com.amazonaws.services.s3.model.DeleteVersionRequest;
|
import com.amazonaws.services.s3.model.DeleteVersionRequest;
|
||||||
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
import org.junit.Before;
|
import org.apache.nifi.proxy.ProxyConfigurationService;
|
||||||
import org.junit.Test;
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.util.HashMap;
|
||||||
import static org.junit.Assert.assertTrue;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestDeleteS3Object {
|
public class TestDeleteS3Object {
|
||||||
|
|
||||||
private TestRunner runner = null;
|
private TestRunner runner = null;
|
||||||
private DeleteS3Object mockDeleteS3Object = null;
|
private DeleteS3Object mockDeleteS3Object = null;
|
||||||
private AmazonS3Client actualS3Client = null;
|
|
||||||
private AmazonS3Client mockS3Client = null;
|
private AmazonS3Client mockS3Client = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
||||||
mockDeleteS3Object = new DeleteS3Object() {
|
mockDeleteS3Object = new DeleteS3Object() {
|
||||||
protected AmazonS3Client getClient() {
|
protected AmazonS3Client getClient() {
|
||||||
actualS3Client = client;
|
|
||||||
return mockS3Client;
|
return mockS3Client;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -60,7 +55,7 @@ public class TestDeleteS3Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteObjectSimple() throws IOException {
|
public void testDeleteObjectSimple() {
|
||||||
runner.setProperty(DeleteS3Object.REGION, "us-west-2");
|
runner.setProperty(DeleteS3Object.REGION, "us-west-2");
|
||||||
runner.setProperty(DeleteS3Object.BUCKET, "test-bucket");
|
runner.setProperty(DeleteS3Object.BUCKET, "test-bucket");
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -139,10 +134,10 @@ public class TestDeleteS3Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPropertyDescriptors() throws Exception {
|
public void testGetPropertyDescriptors() {
|
||||||
DeleteS3Object processor = new DeleteS3Object();
|
DeleteS3Object processor = new DeleteS3Object();
|
||||||
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
||||||
assertEquals("size should be eq", 23, pd.size());
|
assertEquals(23, pd.size(), "size should be eq");
|
||||||
assertTrue(pd.contains(processor.ACCESS_KEY));
|
assertTrue(pd.contains(processor.ACCESS_KEY));
|
||||||
assertTrue(pd.contains(processor.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
assertTrue(pd.contains(processor.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
||||||
assertTrue(pd.contains(processor.BUCKET));
|
assertTrue(pd.contains(processor.BUCKET));
|
||||||
|
|
|
@ -16,16 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.s3;
|
package org.apache.nifi.processors.aws.s3;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.amazonaws.SdkClientException;
|
import com.amazonaws.SdkClientException;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
|
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
||||||
|
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
|
import com.amazonaws.services.s3.model.S3Object;
|
||||||
|
import com.amazonaws.util.StringInputStream;
|
||||||
import org.apache.nifi.components.ConfigVerificationResult;
|
import org.apache.nifi.components.ConfigVerificationResult;
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
|
@ -35,22 +32,23 @@ import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import org.junit.jupiter.api.Test;
|
||||||
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
|
||||||
import com.amazonaws.services.s3.model.GetObjectRequest;
|
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
|
||||||
import com.amazonaws.services.s3.model.S3Object;
|
|
||||||
import com.amazonaws.util.StringInputStream;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -64,7 +62,7 @@ public class TestFetchS3Object {
|
||||||
private AmazonS3Client actualS3Client = null;
|
private AmazonS3Client actualS3Client = null;
|
||||||
private AmazonS3Client mockS3Client = null;
|
private AmazonS3Client mockS3Client = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockS3Client = mock(AmazonS3Client.class);
|
mockS3Client = mock(AmazonS3Client.class);
|
||||||
mockFetchS3Object = new FetchS3Object() {
|
mockFetchS3Object = new FetchS3Object() {
|
||||||
|
|
|
@ -40,8 +40,8 @@ import org.apache.nifi.state.MockStateManager;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestListS3 {
|
public class TestListS3 {
|
||||||
|
@ -65,7 +65,7 @@ public class TestListS3 {
|
||||||
private TestRunner runner = null;
|
private TestRunner runner = null;
|
||||||
private AmazonS3Client mockS3Client = null;
|
private AmazonS3Client mockS3Client = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
||||||
final ListS3 mockListS3 = new ListS3() {
|
final ListS3 mockListS3 = new ListS3() {
|
||||||
|
|
|
@ -16,25 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.s3;
|
package org.apache.nifi.processors.aws.s3;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.amazonaws.services.s3.model.StorageClass;
|
|
||||||
import com.amazonaws.services.s3.model.Tag;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.nifi.components.AllowableValue;
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
import com.amazonaws.ClientConfiguration;
|
||||||
import com.amazonaws.auth.AWSCredentialsProvider;
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
|
||||||
|
@ -45,15 +26,32 @@ import com.amazonaws.services.s3.model.MultipartUploadListing;
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
import com.amazonaws.services.s3.model.PutObjectRequest;
|
import com.amazonaws.services.s3.model.PutObjectRequest;
|
||||||
import com.amazonaws.services.s3.model.PutObjectResult;
|
import com.amazonaws.services.s3.model.PutObjectResult;
|
||||||
|
import com.amazonaws.services.s3.model.StorageClass;
|
||||||
import org.junit.Assert;
|
import com.amazonaws.services.s3.model.Tag;
|
||||||
import org.junit.Before;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.Test;
|
import org.apache.nifi.components.AllowableValue;
|
||||||
|
import org.apache.nifi.components.PropertyDescriptor;
|
||||||
|
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
|
import org.apache.nifi.processor.ProcessContext;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.io.File;
|
||||||
import static org.junit.Assert.assertTrue;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestPutS3Object {
|
public class TestPutS3Object {
|
||||||
|
@ -62,7 +60,7 @@ public class TestPutS3Object {
|
||||||
private PutS3Object putS3Object;
|
private PutS3Object putS3Object;
|
||||||
private AmazonS3Client mockS3Client;
|
private AmazonS3Client mockS3Client;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
||||||
putS3Object = new PutS3Object() {
|
putS3Object = new PutS3Object() {
|
||||||
|
@ -125,11 +123,7 @@ public class TestPutS3Object {
|
||||||
if (!signerType.equals(defaultSignerValue)) {
|
if (!signerType.equals(defaultSignerValue)) {
|
||||||
runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType);
|
runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType);
|
||||||
ProcessContext context = runner.getProcessContext();
|
ProcessContext context = runner.getProcessContext();
|
||||||
try {
|
assertDoesNotThrow(() -> processor.createClient(context, credentialsProvider, config));
|
||||||
processor.createClient(context, credentialsProvider, config);
|
|
||||||
} catch (IllegalArgumentException argEx) {
|
|
||||||
Assert.fail(argEx.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +241,7 @@ public class TestPutS3Object {
|
||||||
public void testGetPropertyDescriptors() {
|
public void testGetPropertyDescriptors() {
|
||||||
PutS3Object processor = new PutS3Object();
|
PutS3Object processor = new PutS3Object();
|
||||||
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
||||||
assertEquals("size should be eq", 39, pd.size());
|
assertEquals(39, pd.size(), "size should be eq");
|
||||||
assertTrue(pd.contains(PutS3Object.ACCESS_KEY));
|
assertTrue(pd.contains(PutS3Object.ACCESS_KEY));
|
||||||
assertTrue(pd.contains(PutS3Object.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
assertTrue(pd.contains(PutS3Object.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
||||||
assertTrue(pd.contains(PutS3Object.BUCKET));
|
assertTrue(pd.contains(PutS3Object.BUCKET));
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.apache.nifi.proxy.ProxyConfigurationService;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestTagS3Object {
|
public class TestTagS3Object {
|
||||||
|
@ -51,7 +51,7 @@ public class TestTagS3Object {
|
||||||
private AmazonS3Client actualS3Client = null;
|
private AmazonS3Client actualS3Client = null;
|
||||||
private AmazonS3Client mockS3Client = null;
|
private AmazonS3Client mockS3Client = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
mockS3Client = Mockito.mock(AmazonS3Client.class);
|
||||||
mockTagS3Object = new TagS3Object() {
|
mockTagS3Object = new TagS3Object() {
|
||||||
|
@ -84,8 +84,8 @@ public class TestTagS3Object {
|
||||||
SetObjectTaggingRequest request = captureRequest.getValue();
|
SetObjectTaggingRequest request = captureRequest.getValue();
|
||||||
assertEquals("test-bucket", request.getBucketName());
|
assertEquals("test-bucket", request.getBucketName());
|
||||||
assertEquals("object-key", request.getKey());
|
assertEquals("object-key", request.getKey());
|
||||||
assertNull("test-version", request.getVersionId());
|
assertNull(request.getVersionId(), "test-version");
|
||||||
assertTrue("Expected tag not found in request", request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)));
|
assertTrue(request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)), "Expected tag not found in request");
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
||||||
MockFlowFile ff0 = flowFiles.get(0);
|
MockFlowFile ff0 = flowFiles.get(0);
|
||||||
|
@ -115,7 +115,7 @@ public class TestTagS3Object {
|
||||||
assertEquals("test-bucket", request.getBucketName());
|
assertEquals("test-bucket", request.getBucketName());
|
||||||
assertEquals("object-key", request.getKey());
|
assertEquals("object-key", request.getKey());
|
||||||
assertEquals("test-version", request.getVersionId());
|
assertEquals("test-version", request.getVersionId());
|
||||||
assertTrue("Expected tag not found in request", request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)));
|
assertTrue(request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)), "Expected tag not found in request");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -143,8 +143,8 @@ public class TestTagS3Object {
|
||||||
SetObjectTaggingRequest request = captureRequest.getValue();
|
SetObjectTaggingRequest request = captureRequest.getValue();
|
||||||
assertEquals("test-bucket", request.getBucketName());
|
assertEquals("test-bucket", request.getBucketName());
|
||||||
assertEquals("object-key", request.getKey());
|
assertEquals("object-key", request.getKey());
|
||||||
assertTrue("New tag not found in request", request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)));
|
assertTrue(request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)), "New tag not found in request");
|
||||||
assertTrue("Existing tag not found in request", request.getTagging().getTagSet().contains(currentTag));
|
assertTrue(request.getTagging().getTagSet().contains(currentTag), "Existing tag not found in request");
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
||||||
MockFlowFile ff0 = flowFiles.get(0);
|
MockFlowFile ff0 = flowFiles.get(0);
|
||||||
|
@ -177,9 +177,9 @@ public class TestTagS3Object {
|
||||||
SetObjectTaggingRequest request = captureRequest.getValue();
|
SetObjectTaggingRequest request = captureRequest.getValue();
|
||||||
assertEquals("test-bucket", request.getBucketName());
|
assertEquals("test-bucket", request.getBucketName());
|
||||||
assertEquals("object-key", request.getKey());
|
assertEquals("object-key", request.getKey());
|
||||||
assertTrue("New tag not found in request", request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)));
|
assertTrue(request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)), "New tag not found in request");
|
||||||
assertTrue("Existing tag not found in request", request.getTagging().getTagSet().contains(currentTag1));
|
assertTrue(request.getTagging().getTagSet().contains(currentTag1), "Existing tag not found in request");
|
||||||
assertFalse("Existing tag should be excluded from request", request.getTagging().getTagSet().contains(currentTag2));
|
assertFalse(request.getTagging().getTagSet().contains(currentTag2), "Existing tag should be excluded from request");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -208,8 +208,8 @@ public class TestTagS3Object {
|
||||||
SetObjectTaggingRequest request = captureRequest.getValue();
|
SetObjectTaggingRequest request = captureRequest.getValue();
|
||||||
assertEquals("test-bucket", request.getBucketName());
|
assertEquals("test-bucket", request.getBucketName());
|
||||||
assertEquals("object-key", request.getKey());
|
assertEquals("object-key", request.getKey());
|
||||||
assertTrue("New tag not found in request", request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)));
|
assertTrue(request.getTagging().getTagSet().contains(new Tag(tagKey, tagVal)), "New tag not found in request");
|
||||||
assertFalse("Existing tag should be excluded from request", request.getTagging().getTagSet().contains(currentTag));
|
assertFalse(request.getTagging().getTagSet().contains(currentTag), "Existing tag should be excluded from request");
|
||||||
|
|
||||||
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS);
|
||||||
MockFlowFile ff0 = flowFiles.get(0);
|
MockFlowFile ff0 = flowFiles.get(0);
|
||||||
|
@ -244,7 +244,7 @@ public class TestTagS3Object {
|
||||||
public void testGetPropertyDescriptors() throws Exception {
|
public void testGetPropertyDescriptors() throws Exception {
|
||||||
TagS3Object processor = new TagS3Object();
|
TagS3Object processor = new TagS3Object();
|
||||||
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
|
||||||
assertEquals("size should be eq", 20, pd.size());
|
assertEquals(20, pd.size(), "size should be eq");
|
||||||
assertTrue(pd.contains(TagS3Object.ACCESS_KEY));
|
assertTrue(pd.contains(TagS3Object.ACCESS_KEY));
|
||||||
assertTrue(pd.contains(TagS3Object.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
assertTrue(pd.contains(TagS3Object.AWS_CREDENTIALS_PROVIDER_SERVICE));
|
||||||
assertTrue(pd.contains(TagS3Object.BUCKET));
|
assertTrue(pd.contains(TagS3Object.BUCKET));
|
||||||
|
|
|
@ -17,18 +17,18 @@
|
||||||
package org.apache.nifi.processors.aws.s3.encryption;
|
package org.apache.nifi.processors.aws.s3.encryption;
|
||||||
|
|
||||||
import org.apache.nifi.components.ValidationResult;
|
import org.apache.nifi.components.ValidationResult;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.processors.aws.s3.encryption.S3EncryptionTestUtil.createKey;
|
import static org.apache.nifi.processors.aws.s3.encryption.S3EncryptionTestUtil.createKey;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestClientSideCEncryptionStrategyKeyValidation {
|
public class TestClientSideCEncryptionStrategyKeyValidation {
|
||||||
|
|
||||||
private ClientSideCEncryptionStrategy strategy;
|
private ClientSideCEncryptionStrategy strategy;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
strategy = new ClientSideCEncryptionStrategy();
|
strategy = new ClientSideCEncryptionStrategy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,15 @@ import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
import com.amazonaws.services.s3.model.PutObjectRequest;
|
import com.amazonaws.services.s3.model.PutObjectRequest;
|
||||||
import com.amazonaws.services.s3.model.UploadPartRequest;
|
import com.amazonaws.services.s3.model.UploadPartRequest;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
|
||||||
public class TestS3EncryptionStrategies {
|
public class TestS3EncryptionStrategies {
|
||||||
|
|
||||||
|
@ -41,7 +44,7 @@ public class TestS3EncryptionStrategies {
|
||||||
private GetObjectRequest getObjectRequest = null;
|
private GetObjectRequest getObjectRequest = null;
|
||||||
private UploadPartRequest uploadPartRequest = null;
|
private UploadPartRequest uploadPartRequest = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
byte[] keyRawBytes = new byte[32];
|
byte[] keyRawBytes = new byte[32];
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
@ -60,19 +63,19 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new ClientSideKMSEncryptionStrategy();
|
S3EncryptionStrategy strategy = new ClientSideKMSEncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy builds a client:
|
// This shows that the strategy builds a client:
|
||||||
Assert.assertNotNull(strategy.createEncryptionClient(null, null, kmsRegion, randomKeyMaterial));
|
assertNotNull(strategy.createEncryptionClient(null, null, kmsRegion, randomKeyMaterial));
|
||||||
|
|
||||||
// This shows that the strategy does not modify the metadata or any of the requests:
|
// This shows that the strategy does not modify the metadata or any of the requests:
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
Assert.assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(initUploadRequest.getSSECustomerKey());
|
assertNull(initUploadRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(getObjectRequest.getSSECustomerKey());
|
assertNull(getObjectRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(uploadPartRequest.getSSECustomerKey());
|
assertNull(uploadPartRequest.getSSECustomerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -80,19 +83,19 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new ClientSideCEncryptionStrategy();
|
S3EncryptionStrategy strategy = new ClientSideCEncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy builds a client:
|
// This shows that the strategy builds a client:
|
||||||
Assert.assertNotNull(strategy.createEncryptionClient(null, null, null, randomKeyMaterial));
|
assertNotNull(strategy.createEncryptionClient(null, null, null, randomKeyMaterial));
|
||||||
|
|
||||||
// This shows that the strategy does not modify the metadata or any of the requests:
|
// This shows that the strategy does not modify the metadata or any of the requests:
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
Assert.assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(initUploadRequest.getSSECustomerKey());
|
assertNull(initUploadRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(getObjectRequest.getSSECustomerKey());
|
assertNull(getObjectRequest.getSSECustomerKey());
|
||||||
|
|
||||||
Assert.assertNull(uploadPartRequest.getSSECustomerKey());
|
assertNull(uploadPartRequest.getSSECustomerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -100,29 +103,29 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new ServerSideCEncryptionStrategy();
|
S3EncryptionStrategy strategy = new ServerSideCEncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy does *not* build a client:
|
// This shows that the strategy does *not* build a client:
|
||||||
Assert.assertNull(strategy.createEncryptionClient(null, null, null, ""));
|
assertNull(strategy.createEncryptionClient(null, null, null, ""));
|
||||||
|
|
||||||
// This shows that the strategy sets the SSE customer key as expected:
|
// This shows that the strategy sets the SSE customer key as expected:
|
||||||
strategy.configurePutObjectRequest(putObjectRequest, metadata, randomKeyMaterial);
|
strategy.configurePutObjectRequest(putObjectRequest, metadata, randomKeyMaterial);
|
||||||
Assert.assertEquals(randomKeyMaterial, putObjectRequest.getSSECustomerKey().getKey());
|
assertEquals(randomKeyMaterial, putObjectRequest.getSSECustomerKey().getKey());
|
||||||
Assert.assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
// Same for InitiateMultipartUploadRequest:
|
// Same for InitiateMultipartUploadRequest:
|
||||||
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, randomKeyMaterial);
|
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, randomKeyMaterial);
|
||||||
Assert.assertEquals(randomKeyMaterial, initUploadRequest.getSSECustomerKey().getKey());
|
assertEquals(randomKeyMaterial, initUploadRequest.getSSECustomerKey().getKey());
|
||||||
Assert.assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
assertNull(initUploadRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
// Same for GetObjectRequest:
|
// Same for GetObjectRequest:
|
||||||
strategy.configureGetObjectRequest(getObjectRequest, metadata, randomKeyMaterial);
|
strategy.configureGetObjectRequest(getObjectRequest, metadata, randomKeyMaterial);
|
||||||
Assert.assertEquals(randomKeyMaterial, initUploadRequest.getSSECustomerKey().getKey());
|
assertEquals(randomKeyMaterial, initUploadRequest.getSSECustomerKey().getKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
// Same for UploadPartRequest:
|
// Same for UploadPartRequest:
|
||||||
strategy.configureUploadPartRequest(uploadPartRequest, metadata, randomKeyMaterial);
|
strategy.configureUploadPartRequest(uploadPartRequest, metadata, randomKeyMaterial);
|
||||||
Assert.assertEquals(randomKeyMaterial, uploadPartRequest.getSSECustomerKey().getKey());
|
assertEquals(randomKeyMaterial, uploadPartRequest.getSSECustomerKey().getKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -130,19 +133,19 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new ServerSideKMSEncryptionStrategy();
|
S3EncryptionStrategy strategy = new ServerSideKMSEncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy does *not* build a client:
|
// This shows that the strategy does *not* build a client:
|
||||||
Assert.assertNull(strategy.createEncryptionClient(null, null, null, null));
|
assertNull(strategy.createEncryptionClient(null, null, null, null));
|
||||||
|
|
||||||
// This shows that the strategy sets the SSE KMS key id as expected:
|
// This shows that the strategy sets the SSE KMS key id as expected:
|
||||||
strategy.configurePutObjectRequest(putObjectRequest, metadata, randomKeyId);
|
strategy.configurePutObjectRequest(putObjectRequest, metadata, randomKeyId);
|
||||||
Assert.assertEquals(randomKeyId, putObjectRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
|
assertEquals(randomKeyId, putObjectRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
// Same for InitiateMultipartUploadRequest:
|
// Same for InitiateMultipartUploadRequest:
|
||||||
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, randomKeyId);
|
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, randomKeyId);
|
||||||
Assert.assertEquals(randomKeyId, initUploadRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
|
assertEquals(randomKeyId, initUploadRequest.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
|
||||||
Assert.assertNull(initUploadRequest.getSSECustomerKey());
|
assertNull(initUploadRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -150,15 +153,15 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new ServerSideS3EncryptionStrategy();
|
S3EncryptionStrategy strategy = new ServerSideS3EncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy does *not* build a client:
|
// This shows that the strategy does *not* build a client:
|
||||||
Assert.assertNull(strategy.createEncryptionClient(null, null, null, null));
|
assertNull(strategy.createEncryptionClient(null, null, null, null));
|
||||||
|
|
||||||
// This shows that the strategy sets the SSE algorithm field as expected:
|
// This shows that the strategy sets the SSE algorithm field as expected:
|
||||||
strategy.configurePutObjectRequest(putObjectRequest, metadata, null);
|
strategy.configurePutObjectRequest(putObjectRequest, metadata, null);
|
||||||
Assert.assertEquals(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION, metadata.getSSEAlgorithm());
|
assertEquals(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION, metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
// Same for InitiateMultipartUploadRequest:
|
// Same for InitiateMultipartUploadRequest:
|
||||||
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, null);
|
strategy.configureInitiateMultipartUploadRequest(initUploadRequest, metadata, null);
|
||||||
Assert.assertEquals(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION, metadata.getSSEAlgorithm());
|
assertEquals(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION, metadata.getSSEAlgorithm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -166,19 +169,19 @@ public class TestS3EncryptionStrategies {
|
||||||
S3EncryptionStrategy strategy = new NoOpEncryptionStrategy();
|
S3EncryptionStrategy strategy = new NoOpEncryptionStrategy();
|
||||||
|
|
||||||
// This shows that the strategy does *not* build a client:
|
// This shows that the strategy does *not* build a client:
|
||||||
Assert.assertNull(strategy.createEncryptionClient(null, null, "", ""));
|
assertNull(strategy.createEncryptionClient(null, null, "", ""));
|
||||||
|
|
||||||
// This shows the request and metadata start with various null objects:
|
// This shows the request and metadata start with various null objects:
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
Assert.assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
|
|
||||||
// Act:
|
// Act:
|
||||||
strategy.configurePutObjectRequest(putObjectRequest, metadata, "");
|
strategy.configurePutObjectRequest(putObjectRequest, metadata, "");
|
||||||
|
|
||||||
// This shows that the request and metadata were not changed:
|
// This shows that the request and metadata were not changed:
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
Assert.assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
assertNull(putObjectRequest.getSSEAwsKeyManagementParams());
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,18 +17,18 @@
|
||||||
package org.apache.nifi.processors.aws.s3.encryption;
|
package org.apache.nifi.processors.aws.s3.encryption;
|
||||||
|
|
||||||
import org.apache.nifi.components.ValidationResult;
|
import org.apache.nifi.components.ValidationResult;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.processors.aws.s3.encryption.S3EncryptionTestUtil.createKey;
|
import static org.apache.nifi.processors.aws.s3.encryption.S3EncryptionTestUtil.createKey;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestServerSideCEncryptionStrategyKeyValidation {
|
public class TestServerSideCEncryptionStrategyKeyValidation {
|
||||||
|
|
||||||
private ServerSideCEncryptionStrategy strategy;
|
private ServerSideCEncryptionStrategy strategy;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
strategy = new ServerSideCEncryptionStrategy();
|
strategy = new ServerSideCEncryptionStrategy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,15 @@ import org.apache.nifi.controller.ConfigurationContext;
|
||||||
import org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService;
|
import org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
|
||||||
public class TestStandardS3EncryptionService {
|
public class TestStandardS3EncryptionService {
|
||||||
private StandardS3EncryptionService service;
|
private StandardS3EncryptionService service;
|
||||||
|
@ -40,7 +43,7 @@ public class TestStandardS3EncryptionService {
|
||||||
private String keyIdOrMaterial;
|
private String keyIdOrMaterial;
|
||||||
private String kmsRegion;
|
private String kmsRegion;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws InitializationException {
|
public void setup() throws InitializationException {
|
||||||
service = new StandardS3EncryptionService();
|
service = new StandardS3EncryptionService();
|
||||||
context = Mockito.mock(ConfigurationContext.class);
|
context = Mockito.mock(ConfigurationContext.class);
|
||||||
|
@ -57,13 +60,13 @@ public class TestStandardS3EncryptionService {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServiceProperties() {
|
public void testServiceProperties() {
|
||||||
Assert.assertEquals(service.getKmsRegion(), kmsRegion);
|
assertEquals(service.getKmsRegion(), kmsRegion);
|
||||||
Assert.assertEquals(service.getStrategyName(), strategyName);
|
assertEquals(service.getStrategyName(), strategyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateClientReturnsNull() {
|
public void testCreateClientReturnsNull() {
|
||||||
Assert.assertNull(service.createEncryptionClient(null, null));
|
assertNull(service.createEncryptionClient(null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -75,29 +78,29 @@ public class TestStandardS3EncryptionService {
|
||||||
final UploadPartRequest uploadPartRequest = new UploadPartRequest();
|
final UploadPartRequest uploadPartRequest = new UploadPartRequest();
|
||||||
|
|
||||||
service.configureGetObjectRequest(getObjectRequest, metadata);
|
service.configureGetObjectRequest(getObjectRequest, metadata);
|
||||||
Assert.assertNull(getObjectRequest.getSSECustomerKey());
|
assertNull(getObjectRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
service.configureUploadPartRequest(uploadPartRequest, metadata);
|
service.configureUploadPartRequest(uploadPartRequest, metadata);
|
||||||
Assert.assertNull(uploadPartRequest.getSSECustomerKey());
|
assertNull(uploadPartRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
service.configurePutObjectRequest(putObjectRequest, metadata);
|
service.configurePutObjectRequest(putObjectRequest, metadata);
|
||||||
Assert.assertNull(putObjectRequest.getSSECustomerKey());
|
assertNull(putObjectRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
|
|
||||||
service.configureInitiateMultipartUploadRequest(initUploadRequest, metadata);
|
service.configureInitiateMultipartUploadRequest(initUploadRequest, metadata);
|
||||||
Assert.assertNull(initUploadRequest.getSSECustomerKey());
|
assertNull(initUploadRequest.getSSECustomerKey());
|
||||||
Assert.assertNull(metadata.getSSEAlgorithm());
|
assertNull(metadata.getSSEAlgorithm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProperties() {
|
public void testProperties() {
|
||||||
List<PropertyDescriptor> properties = service.getSupportedPropertyDescriptors();
|
List<PropertyDescriptor> properties = service.getSupportedPropertyDescriptors();
|
||||||
Assert.assertEquals(3, properties.size());
|
assertEquals(3, properties.size());
|
||||||
|
|
||||||
Assert.assertEquals(properties.get(0).getName(), StandardS3EncryptionService.ENCRYPTION_STRATEGY.getName());
|
assertEquals(properties.get(0).getName(), StandardS3EncryptionService.ENCRYPTION_STRATEGY.getName());
|
||||||
Assert.assertEquals(properties.get(1).getName(), StandardS3EncryptionService.ENCRYPTION_VALUE.getName());
|
assertEquals(properties.get(1).getName(), StandardS3EncryptionService.ENCRYPTION_VALUE.getName());
|
||||||
Assert.assertEquals(properties.get(2).getName(), StandardS3EncryptionService.KMS_REGION.getName());
|
assertEquals(properties.get(2).getName(), StandardS3EncryptionService.KMS_REGION.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.util.NoOpProcessor;
|
import org.apache.nifi.util.NoOpProcessor;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService.STRATEGY_NAME_CSE_C;
|
import static org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService.STRATEGY_NAME_CSE_C;
|
||||||
import static org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS;
|
import static org.apache.nifi.processors.aws.s3.AmazonS3EncryptionService.STRATEGY_NAME_CSE_KMS;
|
||||||
|
@ -36,7 +36,7 @@ public class TestStandardS3EncryptionServiceValidation {
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
private StandardS3EncryptionService service;
|
private StandardS3EncryptionService service;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws InitializationException {
|
public void setUp() throws InitializationException {
|
||||||
runner = TestRunners.newTestRunner(NoOpProcessor.class);
|
runner = TestRunners.newTestRunner(NoOpProcessor.class);
|
||||||
service = new StandardS3EncryptionService();
|
service = new StandardS3EncryptionService();
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sns;
|
package org.apache.nifi.processors.aws.sns;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
||||||
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides integration level testing with actual AWS S3 resources for {@link PutSNS} and requires additional configuration and resources to work.
|
* Provides integration level testing with actual AWS S3 resources for {@link PutSNS} and requires additional configuration and resources to work.
|
||||||
|
|
|
@ -16,43 +16,39 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sns;
|
package org.apache.nifi.processors.aws.sns;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import com.amazonaws.services.sns.AmazonSNSClient;
|
import com.amazonaws.services.sns.AmazonSNSClient;
|
||||||
import com.amazonaws.services.sns.model.AmazonSNSException;
|
import com.amazonaws.services.sns.model.AmazonSNSException;
|
||||||
import com.amazonaws.services.sns.model.PublishRequest;
|
import com.amazonaws.services.sns.model.PublishRequest;
|
||||||
import com.amazonaws.services.sns.model.PublishResult;
|
import com.amazonaws.services.sns.model.PublishResult;
|
||||||
|
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestPutSNS {
|
public class TestPutSNS {
|
||||||
|
|
||||||
private TestRunner runner = null;
|
private TestRunner runner = null;
|
||||||
private PutSNS mockPutSNS = null;
|
private PutSNS mockPutSNS = null;
|
||||||
private AmazonSNSClient actualSNSClient = null;
|
|
||||||
private AmazonSNSClient mockSNSClient = null;
|
private AmazonSNSClient mockSNSClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockSNSClient = Mockito.mock(AmazonSNSClient.class);
|
mockSNSClient = Mockito.mock(AmazonSNSClient.class);
|
||||||
mockPutSNS = new PutSNS() {
|
mockPutSNS = new PutSNS() {
|
||||||
@Override
|
@Override
|
||||||
protected AmazonSNSClient getClient() {
|
protected AmazonSNSClient getClient() {
|
||||||
actualSNSClient = client;
|
|
||||||
return mockSNSClient;
|
return mockSNSClient;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -60,7 +56,7 @@ public class TestPutSNS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublish() throws IOException {
|
public void testPublish() {
|
||||||
runner.setProperty(PutSNS.CREDENTIALS_FILE, "src/test/resources/mock-aws-credentials.properties");
|
runner.setProperty(PutSNS.CREDENTIALS_FILE, "src/test/resources/mock-aws-credentials.properties");
|
||||||
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1");
|
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1");
|
||||||
runner.setProperty(PutSNS.SUBJECT, "${eval.subject}");
|
runner.setProperty(PutSNS.SUBJECT, "${eval.subject}");
|
||||||
|
@ -90,7 +86,7 @@ public class TestPutSNS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishFIFO() throws IOException {
|
public void testPublishFIFO() {
|
||||||
runner.setProperty(PutSNS.CREDENTIALS_FILE, "src/test/resources/mock-aws-credentials.properties");
|
runner.setProperty(PutSNS.CREDENTIALS_FILE, "src/test/resources/mock-aws-credentials.properties");
|
||||||
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1.fifo");
|
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1.fifo");
|
||||||
runner.setProperty(PutSNS.SUBJECT, "${eval.subject}");
|
runner.setProperty(PutSNS.SUBJECT, "${eval.subject}");
|
||||||
|
@ -125,7 +121,7 @@ public class TestPutSNS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishFailure() throws IOException {
|
public void testPublishFailure() {
|
||||||
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1");
|
runner.setProperty(PutSNS.ARN, "arn:aws:sns:us-west-2:123456789012:test-topic-1");
|
||||||
final Map<String, String> ffAttributes = new HashMap<>();
|
final Map<String, String> ffAttributes = new HashMap<>();
|
||||||
ffAttributes.put("filename", "1.txt");
|
ffAttributes.put("filename", "1.txt");
|
||||||
|
@ -138,5 +134,4 @@ public class TestPutSNS {
|
||||||
Mockito.verify(mockSNSClient, Mockito.times(1)).publish(captureRequest.capture());
|
Mockito.verify(mockSNSClient, Mockito.times(1)).publish(captureRequest.capture());
|
||||||
runner.assertAllFlowFilesTransferred(PutSNS.REL_FAILURE, 1);
|
runner.assertAllFlowFilesTransferred(PutSNS.REL_FAILURE, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -16,29 +16,24 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import java.io.File;
|
import com.amazonaws.auth.PropertiesCredentials;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.amazonaws.regions.Regions;
|
import com.amazonaws.regions.Regions;
|
||||||
|
import com.amazonaws.services.sqs.AmazonSQSClient;
|
||||||
import com.amazonaws.services.sqs.model.Message;
|
import com.amazonaws.services.sqs.model.Message;
|
||||||
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
|
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
|
||||||
import com.amazonaws.services.sqs.model.SendMessageResult;
|
import com.amazonaws.services.sqs.model.SendMessageResult;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.amazonaws.auth.PropertiesCredentials;
|
import java.io.File;
|
||||||
import com.amazonaws.services.sqs.AmazonSQSClient;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary queues created")
|
|
||||||
public class ITDeleteSQS {
|
public class ITDeleteSQS {
|
||||||
|
|
||||||
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
@ -46,7 +41,7 @@ public class ITDeleteSQS {
|
||||||
private final String TEST_REGION = "us-west-2";
|
private final String TEST_REGION = "us-west-2";
|
||||||
AmazonSQSClient sqsClient = null;
|
AmazonSQSClient sqsClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws IOException {
|
public void setUp() throws IOException {
|
||||||
PropertiesCredentials credentials = new PropertiesCredentials(new File(CREDENTIALS_FILE));
|
PropertiesCredentials credentials = new PropertiesCredentials(new File(CREDENTIALS_FILE));
|
||||||
sqsClient = new AmazonSQSClient(credentials);
|
sqsClient = new AmazonSQSClient(credentials);
|
||||||
|
@ -54,7 +49,7 @@ public class ITDeleteSQS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleDelete() throws IOException {
|
public void testSimpleDelete() {
|
||||||
// Setup - put one message in queue
|
// Setup - put one message in queue
|
||||||
SendMessageResult sendMessageResult = sqsClient.sendMessage(TEST_QUEUE_URL, "Test message");
|
SendMessageResult sendMessageResult = sqsClient.sendMessage(TEST_QUEUE_URL, "Test message");
|
||||||
assertEquals(200, sendMessageResult.getSdkHttpMetadata().getHttpStatusCode());
|
assertEquals(200, sendMessageResult.getSdkHttpMetadata().getHttpStatusCode());
|
||||||
|
@ -79,5 +74,4 @@ public class ITDeleteSQS {
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(DeleteSQS.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(DeleteSQS.REL_SUCCESS, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -16,18 +16,16 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
import org.apache.nifi.processors.aws.AbstractAWSProcessor;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
import org.apache.nifi.processors.aws.sns.PutSNS;
|
import org.apache.nifi.processors.aws.sns.PutSNS;
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Ignore;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Ignore("For local testing only - interacts with S3 so the credentials file must be configured and all necessary buckets created")
|
|
||||||
public class ITGetSQS {
|
public class ITGetSQS {
|
||||||
|
|
||||||
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
|
|
@ -16,21 +16,20 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.amazonaws.regions.Regions;
|
import com.amazonaws.regions.Regions;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors;
|
import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors;
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@Ignore("For local testing only - interacts with SQS so the credentials file must be configured and all necessary queues created")
|
|
||||||
public class ITPutSQS {
|
public class ITPutSQS {
|
||||||
|
|
||||||
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
private final String CREDENTIALS_FILE = System.getProperty("user.home") + "/aws-credentials.properties";
|
||||||
|
@ -46,7 +45,7 @@ public class ITPutSQS {
|
||||||
runner.setProperty(PutSQS.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
runner.setProperty(PutSQS.CREDENTIALS_FILE, CREDENTIALS_FILE);
|
||||||
runner.setProperty(PutSQS.REGION, REGION);
|
runner.setProperty(PutSQS.REGION, REGION);
|
||||||
runner.setProperty(PutSQS.QUEUE_URL, QUEUE_URL);
|
runner.setProperty(PutSQS.QUEUE_URL, QUEUE_URL);
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
attrs.put("filename", "1.txt");
|
attrs.put("filename", "1.txt");
|
||||||
|
|
|
@ -16,24 +16,22 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.services.sqs.AmazonSQSClient;
|
import com.amazonaws.services.sqs.AmazonSQSClient;
|
||||||
import com.amazonaws.services.sqs.model.AmazonSQSException;
|
import com.amazonaws.services.sqs.model.AmazonSQSException;
|
||||||
import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
|
import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
|
||||||
import com.amazonaws.services.sqs.model.DeleteMessageBatchResult;
|
import com.amazonaws.services.sqs.model.DeleteMessageBatchResult;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.junit.Before;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class TestDeleteSQS {
|
public class TestDeleteSQS {
|
||||||
|
@ -42,7 +40,7 @@ public class TestDeleteSQS {
|
||||||
private DeleteSQS mockDeleteSQS = null;
|
private DeleteSQS mockDeleteSQS = null;
|
||||||
private AmazonSQSClient mockSQSClient = null;
|
private AmazonSQSClient mockSQSClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
||||||
DeleteMessageBatchResult mockResponse = Mockito.mock(DeleteMessageBatchResult.class);
|
DeleteMessageBatchResult mockResponse = Mockito.mock(DeleteMessageBatchResult.class);
|
||||||
|
|
|
@ -16,40 +16,36 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
|
|
||||||
import com.amazonaws.services.sqs.AmazonSQSClient;
|
import com.amazonaws.services.sqs.AmazonSQSClient;
|
||||||
import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
|
import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
|
||||||
import com.amazonaws.services.sqs.model.Message;
|
import com.amazonaws.services.sqs.model.Message;
|
||||||
import com.amazonaws.services.sqs.model.MessageAttributeValue;
|
import com.amazonaws.services.sqs.model.MessageAttributeValue;
|
||||||
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
|
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
|
||||||
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
|
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.junit.Before;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.junit.Test;
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class TestGetSQS {
|
public class TestGetSQS {
|
||||||
|
|
||||||
private TestRunner runner = null;
|
private TestRunner runner = null;
|
||||||
private GetSQS mockGetSQS = null;
|
private GetSQS mockGetSQS = null;
|
||||||
private AmazonSQSClient actualSQSClient = null;
|
|
||||||
private AmazonSQSClient mockSQSClient = null;
|
private AmazonSQSClient mockSQSClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
||||||
mockGetSQS = new GetSQS() {
|
mockGetSQS = new GetSQS() {
|
||||||
protected AmazonSQSClient getClient() {
|
protected AmazonSQSClient getClient() {
|
||||||
actualSQSClient = client;
|
|
||||||
return mockSQSClient;
|
return mockSQSClient;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,24 +16,22 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.aws.sqs;
|
package org.apache.nifi.processors.aws.sqs;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import com.amazonaws.services.sqs.AmazonSQSClient;
|
import com.amazonaws.services.sqs.AmazonSQSClient;
|
||||||
import com.amazonaws.services.sqs.model.AmazonSQSException;
|
import com.amazonaws.services.sqs.model.AmazonSQSException;
|
||||||
import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
|
import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
|
||||||
import com.amazonaws.services.sqs.model.SendMessageBatchResult;
|
import com.amazonaws.services.sqs.model.SendMessageBatchResult;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class TestPutSQS {
|
public class TestPutSQS {
|
||||||
|
@ -43,7 +41,7 @@ public class TestPutSQS {
|
||||||
private AmazonSQSClient actualSQSClient = null;
|
private AmazonSQSClient actualSQSClient = null;
|
||||||
private AmazonSQSClient mockSQSClient = null;
|
private AmazonSQSClient mockSQSClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
mockSQSClient = Mockito.mock(AmazonSQSClient.class);
|
||||||
mockPutSQS = new PutSQS() {
|
mockPutSQS = new PutSQS() {
|
||||||
|
@ -57,9 +55,9 @@ public class TestPutSQS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimplePut() throws IOException {
|
public void testSimplePut() {
|
||||||
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
attrs.put("filename", "1.txt");
|
attrs.put("filename", "1.txt");
|
||||||
|
@ -81,7 +79,7 @@ public class TestPutSQS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPutException() throws IOException {
|
public void testPutException() {
|
||||||
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
@ -102,11 +100,11 @@ public class TestPutSQS {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFIFOPut() throws IOException {
|
public void testFIFOPut() {
|
||||||
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
runner.setProperty(PutSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000");
|
||||||
runner.setProperty(PutSQS.MESSAGEDEDUPLICATIONID, "${myuuid}");
|
runner.setProperty(PutSQS.MESSAGEDEDUPLICATIONID, "${myuuid}");
|
||||||
runner.setProperty(PutSQS.MESSAGEGROUPID, "test1234");
|
runner.setProperty(PutSQS.MESSAGEGROUPID, "test1234");
|
||||||
Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());
|
||||||
|
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
attrs.put("filename", "1.txt");
|
attrs.put("filename", "1.txt");
|
||||||
|
@ -129,5 +127,4 @@ public class TestPutSQS {
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,18 @@
|
||||||
|
|
||||||
package org.apache.nifi.processors.aws.wag;
|
package org.apache.nifi.processors.aws.wag;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
import static org.junit.Assert.assertThrows;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import static org.junit.Assert.assertTrue;
|
import okhttp3.mockwebserver.RecordedRequest;
|
||||||
|
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
|
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
||||||
|
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
||||||
|
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
||||||
|
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||||
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -29,21 +38,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import okhttp3.mockwebserver.RecordedRequest;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
|
||||||
import org.apache.nifi.processors.aws.AbstractAWSCredentialsProviderProcessor;
|
|
||||||
import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderControllerService;
|
|
||||||
import org.apache.nifi.provenance.ProvenanceEventRecord;
|
|
||||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public abstract class TestInvokeAWSGatewayApiCommon {
|
public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
|
@ -555,7 +552,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Internal Server Error");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Internal Server Error");
|
||||||
|
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -586,7 +583,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "302");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "302");
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Moved Temporarily");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Moved Temporarily");
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -617,7 +614,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "304");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "304");
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Not Modified");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Not Modified");
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -647,7 +644,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "400");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "400");
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Bad Request");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Bad Request");
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -678,7 +675,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "400");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "400");
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Bad Request");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Bad Request");
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +705,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "412");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_CODE, "412");
|
||||||
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Precondition Failed");
|
bundle.assertAttributeEquals(InvokeAWSGatewayApi.STATUS_MESSAGE, "Precondition Failed");
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -747,7 +744,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle1.assertAttributeEquals("Foo", "Bar");
|
bundle1.assertAttributeEquals("Foo", "Bar");
|
||||||
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected1 = "";
|
final String expected1 = "";
|
||||||
Assert.assertEquals(expected1, actual1);
|
assertEquals(expected1, actual1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -786,7 +783,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected1 = "";
|
final String expected1 = "";
|
||||||
Assert.assertEquals(expected1, actual1);
|
assertEquals(expected1, actual1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -959,7 +956,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected1 = "";
|
final String expected1 = "";
|
||||||
Assert.assertEquals(expected1, actual1);
|
assertEquals(expected1, actual1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -996,7 +993,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected1 = "";
|
final String expected1 = "";
|
||||||
Assert.assertEquals(expected1, actual1);
|
assertEquals(expected1, actual1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1088,7 +1085,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
bundle1.assertAttributeEquals("Foo", "Bar");
|
bundle1.assertAttributeEquals("Foo", "Bar");
|
||||||
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
final String actual1 = new String(bundle1.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected1 = "";
|
final String expected1 = "";
|
||||||
Assert.assertEquals(expected1, actual1);
|
assertEquals(expected1, actual1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1191,7 +1188,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,7 +1216,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1246,7 +1243,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
final String actual = new String(bundle.toByteArray(), StandardCharsets.UTF_8);
|
||||||
final String expected = "Hello";
|
final String expected = "Hello";
|
||||||
Assert.assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
bundle.assertAttributeEquals("Foo", "Bar");
|
bundle.assertAttributeEquals("Foo", "Bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,6 +1275,7 @@ public abstract class TestInvokeAWSGatewayApiCommon {
|
||||||
runner.setProperty(InvokeAWSGatewayApi.PROP_AWS_GATEWAY_API_ENDPOINT, "http://nifi.apache.org/");
|
runner.setProperty(InvokeAWSGatewayApi.PROP_AWS_GATEWAY_API_ENDPOINT, "http://nifi.apache.org/");
|
||||||
runner.setProperty(InvokeAWSGatewayApi.PROP_RESOURCE_NAME, "/status/200");
|
runner.setProperty(InvokeAWSGatewayApi.PROP_RESOURCE_NAME, "/status/200");
|
||||||
runner.setProperty(InvokeAWSGatewayApi.PROXY_HOST, "${proxy.host}");
|
runner.setProperty(InvokeAWSGatewayApi.PROXY_HOST, "${proxy.host}");
|
||||||
|
|
||||||
runner.setProperty(InvokeAWSGatewayApi.PROXY_HOST_PORT, "${proxy.port}");
|
runner.setProperty(InvokeAWSGatewayApi.PROXY_HOST_PORT, "${proxy.port}");
|
||||||
runner.setProperty(InvokeAWSGatewayApi.PROXY_USERNAME, "${proxy.username}");
|
runner.setProperty(InvokeAWSGatewayApi.PROXY_USERNAME, "${proxy.username}");
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredential
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -52,7 +52,7 @@ public class TestInvokeAmazonGatewayApiMock {
|
||||||
private TestRunner runner = null;
|
private TestRunner runner = null;
|
||||||
private SdkHttpClient mockSdkClient = null;
|
private SdkHttpClient mockSdkClient = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mockSdkClient = Mockito.mock(SdkHttpClient.class);
|
mockSdkClient = Mockito.mock(SdkHttpClient.class);
|
||||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
ClientConfiguration clientConfig = new ClientConfiguration();
|
||||||
|
|
|
@ -18,13 +18,13 @@ package org.apache.nifi.processors.aws.wag;
|
||||||
|
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class TestInvokeInvokeAmazonGatewayApi extends TestInvokeAWSGatewayApiCommon {
|
public class TestInvokeInvokeAmazonGatewayApi extends TestInvokeAWSGatewayApiCommon {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
runner = TestRunners.newTestRunner(InvokeAWSGatewayApi.class);
|
runner = TestRunners.newTestRunner(InvokeAWSGatewayApi.class);
|
||||||
runner.setValidateExpressionUsage(false);
|
runner.setValidateExpressionUsage(false);
|
||||||
|
@ -32,7 +32,7 @@ public class TestInvokeInvokeAmazonGatewayApi extends TestInvokeAWSGatewayApiCom
|
||||||
mockWebServer = new MockWebServer();
|
mockWebServer = new MockWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void after() {
|
public void after() {
|
||||||
runner.shutdown();
|
runner.shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,30 +17,31 @@
|
||||||
|
|
||||||
package org.apache.nifi.authorization.azure;
|
package org.apache.nifi.authorization.azure;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.nifi.authorization.AuthorizerConfigurationContext;
|
import org.apache.nifi.authorization.AuthorizerConfigurationContext;
|
||||||
import org.apache.nifi.authorization.Group;
|
import org.apache.nifi.authorization.Group;
|
||||||
import org.apache.nifi.authorization.UserAndGroups;
|
import org.apache.nifi.authorization.UserAndGroups;
|
||||||
import org.apache.nifi.authorization.UserGroupProviderInitializationContext;
|
import org.apache.nifi.authorization.UserGroupProviderInitializationContext;
|
||||||
import org.apache.nifi.util.MockPropertyValue;
|
import org.apache.nifi.util.MockPropertyValue;
|
||||||
import org.apache.nifi.util.file.FileUtils;
|
import org.apache.nifi.util.file.FileUtils;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class AzureGraphUserGroupProviderIT {
|
public class AzureGraphUserGroupProviderIT {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AzureGraphUserGroupProviderIT.class);
|
private static final Logger logger = LoggerFactory.getLogger(AzureGraphUserGroupProviderIT.class);
|
||||||
|
|
||||||
|
@ -50,18 +51,11 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CONFIG = new Properties();
|
CONFIG = new Properties();
|
||||||
try {
|
assertDoesNotThrow(() -> {
|
||||||
final FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
|
final FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
|
||||||
try {
|
assertDoesNotThrow(() -> CONFIG.load(fis));
|
||||||
CONFIG.load(fis);
|
FileUtils.closeQuietly(fis);
|
||||||
} catch (IOException e) {
|
});
|
||||||
fail("Could not open credentials file " + CREDENTIALS_FILE + ": " + e.getLocalizedMessage());
|
|
||||||
} finally {
|
|
||||||
FileUtils.closeQuietly(fis);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
fail("Could not open credentials file " + CREDENTIALS_FILE + ": " + e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getAuthorityEndpoint() {
|
protected static String getAuthorityEndpoint() {
|
||||||
|
@ -97,7 +91,7 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
private AzureGraphUserGroupProvider testingProvider;
|
private AzureGraphUserGroupProvider testingProvider;
|
||||||
private UserGroupProviderInitializationContext initContext;
|
private UserGroupProviderInitializationContext initContext;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
authContext = Mockito.mock(AuthorizerConfigurationContext.class);
|
authContext = Mockito.mock(AuthorizerConfigurationContext.class);
|
||||||
initContext = Mockito.mock(UserGroupProviderInitializationContext.class);
|
initContext = Mockito.mock(UserGroupProviderInitializationContext.class);
|
||||||
|
@ -126,7 +120,7 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
testingProvider.preDestruction();
|
testingProvider.preDestruction();
|
||||||
}
|
}
|
||||||
|
@ -138,11 +132,11 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
|
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
Assert.assertTrue(testingProvider.getUsers().size() > 0);
|
assertTrue(testingProvider.getUsers().size() > 0);
|
||||||
UserAndGroups uag = testingProvider.getUserAndGroups(getKnownTestUserName());
|
UserAndGroups uag = testingProvider.getUserAndGroups(getKnownTestUserName());
|
||||||
Assert.assertNotNull(uag.getUser());
|
assertNotNull(uag.getUser());
|
||||||
Assert.assertTrue(uag.getGroups().size() > 0);
|
assertTrue(uag.getGroups().size() > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,15 +149,15 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
|
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
Assert.assertTrue(testingProvider.getUsers().size() > 0);
|
assertTrue(testingProvider.getUsers().size() > 0);
|
||||||
UserAndGroups uag = testingProvider.getUserAndGroups(getKnownTestUserName());
|
UserAndGroups uag = testingProvider.getUserAndGroups(getKnownTestUserName());
|
||||||
Assert.assertNotNull(uag.getUser());
|
assertNotNull(uag.getUser());
|
||||||
Assert.assertTrue(uag.getGroups().size() > 0);
|
assertTrue(uag.getGroups().size() > 0);
|
||||||
|
|
||||||
String knownGroupName = getKnownTestGroupName();
|
String knownGroupName = getKnownTestGroupName();
|
||||||
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
||||||
Assert.assertTrue(search.size() > 0);
|
assertTrue(search.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -175,9 +169,9 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
.thenReturn(new MockPropertyValue(prefix));
|
.thenReturn(new MockPropertyValue(prefix));
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
||||||
Assert.assertTrue(search.size() > 0);
|
assertTrue(search.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -189,9 +183,9 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
.thenReturn(new MockPropertyValue(suffix));
|
.thenReturn(new MockPropertyValue(suffix));
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
List<Group> search = testingProvider.getGroups().stream().filter(g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
||||||
Assert.assertTrue(search.size() > 0);
|
assertTrue(search.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -203,9 +197,9 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
.thenReturn(new MockPropertyValue(substring));
|
.thenReturn(new MockPropertyValue(substring));
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
List<Group> search = testingProvider.getGroups().stream().filter( g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
List<Group> search = testingProvider.getGroups().stream().filter( g-> g.getName().equals(knownGroupName)).collect(Collectors.toList());
|
||||||
Assert.assertTrue(search.size() > 0);
|
assertTrue(search.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -219,9 +213,9 @@ public class AzureGraphUserGroupProviderIT {
|
||||||
.thenReturn(new MockPropertyValue(getGroupListInclusion()));
|
.thenReturn(new MockPropertyValue(getGroupListInclusion()));
|
||||||
|
|
||||||
setupTestingProvider();
|
setupTestingProvider();
|
||||||
Assert.assertTrue(testingProvider.getGroups().size() > 0);
|
assertTrue(testingProvider.getGroups().size() > 0);
|
||||||
Set<Group> search = testingProvider.getGroups().stream().collect(Collectors.toSet());
|
Set<Group> search = testingProvider.getGroups().stream().collect(Collectors.toSet());
|
||||||
// check there is no duplicate group
|
// check there is no duplicate group
|
||||||
Assert.assertEquals(search.size(), testingProvider.getGroups().size());
|
assertEquals(search.size(), testingProvider.getGroups().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.azure.cosmos.document;
|
package org.apache.nifi.processors.azure.cosmos.document;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import com.azure.cosmos.CosmosClient;
|
import com.azure.cosmos.CosmosClient;
|
||||||
import com.azure.cosmos.CosmosClientBuilder;
|
import com.azure.cosmos.CosmosClientBuilder;
|
||||||
import com.azure.cosmos.CosmosContainer;
|
import com.azure.cosmos.CosmosContainer;
|
||||||
|
@ -38,15 +29,21 @@ import com.azure.cosmos.models.CosmosQueryRequestOptions;
|
||||||
import com.azure.cosmos.models.PartitionKey;
|
import com.azure.cosmos.models.PartitionKey;
|
||||||
import com.azure.cosmos.util.CosmosPagedIterable;
|
import com.azure.cosmos.util.CosmosPagedIterable;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.services.azure.cosmos.document.AzureCosmosDBClientService;
|
import org.apache.nifi.services.azure.cosmos.document.AzureCosmosDBClientService;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.apache.nifi.util.file.FileUtils;
|
import org.apache.nifi.util.file.FileUtils;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public abstract class ITAbstractAzureCosmosDBDocument {
|
public abstract class ITAbstractAzureCosmosDBDocument {
|
||||||
static Logger logger = Logger.getLogger(ITAbstractAzureCosmosDBDocument.class.getName());
|
static Logger logger = Logger.getLogger(ITAbstractAzureCosmosDBDocument.class.getName());
|
||||||
|
@ -62,20 +59,13 @@ public abstract class ITAbstractAzureCosmosDBDocument {
|
||||||
protected static CosmosContainer container;
|
protected static CosmosContainer container;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final FileInputStream fis;
|
|
||||||
CONFIG = new Properties();
|
CONFIG = new Properties();
|
||||||
try {
|
assertDoesNotThrow(() -> {
|
||||||
fis = new FileInputStream(CREDENTIALS_FILE);
|
final FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
|
||||||
try {
|
assertDoesNotThrow(() -> CONFIG.load(fis));
|
||||||
CONFIG.load(fis);
|
FileUtils.closeQuietly(fis);
|
||||||
} catch (IOException e) {
|
});
|
||||||
fail("Could not open credentials file " + CREDENTIALS_FILE + ": " + e.getLocalizedMessage());
|
|
||||||
} finally {
|
|
||||||
FileUtils.closeQuietly(fis);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
fail("Could not open credentials file " + CREDENTIALS_FILE + ": " + e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getComosURI() {
|
protected static String getComosURI() {
|
||||||
|
@ -88,7 +78,7 @@ public abstract class ITAbstractAzureCosmosDBDocument {
|
||||||
|
|
||||||
protected TestRunner runner;
|
protected TestRunner runner;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void createTestDBContainerIfNeeded() throws CosmosException {
|
public static void createTestDBContainerIfNeeded() throws CosmosException {
|
||||||
final String testDBURI = getComosURI();
|
final String testDBURI = getComosURI();
|
||||||
final String testDBContainer = getCosmosKey();
|
final String testDBContainer = getCosmosKey();
|
||||||
|
@ -107,7 +97,7 @@ public abstract class ITAbstractAzureCosmosDBDocument {
|
||||||
assertNotNull(container);
|
assertNotNull(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void dropTestDBAndContainer() throws CosmosException {
|
public static void dropTestDBAndContainer() throws CosmosException {
|
||||||
resetTestCosmosConnection();
|
resetTestCosmosConnection();
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
|
@ -139,7 +129,7 @@ public abstract class ITAbstractAzureCosmosDBDocument {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUpCosmosIT() {
|
public void setUpCosmosIT() {
|
||||||
final String testDBURI = getComosURI();
|
final String testDBURI = getComosURI();
|
||||||
final String testDBContainer = getCosmosKey();
|
final String testDBContainer = getCosmosKey();
|
||||||
|
|
|
@ -16,17 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.azure.cosmos.document;
|
package org.apache.nifi.processors.azure.cosmos.document;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import com.azure.cosmos.models.CosmosQueryRequestOptions;
|
import com.azure.cosmos.models.CosmosQueryRequestOptions;
|
||||||
import com.azure.cosmos.util.CosmosPagedIterable;
|
import com.azure.cosmos.util.CosmosPagedIterable;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.serialization.SimpleRecordSchema;
|
import org.apache.nifi.serialization.SimpleRecordSchema;
|
||||||
|
@ -35,9 +27,16 @@ import org.apache.nifi.serialization.record.MockRecordParser;
|
||||||
import org.apache.nifi.serialization.record.RecordField;
|
import org.apache.nifi.serialization.record.RecordField;
|
||||||
import org.apache.nifi.serialization.record.RecordFieldType;
|
import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class ITPutAzureCosmosDBRecord extends ITAbstractAzureCosmosDBDocument {
|
public class ITPutAzureCosmosDBRecord extends ITAbstractAzureCosmosDBDocument {
|
||||||
static Logger logger = Logger.getLogger(ITPutAzureCosmosDBRecord.class.getName());
|
static Logger logger = Logger.getLogger(ITPutAzureCosmosDBRecord.class.getName());
|
||||||
|
@ -47,12 +46,12 @@ public class ITPutAzureCosmosDBRecord extends ITAbstractAzureCosmosDBDocument {
|
||||||
return PutAzureCosmosDBRecord.class;
|
return PutAzureCosmosDBRecord.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
resetTestCosmosConnection();
|
resetTestCosmosConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void cleanupTestCase() {
|
public void cleanupTestCase() {
|
||||||
try{
|
try{
|
||||||
clearTestData();
|
clearTestData();
|
||||||
|
@ -159,7 +158,4 @@ public class ITPutAzureCosmosDBRecord extends ITAbstractAzureCosmosDBDocument {
|
||||||
runner.assertAllFlowFilesTransferred(PutAzureCosmosDBRecord.REL_SUCCESS, 1);
|
runner.assertAllFlowFilesTransferred(PutAzureCosmosDBRecord.REL_SUCCESS, 1);
|
||||||
assertEquals(5, getDataFromTestDB().size());
|
assertEquals(5, getDataFromTestDB().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,17 +17,16 @@
|
||||||
|
|
||||||
package org.apache.nifi.processors.azure.cosmos.document;
|
package org.apache.nifi.processors.azure.cosmos.document;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.azure.cosmos.ConsistencyLevel;
|
import com.azure.cosmos.ConsistencyLevel;
|
||||||
import com.azure.cosmos.CosmosClient;
|
import com.azure.cosmos.CosmosClient;
|
||||||
|
|
||||||
import org.apache.nifi.reporting.InitializationException;
|
import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.services.azure.cosmos.document.AzureCosmosDBClientService;
|
import org.apache.nifi.services.azure.cosmos.document.AzureCosmosDBClientService;
|
||||||
import org.apache.nifi.util.TestRunner;
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class MockTestBase {
|
public class MockTestBase {
|
||||||
|
|
||||||
protected static final String MOCK_DB_NAME = "MOCK_DB_NAME";
|
protected static final String MOCK_DB_NAME = "MOCK_DB_NAME";
|
||||||
|
|
|
@ -16,17 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.nifi.processors.azure.cosmos.document;
|
package org.apache.nifi.processors.azure.cosmos.document;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.azure.cosmos.ConsistencyLevel;
|
import com.azure.cosmos.ConsistencyLevel;
|
||||||
import com.azure.cosmos.CosmosClient;
|
import com.azure.cosmos.CosmosClient;
|
||||||
import com.azure.cosmos.CosmosContainer;
|
import com.azure.cosmos.CosmosContainer;
|
||||||
|
@ -35,7 +24,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minidev.json.JSONObject;
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.nifi.avro.AvroTypeUtil;
|
import org.apache.nifi.avro.AvroTypeUtil;
|
||||||
import org.apache.nifi.json.JsonTreeReader;
|
import org.apache.nifi.json.JsonTreeReader;
|
||||||
|
@ -50,10 +39,20 @@ import org.apache.nifi.serialization.record.RecordField;
|
||||||
import org.apache.nifi.serialization.record.RecordFieldType;
|
import org.apache.nifi.serialization.record.RecordFieldType;
|
||||||
import org.apache.nifi.serialization.record.RecordSchema;
|
import org.apache.nifi.serialization.record.RecordSchema;
|
||||||
import org.apache.nifi.util.TestRunners;
|
import org.apache.nifi.util.TestRunners;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import net.minidev.json.JSONObject;
|
|
||||||
public class PutAzureCosmosDBRecordTest extends MockTestBase {
|
public class PutAzureCosmosDBRecordTest extends MockTestBase {
|
||||||
|
|
||||||
private MockPutAzureCosmosDBRecord processor;
|
private MockPutAzureCosmosDBRecord processor;
|
||||||
|
@ -69,7 +68,7 @@ public class PutAzureCosmosDBRecordTest extends MockTestBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
processor = new MockPutAzureCosmosDBRecord();
|
processor = new MockPutAzureCosmosDBRecord();
|
||||||
testRunner = TestRunners.newTestRunner(processor);
|
testRunner = TestRunners.newTestRunner(processor);
|
||||||
|
@ -287,8 +286,4 @@ class MockPutAzureCosmosDBRecord extends PutAzureCosmosDBRecord {
|
||||||
public CosmosContainer getMockConainer() {
|
public CosmosContainer getMockConainer() {
|
||||||
return mockContainer;
|
return mockContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,9 +18,16 @@ package org.apache.nifi.processors.azure.eventhub;
|
||||||
|
|
||||||
import com.microsoft.azure.eventhubs.EventData;
|
import com.microsoft.azure.eventhubs.EventData;
|
||||||
import com.microsoft.azure.eventhubs.EventData.SystemProperties;
|
import com.microsoft.azure.eventhubs.EventData.SystemProperties;
|
||||||
import com.microsoft.azure.eventhubs.PartitionReceiver;
|
|
||||||
import com.microsoft.azure.eventhubs.EventHubException;
|
import com.microsoft.azure.eventhubs.EventHubException;
|
||||||
|
import com.microsoft.azure.eventhubs.PartitionReceiver;
|
||||||
import com.microsoft.azure.eventhubs.impl.AmqpConstants;
|
import com.microsoft.azure.eventhubs.impl.AmqpConstants;
|
||||||
|
import org.apache.nifi.processor.ProcessContext;
|
||||||
|
import org.apache.nifi.processor.exception.ProcessException;
|
||||||
|
import org.apache.nifi.util.MockFlowFile;
|
||||||
|
import org.apache.nifi.util.TestRunner;
|
||||||
|
import org.apache.nifi.util.TestRunners;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
|
@ -32,13 +39,7 @@ import java.util.LinkedList;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import org.apache.nifi.processor.exception.ProcessException;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class GetAzureEventHubTest {
|
public class GetAzureEventHubTest {
|
||||||
private static final String namespaceName = "nifi-azure-hub";
|
private static final String namespaceName = "nifi-azure-hub";
|
||||||
|
@ -53,7 +54,7 @@ public class GetAzureEventHubTest {
|
||||||
private TestRunner testRunner;
|
private TestRunner testRunner;
|
||||||
private MockGetAzureEventHub processor;
|
private MockGetAzureEventHub processor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
processor = new MockGetAzureEventHub();
|
processor = new MockGetAzureEventHub();
|
||||||
testRunner = TestRunners.newTestRunner(processor);
|
testRunner = TestRunners.newTestRunner(processor);
|
||||||
|
@ -119,11 +120,11 @@ public class GetAzureEventHubTest {
|
||||||
testRunner.clearTransferState();
|
testRunner.clearTransferState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError.class)
|
@Test//(expected = AssertionError.class)
|
||||||
public void testThrowGetReceiver(){
|
public void testThrowGetReceiver(){
|
||||||
setUpStandardTestConfig();
|
setUpStandardTestConfig();
|
||||||
processor.getReceiverThrow = true;
|
processor.getReceiverThrow = true;
|
||||||
testRunner.run(1, true);
|
assertThrows(AssertionError.class, () -> testRunner.run(1, true));
|
||||||
testRunner.assertAllFlowFilesTransferred(GetAzureEventHub.REL_SUCCESS, 0);
|
testRunner.assertAllFlowFilesTransferred(GetAzureEventHub.REL_SUCCESS, 0);
|
||||||
testRunner.clearTransferState();
|
testRunner.clearTransferState();
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue