mirror of
https://github.com/apache/nifi.git
synced 2025-02-08 11:05:17 +00:00
NIFI-14131 Expanded PMD coverage to include tests and fixed violations (#9610)
Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
6c894f3ae1
commit
32bc68a40c
@ -43,6 +43,7 @@ class ShutdownHookTest {
|
|||||||
private ShutdownHook shutdownHook;
|
private ShutdownHook shutdownHook;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("PMD.DontCallThreadRun")
|
||||||
void testRunShouldShutdownSchedulersAndProcesses() {
|
void testRunShouldShutdownSchedulersAndProcesses() {
|
||||||
when(runner.getPeriodicStatusReporterManager()).thenReturn(periodicStatusReporterManager);
|
when(runner.getPeriodicStatusReporterManager()).thenReturn(periodicStatusReporterManager);
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ public class TestDataTypeUtils {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConvertToBigDecimalWhenUnsupportedType() {
|
public void testConvertToBigDecimalWhenUnsupportedType() {
|
||||||
assertThrows(IllegalTypeConversionException.class, () -> DataTypeUtils.convertType(new ArrayList<Double>(), RecordFieldType.DECIMAL.getDecimalDataType(30, 10),
|
assertThrows(IllegalTypeConversionException.class, () -> DataTypeUtils.convertType(new ArrayList<>(), RecordFieldType.DECIMAL.getDecimalDataType(30, 10),
|
||||||
null, StandardCharsets.UTF_8));
|
null, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,8 +716,8 @@ public class TestDataTypeUtils {
|
|||||||
final Function<Object, BigInteger> toBigInteger = v -> (BigInteger) DataTypeUtils.convertType(v, RecordFieldType.BIGINT.getDataType(), "field");
|
final Function<Object, BigInteger> toBigInteger = v -> (BigInteger) DataTypeUtils.convertType(v, RecordFieldType.BIGINT.getDataType(), "field");
|
||||||
assertEquals(new BigInteger("12345678901234567890"), toBigInteger.apply(new BigInteger("12345678901234567890")));
|
assertEquals(new BigInteger("12345678901234567890"), toBigInteger.apply(new BigInteger("12345678901234567890")));
|
||||||
assertEquals(new BigInteger("1234567890123456789"), toBigInteger.apply(1234567890123456789L));
|
assertEquals(new BigInteger("1234567890123456789"), toBigInteger.apply(1234567890123456789L));
|
||||||
assertEquals(new BigInteger("1"), toBigInteger.apply(1));
|
assertEquals(BigInteger.ONE, toBigInteger.apply(1));
|
||||||
assertEquals(new BigInteger("1"), toBigInteger.apply((short) 1));
|
assertEquals(BigInteger.ONE, toBigInteger.apply((short) 1));
|
||||||
// Decimals are truncated.
|
// Decimals are truncated.
|
||||||
assertEquals(new BigInteger("3"), toBigInteger.apply(3.4f));
|
assertEquals(new BigInteger("3"), toBigInteger.apply(3.4f));
|
||||||
assertEquals(new BigInteger("3"), toBigInteger.apply(3.9f));
|
assertEquals(new BigInteger("3"), toBigInteger.apply(3.9f));
|
||||||
|
@ -53,14 +53,14 @@ public class TestSchemaRecordReader {
|
|||||||
fields.add(new MapRecordField("map",
|
fields.add(new MapRecordField("map",
|
||||||
new SimpleRecordField("key", FieldType.STRING, Repetition.EXACTLY_ONE),
|
new SimpleRecordField("key", FieldType.STRING, Repetition.EXACTLY_ONE),
|
||||||
new SimpleRecordField("value", FieldType.STRING, Repetition.ZERO_OR_ONE), Repetition.EXACTLY_ONE));
|
new SimpleRecordField("value", FieldType.STRING, Repetition.ZERO_OR_ONE), Repetition.EXACTLY_ONE));
|
||||||
fields.add(new UnionRecordField("union1", Repetition.EXACTLY_ONE, Arrays.asList(new RecordField[] {
|
fields.add(new UnionRecordField("union1", Repetition.EXACTLY_ONE, List.of(
|
||||||
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
||||||
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
||||||
})));
|
)));
|
||||||
fields.add(new UnionRecordField("union2", Repetition.EXACTLY_ONE, Arrays.asList(new RecordField[] {
|
fields.add(new UnionRecordField("union2", Repetition.EXACTLY_ONE, List.of(
|
||||||
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
||||||
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
||||||
})));
|
)));
|
||||||
final RecordSchema schema = new RecordSchema(fields);
|
final RecordSchema schema = new RecordSchema(fields);
|
||||||
|
|
||||||
final SchemaRecordReader reader = SchemaRecordReader.fromSchema(schema, new NoOpFieldCache());
|
final SchemaRecordReader reader = SchemaRecordReader.fromSchema(schema, new NoOpFieldCache());
|
||||||
@ -156,14 +156,14 @@ public class TestSchemaRecordReader {
|
|||||||
fields.add(new MapRecordField("map present",
|
fields.add(new MapRecordField("map present",
|
||||||
new SimpleRecordField("key", FieldType.STRING, Repetition.ZERO_OR_ONE),
|
new SimpleRecordField("key", FieldType.STRING, Repetition.ZERO_OR_ONE),
|
||||||
new SimpleRecordField("value", FieldType.STRING, Repetition.ZERO_OR_MORE), Repetition.ZERO_OR_ONE));
|
new SimpleRecordField("value", FieldType.STRING, Repetition.ZERO_OR_MORE), Repetition.ZERO_OR_ONE));
|
||||||
fields.add(new UnionRecordField("union", Repetition.ZERO_OR_ONE, Arrays.asList(new RecordField[] {
|
fields.add(new UnionRecordField("union", Repetition.ZERO_OR_ONE, List.of(
|
||||||
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
||||||
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
new SimpleRecordField("two", FieldType.INT, Repetition.EXACTLY_ONE)
|
||||||
})));
|
)));
|
||||||
fields.add(new UnionRecordField("union present", Repetition.ZERO_OR_ONE, Arrays.asList(new RecordField[] {
|
fields.add(new UnionRecordField("union present", Repetition.ZERO_OR_ONE, List.of(
|
||||||
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
new SimpleRecordField("one", FieldType.STRING, Repetition.EXACTLY_ONE),
|
||||||
new SimpleRecordField("two", FieldType.INT, Repetition.ZERO_OR_MORE)
|
new SimpleRecordField("two", FieldType.INT, Repetition.ZERO_OR_MORE)
|
||||||
})));
|
)));
|
||||||
|
|
||||||
final RecordSchema schema = new RecordSchema(fields);
|
final RecordSchema schema = new RecordSchema(fields);
|
||||||
|
|
||||||
@ -266,9 +266,9 @@ public class TestSchemaRecordReader {
|
|||||||
assertTrue(map.containsKey(null));
|
assertTrue(map.containsKey(null));
|
||||||
assertTrue(map.containsKey("key1"));
|
assertTrue(map.containsKey("key1"));
|
||||||
|
|
||||||
final List<String> key1Values = Arrays.asList(new String[] {"one", "two"});
|
final List<String> key1Values = List.of("one", "two");
|
||||||
assertEquals(key1Values, map.get("key1"));
|
assertEquals(key1Values, map.get("key1"));
|
||||||
final List<String> nullKeyValues = Arrays.asList(new String[] {"three"});
|
final List<String> nullKeyValues = List.of("three");
|
||||||
assertEquals(nullKeyValues, map.get(null));
|
assertEquals(nullKeyValues, map.get(null));
|
||||||
|
|
||||||
final List<Integer> unionValues = (List<Integer>) valueMap.get("union present");
|
final List<Integer> unionValues = (List<Integer>) valueMap.get("union present");
|
||||||
|
@ -75,7 +75,7 @@ public class TestSchemaRecordReaderWriter {
|
|||||||
final FieldMapRecord complexRecord2 = new FieldMapRecord(complexMap2, new RecordSchema(longStringField, longField));
|
final FieldMapRecord complexRecord2 = new FieldMapRecord(complexMap2, new RecordSchema(longStringField, longField));
|
||||||
|
|
||||||
// Create a Union Field that indicates that the type could be either 'complex 1' or 'complex 2'
|
// Create a Union Field that indicates that the type could be either 'complex 1' or 'complex 2'
|
||||||
final UnionRecordField unionRecordField = new UnionRecordField("union", Repetition.ZERO_OR_MORE, Arrays.asList(new RecordField[] {complexField1, complexField2}));
|
final UnionRecordField unionRecordField = new UnionRecordField("union", Repetition.ZERO_OR_MORE, List.of(complexField1, complexField2));
|
||||||
|
|
||||||
// Create a Record Schema
|
// Create a Record Schema
|
||||||
final List<RecordField> fields = new ArrayList<>();
|
final List<RecordField> fields = new ArrayList<>();
|
||||||
@ -123,9 +123,9 @@ public class TestSchemaRecordReaderWriter {
|
|||||||
values.put(createField("long string present", FieldType.LONG_STRING), "Long Hello");
|
values.put(createField("long string present", FieldType.LONG_STRING), "Long Hello");
|
||||||
values.put(createField("complex present", FieldType.COMPLEX), new FieldMapRecord(complexFieldMap, new RecordSchema(colorField, fruitField)));
|
values.put(createField("complex present", FieldType.COMPLEX), new FieldMapRecord(complexFieldMap, new RecordSchema(colorField, fruitField)));
|
||||||
values.put(new MapRecordField("map present", createField("key", FieldType.STRING), createField("value", FieldType.INT), Repetition.EXACTLY_ONE), simpleMap);
|
values.put(new MapRecordField("map present", createField("key", FieldType.STRING), createField("value", FieldType.INT), Repetition.EXACTLY_ONE), simpleMap);
|
||||||
values.put(unionRecordField, Arrays.asList(new NamedValue[] {
|
values.put(unionRecordField, List.of(
|
||||||
new NamedValue("complex1", complexRecord1),
|
new NamedValue("complex1", complexRecord1),
|
||||||
new NamedValue("complex2", complexRecord2)}));
|
new NamedValue("complex2", complexRecord2)));
|
||||||
|
|
||||||
final FieldMapRecord originalRecord = new FieldMapRecord(values, schema);
|
final FieldMapRecord originalRecord = new FieldMapRecord(values, schema);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class EphemeralKeyStoreBuilderTest {
|
|||||||
|
|
||||||
private static final String KEY_ALGORITHM = "RSA";
|
private static final String KEY_ALGORITHM = "RSA";
|
||||||
|
|
||||||
private static final char[] KEY_PASSWORD = EphemeralKeyStoreBuilderTest.class.getSimpleName().toCharArray();;
|
private static final char[] KEY_PASSWORD = EphemeralKeyStoreBuilderTest.class.getSimpleName().toCharArray();
|
||||||
|
|
||||||
private static KeyPair keyPair;
|
private static KeyPair keyPair;
|
||||||
|
|
||||||
|
@ -25,10 +25,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -48,7 +46,7 @@ public class TestSiteInfoProvider {
|
|||||||
@Test
|
@Test
|
||||||
public void testSecure() throws Exception {
|
public void testSecure() throws Exception {
|
||||||
|
|
||||||
final Set<String> expectedClusterUrl = new LinkedHashSet<>(Arrays.asList(new String[]{"https://node1:8443", "https://node2:8443"}));
|
final Set<String> expectedClusterUrl = Set.of("https://node1:8443", "https://node2:8443");
|
||||||
final String expectedActiveClusterUrl = "https://node2:8443/nifi-api";
|
final String expectedActiveClusterUrl = "https://node2:8443/nifi-api";
|
||||||
final SSLContext expectedSslConText = mock(SSLContext.class);
|
final SSLContext expectedSslConText = mock(SSLContext.class);
|
||||||
final HttpProxy expectedHttpProxy = mock(HttpProxy.class);
|
final HttpProxy expectedHttpProxy = mock(HttpProxy.class);
|
||||||
@ -130,7 +128,7 @@ public class TestSiteInfoProvider {
|
|||||||
@Test
|
@Test
|
||||||
public void testPlain() throws Exception {
|
public void testPlain() throws Exception {
|
||||||
|
|
||||||
final Set<String> expectedClusterUrl = new LinkedHashSet<>(Arrays.asList(new String[]{"http://node1:8443, http://node2:8443"}));
|
final Set<String> expectedClusterUrl = Set.of("http://node1:8443, http://node2:8443");
|
||||||
final String expectedActiveClusterUrl = "http://node2:8443/nifi-api";
|
final String expectedActiveClusterUrl = "http://node2:8443/nifi-api";
|
||||||
|
|
||||||
final SiteInfoProvider siteInfoProvider = spy(new SiteInfoProvider());
|
final SiteInfoProvider siteInfoProvider = spy(new SiteInfoProvider());
|
||||||
@ -168,7 +166,7 @@ public class TestSiteInfoProvider {
|
|||||||
@Test
|
@Test
|
||||||
public void testConnectException() throws Exception {
|
public void testConnectException() throws Exception {
|
||||||
|
|
||||||
final Set<String> expectedClusterUrl = new LinkedHashSet<>(Arrays.asList(new String[]{"http://node1:8443, http://node2:8443"}));
|
final Set<String> expectedClusterUrl = Set.of("http://node1:8443, http://node2:8443");
|
||||||
|
|
||||||
final SiteInfoProvider siteInfoProvider = spy(new SiteInfoProvider());
|
final SiteInfoProvider siteInfoProvider = spy(new SiteInfoProvider());
|
||||||
siteInfoProvider.setClusterUrls(expectedClusterUrl);
|
siteInfoProvider.setClusterUrls(expectedClusterUrl);
|
||||||
|
@ -31,8 +31,6 @@ import org.apache.nifi.remote.protocol.RequestType;
|
|||||||
import org.apache.nifi.remote.protocol.Response;
|
import org.apache.nifi.remote.protocol.Response;
|
||||||
import org.apache.nifi.remote.protocol.ResponseCode;
|
import org.apache.nifi.remote.protocol.ResponseCode;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -57,7 +55,6 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
public class TestSocketClientTransaction {
|
public class TestSocketClientTransaction {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(TestSocketClientTransaction.class);
|
|
||||||
private FlowFileCodec codec = new StandardFlowFileCodec();
|
private FlowFileCodec codec = new StandardFlowFileCodec();
|
||||||
|
|
||||||
private SocketClientTransaction getClientTransaction(ByteArrayInputStream bis, ByteArrayOutputStream bos, TransferDirection direction) throws IOException {
|
private SocketClientTransaction getClientTransaction(ByteArrayInputStream bis, ByteArrayOutputStream bos, TransferDirection direction) throws IOException {
|
||||||
|
@ -76,7 +76,9 @@ public class ByteCountingInputStreamTest {
|
|||||||
int availableBytes = bcis.available();
|
int availableBytes = bcis.available();
|
||||||
assertEquals(ALPHABET.length() - 2, availableBytes);
|
assertEquals(ALPHABET.length() - 2, availableBytes);
|
||||||
|
|
||||||
bcis.skip(24);
|
final long expectedSkip = 24;
|
||||||
|
final long actualSkip = bcis.skip(expectedSkip);
|
||||||
|
assertEquals(expectedSkip, actualSkip);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
int finalAvailableBytes = bcis.available();
|
int finalAvailableBytes = bcis.available();
|
||||||
|
@ -103,9 +103,9 @@ public class TestJASN1RecordReader implements JASN1ReadRecordTester {
|
|||||||
// Assert integers
|
// Assert integers
|
||||||
final Object[] numbers = (Object[]) record.getValue("numbers");
|
final Object[] numbers = (Object[]) record.getValue("numbers");
|
||||||
assertEquals(4, numbers.length);
|
assertEquals(4, numbers.length);
|
||||||
assertEquals(new BigInteger("0"), numbers[0]);
|
assertEquals(BigInteger.ZERO, numbers[0]);
|
||||||
assertEquals(new BigInteger("1"), numbers[1]);
|
assertEquals(BigInteger.ONE, numbers[1]);
|
||||||
assertEquals(new BigInteger("2"), numbers[2]);
|
assertEquals(BigInteger.TWO, numbers[2]);
|
||||||
assertEquals(new BigInteger("3"), numbers[3]);
|
assertEquals(new BigInteger("3"), numbers[3]);
|
||||||
|
|
||||||
// Assert unordered
|
// Assert unordered
|
||||||
|
@ -565,7 +565,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
|||||||
final PutS3Object.MultipartState state1new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey1);
|
final PutS3Object.MultipartState state1new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey1);
|
||||||
assertEquals("", state1new.getUploadId());
|
assertEquals("", state1new.getUploadId());
|
||||||
assertEquals(0L, state1new.getFilePosition().longValue());
|
assertEquals(0L, state1new.getFilePosition().longValue());
|
||||||
assertEquals(new ArrayList<PartETag>(), state1new.getPartETags());
|
assertEquals(new ArrayList<>(), state1new.getPartETags());
|
||||||
assertEquals(0L, state1new.getPartSize().longValue());
|
assertEquals(0L, state1new.getPartSize().longValue());
|
||||||
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state1new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state1new.getStorageClass());
|
||||||
assertEquals(0L, state1new.getContentLength().longValue());
|
assertEquals(0L, state1new.getContentLength().longValue());
|
||||||
@ -573,7 +573,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
|||||||
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
final PutS3Object.MultipartState state2new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey2);
|
||||||
assertEquals("1234", state2new.getUploadId());
|
assertEquals("1234", state2new.getUploadId());
|
||||||
assertEquals(0L, state2new.getFilePosition().longValue());
|
assertEquals(0L, state2new.getFilePosition().longValue());
|
||||||
assertEquals(new ArrayList<PartETag>(), state2new.getPartETags());
|
assertEquals(new ArrayList<>(), state2new.getPartETags());
|
||||||
assertEquals(0L, state2new.getPartSize().longValue());
|
assertEquals(0L, state2new.getPartSize().longValue());
|
||||||
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state2new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state2new.getStorageClass());
|
||||||
assertEquals(1234L, state2new.getContentLength().longValue());
|
assertEquals(1234L, state2new.getContentLength().longValue());
|
||||||
@ -581,7 +581,7 @@ public class ITPutS3Object extends AbstractS3IT {
|
|||||||
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
final PutS3Object.MultipartState state3new = processor.getLocalStateIfInS3(mockClient, bucket, cacheKey3);
|
||||||
assertEquals("5678", state3new.getUploadId());
|
assertEquals("5678", state3new.getUploadId());
|
||||||
assertEquals(0L, state3new.getFilePosition().longValue());
|
assertEquals(0L, state3new.getFilePosition().longValue());
|
||||||
assertEquals(new ArrayList<PartETag>(), state3new.getPartETags());
|
assertEquals(new ArrayList<>(), state3new.getPartETags());
|
||||||
assertEquals(0L, state3new.getPartSize().longValue());
|
assertEquals(0L, state3new.getPartSize().longValue());
|
||||||
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state3new.getStorageClass());
|
assertEquals(StorageClass.fromValue(StorageClass.Standard.toString()), state3new.getStorageClass());
|
||||||
assertEquals(5678L, state3new.getContentLength().longValue());
|
assertEquals(5678L, state3new.getContentLength().longValue());
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.nifi.processors.evtx.parser.bxml;
|
package org.apache.nifi.processors.evtx.parser.bxml;
|
||||||
|
|
||||||
import org.apache.nifi.processors.evtx.parser.BinaryReader;
|
|
||||||
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
|
import org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor;
|
||||||
import org.apache.nifi.processors.evtx.parser.bxml.value.NullTypeNode;
|
import org.apache.nifi.processors.evtx.parser.bxml.value.NullTypeNode;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -34,7 +33,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|||||||
|
|
||||||
public class AttributeNodeTest extends BxmlNodeWithTokenAndStringTestBase {
|
public class AttributeNodeTest extends BxmlNodeWithTokenAndStringTestBase {
|
||||||
public static final String ATTRIBUTE_NAME = "AttributeName";
|
public static final String ATTRIBUTE_NAME = "AttributeName";
|
||||||
private BinaryReader binaryReader;
|
|
||||||
private AttributeNode attributeNode;
|
private AttributeNode attributeNode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -418,7 +418,7 @@ public class TestJdbcCommon {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConvertToAvroStreamForBigDecimal() throws SQLException, IOException {
|
public void testConvertToAvroStreamForBigDecimal() throws SQLException, IOException {
|
||||||
final BigDecimal bigDecimal = new BigDecimal(12345D);
|
final BigDecimal bigDecimal = new BigDecimal("12345");
|
||||||
// If db returns a precision, it should be used.
|
// If db returns a precision, it should be used.
|
||||||
testConvertToAvroStreamForBigDecimal(bigDecimal, 38, 10, 38, 0);
|
testConvertToAvroStreamForBigDecimal(bigDecimal, 38, 10, 38, 0);
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ public class TestJdbcCommon {
|
|||||||
final int defaultScale = 15;
|
final int defaultScale = 15;
|
||||||
|
|
||||||
final BigDecimal bigDecimal = new BigDecimal("1.123", new MathContext(dbPrecision));
|
final BigDecimal bigDecimal = new BigDecimal("1.123", new MathContext(dbPrecision));
|
||||||
final BigDecimal expectedValue = new BigDecimal("1");
|
final BigDecimal expectedValue = BigDecimal.ONE;
|
||||||
testConvertToAvroStreamForBigDecimal(bigDecimal, expectedValue, dbPrecision, dbScale, defaultPrecision, defaultScale, expectedPrecision, expectedScale);
|
testConvertToAvroStreamForBigDecimal(bigDecimal, expectedValue, dbPrecision, dbScale, defaultPrecision, defaultScale, expectedPrecision, expectedScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ public class TestFileInfo {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPermissionModeToString() {
|
public void testPermissionModeToString() {
|
||||||
String rwxPerm = FileInfo.permissionToString(0567);
|
String rwxPerm = FileInfo.permissionToString(Integer.decode("0567"));
|
||||||
assertEquals("r-xrw-rwx", rwxPerm);
|
assertEquals("r-xrw-rwx", rwxPerm);
|
||||||
|
|
||||||
// Test with sticky bit
|
// Test with sticky bit
|
||||||
rwxPerm = FileInfo.permissionToString(01567);
|
rwxPerm = FileInfo.permissionToString(Integer.decode("01567"));
|
||||||
assertEquals("r-xrw-rwx", rwxPerm);
|
assertEquals("r-xrw-rwx", rwxPerm);
|
||||||
|
|
||||||
rwxPerm = FileInfo.permissionToString(03);
|
rwxPerm = FileInfo.permissionToString(Integer.decode("03"));
|
||||||
assertEquals("-------wx", rwxPerm);
|
assertEquals("-------wx", rwxPerm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,8 @@ import org.apache.nifi.util.TestRunners;
|
|||||||
import org.glassfish.jersey.internal.guava.Predicates;
|
import org.glassfish.jersey.internal.guava.Predicates;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -70,8 +68,6 @@ public class TestAbstractListProcessor {
|
|||||||
|
|
||||||
private ConcreteListProcessor proc;
|
private ConcreteListProcessor proc;
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
@TempDir
|
|
||||||
private Path testFolder;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@ -363,7 +359,6 @@ public class TestAbstractListProcessor {
|
|||||||
|
|
||||||
static class EphemeralMapCacheClientService extends AbstractControllerService implements DistributedMapCacheClient {
|
static class EphemeralMapCacheClientService extends AbstractControllerService implements DistributedMapCacheClient {
|
||||||
private final Map<Object, Object> stored = new HashMap<>();
|
private final Map<Object, Object> stored = new HashMap<>();
|
||||||
private int fetchCount = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K, V> boolean putIfAbsent(K key, V value, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
|
public <K, V> boolean putIfAbsent(K key, V value, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
|
||||||
@ -388,7 +383,6 @@ public class TestAbstractListProcessor {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <K, V> V get(K key, Serializer<K> keySerializer, Deserializer<V> valueDeserializer) throws IOException {
|
public <K, V> V get(K key, Serializer<K> keySerializer, Deserializer<V> valueDeserializer) throws IOException {
|
||||||
fetchCount++;
|
|
||||||
return (V) stored.get(key);
|
return (V) stored.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@ import org.apache.nifi.processor.exception.ProcessException;
|
|||||||
import org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure;
|
import org.apache.nifi.processor.util.pattern.TestExceptionHandler.ExternalProcedure;
|
||||||
import org.apache.nifi.util.MockComponentLog;
|
import org.apache.nifi.util.MockComponentLog;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,8 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
|
|
||||||
public class TestRollbackOnFailure {
|
public class TestRollbackOnFailure {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TestRollbackOnFailure.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This can be an example for how to compose an ExceptionHandler instance by reusable functions.
|
* This can be an example for how to compose an ExceptionHandler instance by reusable functions.
|
||||||
* @param logger used to log messages within functions
|
* @param logger used to log messages within functions
|
||||||
|
@ -148,8 +148,8 @@ public class TestAvroTypeUtil {
|
|||||||
assertEquals(42L, avroSchema.getField("long").defaultVal());
|
assertEquals(42L, avroSchema.getField("long").defaultVal());
|
||||||
assertEquals(2.4D, (float) avroSchema.getField("float").defaultVal(), 0.002D); // Even though we provide a Float, avro converts it into a Double value.
|
assertEquals(2.4D, (float) avroSchema.getField("float").defaultVal(), 0.002D); // Even though we provide a Float, avro converts it into a Double value.
|
||||||
assertEquals(28.1D, (double) avroSchema.getField("double").defaultVal(), 0.002D);
|
assertEquals(28.1D, (double) avroSchema.getField("double").defaultVal(), 0.002D);
|
||||||
assertEquals(new ArrayList<String>(), avroSchema.getField("stringArray").defaultVal());
|
assertEquals(new ArrayList<>(), avroSchema.getField("stringArray").defaultVal());
|
||||||
assertEquals(new ArrayList<Integer>(), avroSchema.getField("intArray").defaultVal());
|
assertEquals(new ArrayList<>(), avroSchema.getField("intArray").defaultVal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,7 +49,7 @@ public class InferenceSchemaStrategyTest {
|
|||||||
{"double", 1D, RecordFieldType.DOUBLE.getDataType()},
|
{"double", 1D, RecordFieldType.DOUBLE.getDataType()},
|
||||||
{"date", new Date(), RecordFieldType.DATE.getDataType()},
|
{"date", new Date(), RecordFieldType.DATE.getDataType()},
|
||||||
{"decimal", BigDecimal.valueOf(123.456D), RecordFieldType.DECIMAL.getDecimalDataType(6, 3)},
|
{"decimal", BigDecimal.valueOf(123.456D), RecordFieldType.DECIMAL.getDecimalDataType(6, 3)},
|
||||||
{"array", new ArrayList<String>(), RecordFieldType.ARRAY.getDataType()},
|
{"array", new ArrayList<>(), RecordFieldType.ARRAY.getDataType()},
|
||||||
|
|
||||||
// date subclasses
|
// date subclasses
|
||||||
{"time", new Time(System.currentTimeMillis()), RecordFieldType.DATE.getDataType()},
|
{"time", new Time(System.currentTimeMillis()), RecordFieldType.DATE.getDataType()},
|
||||||
|
@ -245,14 +245,14 @@ public class MockFileSystem extends FileSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileStatus newDir(Path p) {
|
public FileStatus newDir(Path p) {
|
||||||
return new FileStatus(DIR_LENGTH, true, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms((short) 0755), "owner", "group", (Path) null, p, true, false, false);
|
return new FileStatus(DIR_LENGTH, true, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms(Integer.decode("0755").shortValue()), "owner", "group", (Path) null, p, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileStatus newFile(String p) {
|
public FileStatus newFile(String p) {
|
||||||
return new FileStatus(FILE_LENGTH, false, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms((short) 0644), "owner", "group", new Path(p));
|
return new FileStatus(FILE_LENGTH, false, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms(Integer.decode("0644").shortValue()), "owner", "group", new Path(p));
|
||||||
}
|
}
|
||||||
public FileStatus newDir(String p) {
|
public FileStatus newDir(String p) {
|
||||||
return new FileStatus(DIR_LENGTH, true, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms((short) 0755), "owner", "group", new Path(p));
|
return new FileStatus(DIR_LENGTH, true, 3, 128 * 1024 * 1024, 1523456000000L, 1523457000000L, perms(Integer.decode("0755").shortValue()), "owner", "group", new Path(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,8 +26,6 @@ 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.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -45,8 +43,6 @@ import static org.mockito.Mockito.when;
|
|||||||
*/
|
*/
|
||||||
public class JMSConnectionFactoryProviderTest {
|
public class JMSConnectionFactoryProviderTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(JMSConnectionFactoryProviderTest.class);
|
|
||||||
|
|
||||||
private static final String HOSTNAME = "myhost";
|
private static final String HOSTNAME = "myhost";
|
||||||
private static final String PORT = "1234";
|
private static final String PORT = "1234";
|
||||||
|
|
||||||
|
@ -52,8 +52,6 @@ class ConsumeKafkaRecordIT extends AbstractConsumeKafkaIT {
|
|||||||
|
|
||||||
private static final int FIRST_PARTITION = 0;
|
private static final int FIRST_PARTITION = 0;
|
||||||
|
|
||||||
private static final long FIRST_OFFSET = 0;
|
|
||||||
|
|
||||||
private TestRunner runner;
|
private TestRunner runner;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
@ -360,7 +360,7 @@ public class GetMongoIT extends AbstractMongoIT {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReadQueryFromBodyWithEL() {
|
public void testReadQueryFromBodyWithEL() {
|
||||||
Map attributes = new HashMap();
|
Map<String, String> attributes = new HashMap<>();
|
||||||
attributes.put("field", "c");
|
attributes.put("field", "c");
|
||||||
attributes.put("value", "4");
|
attributes.put("value", "4");
|
||||||
String query = "{ \"${field}\": { \"$gte\": ${value}}}";
|
String query = "{ \"${field}\": { \"$gte\": ${value}}}";
|
||||||
|
@ -31,7 +31,7 @@ public class MqttTestClient implements MqttClient {
|
|||||||
|
|
||||||
public ConnectType type;
|
public ConnectType type;
|
||||||
|
|
||||||
public enum ConnectType { Publisher, Subscriber };
|
public enum ConnectType { Publisher, Subscriber }
|
||||||
|
|
||||||
public String subscribedTopic;
|
public String subscribedTopic;
|
||||||
public int subscribedQos;
|
public int subscribedQos;
|
||||||
|
@ -605,7 +605,7 @@ public class FetchParquetTest {
|
|||||||
|
|
||||||
try (final ParquetWriter<GenericRecord> writer = writerBuilder.build()) {
|
try (final ParquetWriter<GenericRecord> writer = writerBuilder.build()) {
|
||||||
for (int i = 0; i < USERS; i++) {
|
for (int i = 0; i < USERS; i++) {
|
||||||
final BigDecimal incrementedAmount = initialAmount.add(new BigDecimal("1"));
|
final BigDecimal incrementedAmount = initialAmount.add(BigDecimal.ONE);
|
||||||
final GenericRecord user = new GenericData.Record(schemaWithDecimal);
|
final GenericRecord user = new GenericData.Record(schemaWithDecimal);
|
||||||
user.put("name", "Bob" + i);
|
user.put("name", "Bob" + i);
|
||||||
user.put("amount", decimalConversion.toFixed(incrementedAmount, amountSchema, amountSchema.getLogicalType()));
|
user.put("amount", decimalConversion.toFixed(incrementedAmount, amountSchema, amountSchema.getLogicalType()));
|
||||||
|
@ -44,7 +44,7 @@ public class SambaTestContainers {
|
|||||||
protected final static Integer DEFAULT_SAMBA_PORT = 445;
|
protected final static Integer DEFAULT_SAMBA_PORT = 445;
|
||||||
|
|
||||||
protected enum AccessMode {
|
protected enum AccessMode {
|
||||||
READ_ONLY, READ_WRITE;
|
READ_ONLY, READ_WRITE
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final GenericContainer<?> sambaContainer = new GenericContainer<>(DockerImageName.parse("dperson/samba"))
|
protected final GenericContainer<?> sambaContainer = new GenericContainer<>(DockerImageName.parse("dperson/samba"))
|
||||||
@ -107,7 +107,7 @@ public class SambaTestContainers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void writeFile(final String path, final String content, final AccessMode accessMode) {
|
protected void writeFile(final String path, final String content, final AccessMode accessMode) {
|
||||||
final int fileMode = accessMode == AccessMode.READ_ONLY ? 0100644 : 0100666;
|
final int fileMode = Integer.decode(accessMode == AccessMode.READ_ONLY ? "0100644" : "0100666");
|
||||||
sambaContainer.copyFileToContainer(Transferable.of(content, fileMode), getContainerPath(path));
|
sambaContainer.copyFileToContainer(Transferable.of(content, fileMode), getContainerPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class SNMPTreeResponseTest {
|
|||||||
private static VariableBinding[] vbs3;
|
private static VariableBinding[] vbs3;
|
||||||
private static Map<String, String> vbMap;
|
private static Map<String, String> vbMap;
|
||||||
@Mock
|
@Mock
|
||||||
private static Target target;
|
private static Target<UdpAddress> target;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
@ -66,7 +66,7 @@ public class SNMPTreeResponseTest {
|
|||||||
vbMap.put(SNMP_PREFIX + OID_2 + SNMP_SEPARATOR + VB_SYNTAX, OID_2_VALUE);
|
vbMap.put(SNMP_PREFIX + OID_2 + SNMP_SEPARATOR + VB_SYNTAX, OID_2_VALUE);
|
||||||
vbMap.put(SNMP_PREFIX + OID_3 + SNMP_SEPARATOR + VB_SYNTAX, OID_3_VALUE);
|
vbMap.put(SNMP_PREFIX + OID_3 + SNMP_SEPARATOR + VB_SYNTAX, OID_3_VALUE);
|
||||||
|
|
||||||
target = new CommunityTarget();
|
target = new CommunityTarget<>();
|
||||||
target.setAddress(new UdpAddress(TARGET_ADDRESS));
|
target.setAddress(new UdpAddress(TARGET_ADDRESS));
|
||||||
|
|
||||||
vbs1 = new VariableBinding[]{
|
vbs1 = new VariableBinding[]{
|
||||||
|
@ -253,13 +253,11 @@ public class TestDatabaseParameterProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ResultSetAnswer implements Answer<Boolean> {
|
private class ResultSetAnswer implements Answer<Boolean> {
|
||||||
private final List<java.util.Map<String, String>> rows;
|
|
||||||
|
|
||||||
private Iterator<java.util.Map<String, String>> rowIterator;
|
private final Iterator<java.util.Map<String, String>> rowIterator;
|
||||||
private java.util.Map<String, String> currentRow;
|
private java.util.Map<String, String> currentRow;
|
||||||
|
|
||||||
private ResultSetAnswer(final List<java.util.Map<String, String>> rows) {
|
private ResultSetAnswer(final List<java.util.Map<String, String>> rows) {
|
||||||
this.rows = rows;
|
|
||||||
this.rowIterator = rows.iterator();
|
this.rowIterator = rows.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
public class TestExecuteSQLRecord {
|
public class TestExecuteSQLRecord {
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(TestExecuteSQLRecord.class);;
|
private final Logger LOGGER = LoggerFactory.getLogger(TestExecuteSQLRecord.class);
|
||||||
|
|
||||||
final static String DB_LOCATION = "target/db";
|
final static String DB_LOCATION = "target/db";
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.channels.SelectableChannel;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
@ -97,13 +98,13 @@ public class TestListenUDPRecord {
|
|||||||
public void testSuccessWithBatchSizeGreaterThanAvailableRecords() {
|
public void testSuccessWithBatchSizeGreaterThanAvailableRecords() {
|
||||||
final String sender = "foo";
|
final String sender = "foo";
|
||||||
|
|
||||||
final StandardEvent event1 = new StandardEvent(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event1 = new StandardEvent<>(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event1);
|
proc.addEvent(event1);
|
||||||
|
|
||||||
final StandardEvent event2 = new StandardEvent(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event2 = new StandardEvent<>(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event2);
|
proc.addEvent(event2);
|
||||||
|
|
||||||
final StandardEvent event3 = new StandardEvent(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event3 = new StandardEvent<>(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event3);
|
proc.addEvent(event3);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
@ -117,13 +118,13 @@ public class TestListenUDPRecord {
|
|||||||
public void testSuccessWithBatchLessThanAvailableRecords() {
|
public void testSuccessWithBatchLessThanAvailableRecords() {
|
||||||
final String sender = "foo";
|
final String sender = "foo";
|
||||||
|
|
||||||
final StandardEvent event1 = new StandardEvent(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event1 = new StandardEvent<>(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event1);
|
proc.addEvent(event1);
|
||||||
|
|
||||||
final StandardEvent event2 = new StandardEvent(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event2 = new StandardEvent<>(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event2);
|
proc.addEvent(event2);
|
||||||
|
|
||||||
final StandardEvent event3 = new StandardEvent(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event3 = new StandardEvent<>(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event3);
|
proc.addEvent(event3);
|
||||||
|
|
||||||
runner.setProperty(ListenUDPRecord.BATCH_SIZE, "1");
|
runner.setProperty(ListenUDPRecord.BATCH_SIZE, "1");
|
||||||
@ -161,10 +162,10 @@ public class TestListenUDPRecord {
|
|||||||
public void testMultipleRecordsPerDatagram() {
|
public void testMultipleRecordsPerDatagram() {
|
||||||
final String sender = "foo";
|
final String sender = "foo";
|
||||||
|
|
||||||
final StandardEvent event1 = new StandardEvent(sender, MULTI_DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event1 = new StandardEvent<>(sender, MULTI_DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event1);
|
proc.addEvent(event1);
|
||||||
|
|
||||||
final StandardEvent event2 = new StandardEvent(sender, MULTI_DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event2 = new StandardEvent<>(sender, MULTI_DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event2);
|
proc.addEvent(event2);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
@ -178,10 +179,10 @@ public class TestListenUDPRecord {
|
|||||||
public void testParseFailure() {
|
public void testParseFailure() {
|
||||||
final String sender = "foo";
|
final String sender = "foo";
|
||||||
|
|
||||||
final StandardEvent event1 = new StandardEvent(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event1 = new StandardEvent<>(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event1);
|
proc.addEvent(event1);
|
||||||
|
|
||||||
final StandardEvent event2 = new StandardEvent(sender, "WILL NOT PARSE".getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event2 = new StandardEvent<>(sender, "WILL NOT PARSE".getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event2);
|
proc.addEvent(event2);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
@ -203,13 +204,13 @@ public class TestListenUDPRecord {
|
|||||||
|
|
||||||
final String sender = "foo";
|
final String sender = "foo";
|
||||||
|
|
||||||
final StandardEvent event1 = new StandardEvent(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event1 = new StandardEvent<>(sender, DATAGRAM_1.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event1);
|
proc.addEvent(event1);
|
||||||
|
|
||||||
final StandardEvent event2 = new StandardEvent(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event2 = new StandardEvent<>(sender, DATAGRAM_2.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event2);
|
proc.addEvent(event2);
|
||||||
|
|
||||||
final StandardEvent event3 = new StandardEvent(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
final StandardEvent<SelectableChannel> event3 = new StandardEvent<>(sender, DATAGRAM_3.getBytes(StandardCharsets.UTF_8), null);
|
||||||
proc.addEvent(event3);
|
proc.addEvent(event3);
|
||||||
|
|
||||||
runner.run();
|
runner.run();
|
||||||
@ -219,8 +220,8 @@ public class TestListenUDPRecord {
|
|||||||
|
|
||||||
private static class TestableListenUDPRecord extends ListenUDPRecord {
|
private static class TestableListenUDPRecord extends ListenUDPRecord {
|
||||||
|
|
||||||
private volatile BlockingQueue<StandardEvent> testEvents = new LinkedBlockingQueue<>();
|
private volatile BlockingQueue<StandardEvent<SelectableChannel>> testEvents = new LinkedBlockingQueue<>();
|
||||||
private volatile BlockingQueue<StandardEvent> testErrorEvents = new LinkedBlockingQueue<>();
|
private volatile BlockingQueue<StandardEvent<SelectableChannel>> testErrorEvents = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ChannelDispatcher createDispatcher(ProcessContext context, BlockingQueue<StandardEvent> events) throws IOException {
|
protected ChannelDispatcher createDispatcher(ProcessContext context, BlockingQueue<StandardEvent> events) throws IOException {
|
||||||
|
@ -171,7 +171,7 @@ public class TestReplaceText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithEscaped$InReplacement() throws IOException {
|
public void testWithEscapedDollarSignInReplacement() throws IOException {
|
||||||
final TestRunner runner = getRunner();
|
final TestRunner runner = getRunner();
|
||||||
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
|
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
|
||||||
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a\\$b");
|
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a\\$b");
|
||||||
@ -185,7 +185,7 @@ public class TestReplaceText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithUnEscaped$InReplacement() throws IOException {
|
public void testWithUnEscapedDollarSignInReplacement() throws IOException {
|
||||||
final TestRunner runner = getRunner();
|
final TestRunner runner = getRunner();
|
||||||
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
|
runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s:^.*$)");
|
||||||
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a$b");
|
runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "a$b");
|
||||||
|
@ -357,12 +357,12 @@ class TestJsonPathRowRecordReader {
|
|||||||
final JsonPathRowRecordReader reader = new JsonPathRowRecordReader(jsonPaths, schema, in, Mockito.mock(ComponentLog.class), dateFormat, timeFormat, timestampFormat)) {
|
final JsonPathRowRecordReader reader = new JsonPathRowRecordReader(jsonPaths, schema, in, Mockito.mock(ComponentLog.class), dateFormat, timeFormat, timestampFormat)) {
|
||||||
|
|
||||||
final List<String> fieldNames = schema.getFieldNames();
|
final List<String> fieldNames = schema.getFieldNames();
|
||||||
final List<String> expectedFieldNames = Arrays.asList(new String[] {"id", "name", "balance", "address", "city", "state", "zipCode", "country", "accountIds"});
|
final List<String> expectedFieldNames = Arrays.asList("id", "name", "balance", "address", "city", "state", "zipCode", "country", "accountIds");
|
||||||
assertEquals(expectedFieldNames, fieldNames);
|
assertEquals(expectedFieldNames, fieldNames);
|
||||||
|
|
||||||
final List<RecordFieldType> dataTypes = schema.getDataTypes().stream().map(dt -> dt.getFieldType()).collect(Collectors.toList());
|
final List<RecordFieldType> dataTypes = schema.getDataTypes().stream().map(dt -> dt.getFieldType()).collect(Collectors.toList());
|
||||||
final List<RecordFieldType> expectedTypes = Arrays.asList(new RecordFieldType[] {RecordFieldType.INT, RecordFieldType.STRING, RecordFieldType.DOUBLE, RecordFieldType.STRING,
|
final List<RecordFieldType> expectedTypes = Arrays.asList(RecordFieldType.INT, RecordFieldType.STRING, RecordFieldType.DOUBLE, RecordFieldType.STRING,
|
||||||
RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.ARRAY});
|
RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.STRING, RecordFieldType.ARRAY);
|
||||||
assertEquals(expectedTypes, dataTypes);
|
assertEquals(expectedTypes, dataTypes);
|
||||||
|
|
||||||
final Object[] firstRecordValues = reader.nextRecord().getValues();
|
final Object[] firstRecordValues = reader.nextRecord().getValues();
|
||||||
|
@ -57,7 +57,7 @@ class TestSchemaInferenceUtil {
|
|||||||
Arguments.of("tRUE", RecordFieldType.BOOLEAN.getDataType()),
|
Arguments.of("tRUE", RecordFieldType.BOOLEAN.getDataType()),
|
||||||
Arguments.of("fALSE", RecordFieldType.BOOLEAN.getDataType()),
|
Arguments.of("fALSE", RecordFieldType.BOOLEAN.getDataType()),
|
||||||
|
|
||||||
Arguments.of(new BigDecimal(Double.MAX_VALUE - 1).toPlainString() + ".01", RecordFieldType.DOUBLE.getDataType()),
|
Arguments.of(new BigDecimal(Double.toString(Double.MAX_VALUE - 1)).toPlainString() + ".01", RecordFieldType.DOUBLE.getDataType()),
|
||||||
|
|
||||||
Arguments.of(String.valueOf(1.1D), RecordFieldType.FLOAT.getDataType()),
|
Arguments.of(String.valueOf(1.1D), RecordFieldType.FLOAT.getDataType()),
|
||||||
|
|
||||||
|
@ -425,19 +425,19 @@ public class TestXMLRecordReader {
|
|||||||
null, "CONTENT", dateFormat, timeFormat, timestampFormat, Mockito.mock(ComponentLog.class));
|
null, "CONTENT", dateFormat, timeFormat, timestampFormat, Mockito.mock(ComponentLog.class));
|
||||||
|
|
||||||
Record first = reader.nextRecord(false, false);
|
Record first = reader.nextRecord(false, false);
|
||||||
assertTrue(Arrays.asList(new Object[] {"Cleve Butler", "42", "USA", "P1"}).containsAll(Arrays.asList(first.getValues())));
|
assertTrue(List.of("Cleve Butler", "42", "USA", "P1").containsAll(Arrays.asList(first.getValues())));
|
||||||
assertEquals("P1", first.getAsString("ID"));
|
assertEquals("P1", first.getAsString("ID"));
|
||||||
|
|
||||||
Record second = reader.nextRecord(false, false);
|
Record second = reader.nextRecord(false, false);
|
||||||
assertTrue(Arrays.asList(new Object[] {"Ainslie Fletcher", "33", "UK", "P2"}).containsAll(Arrays.asList(second.getValues())));
|
assertTrue(List.of("Ainslie Fletcher", "33", "UK", "P2").containsAll(Arrays.asList(second.getValues())));
|
||||||
assertEquals("P2", second.getAsString("ID"));
|
assertEquals("P2", second.getAsString("ID"));
|
||||||
|
|
||||||
Record third = reader.nextRecord(false, false);
|
Record third = reader.nextRecord(false, false);
|
||||||
assertTrue(Arrays.asList(new Object[] {"Amélie Bonfils", "74", "FR", "P3"}).containsAll(Arrays.asList(third.getValues())));
|
assertTrue(List.of("Amélie Bonfils", "74", "FR", "P3").containsAll(Arrays.asList(third.getValues())));
|
||||||
assertEquals("P3", third.getAsString("ID"));
|
assertEquals("P3", third.getAsString("ID"));
|
||||||
|
|
||||||
Record fourth = reader.nextRecord(false, false);
|
Record fourth = reader.nextRecord(false, false);
|
||||||
assertTrue(Arrays.asList(new Object[] {"Elenora Scrivens", "16", "USA", "P4"}).containsAll(Arrays.asList(fourth.getValues())));
|
assertTrue(List.of("Elenora Scrivens", "16", "USA", "P4").containsAll(Arrays.asList(fourth.getValues())));
|
||||||
assertEquals("P4", fourth.getAsString("ID"));
|
assertEquals("P4", fourth.getAsString("ID"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class TestXMLRecordSetWriter {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSchemaRootRecordNaming() throws IOException, InitializationException {
|
public void testSchemaRootRecordNaming() throws IOException, InitializationException {
|
||||||
String avroSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/xml/testschema3")));;
|
String avroSchemaText = new String(Files.readAllBytes(Paths.get("src/test/resources/xml/testschema3")));
|
||||||
Schema avroSchema = new Schema.Parser().parse(avroSchemaText);
|
Schema avroSchema = new Schema.Parser().parse(avroSchemaText);
|
||||||
|
|
||||||
SchemaIdentifier schemaId = SchemaIdentifier.builder().name("schemaName").build();
|
SchemaIdentifier schemaId = SchemaIdentifier.builder().name("schemaName").build();
|
||||||
|
@ -39,7 +39,7 @@ class ControllerServiceEntityMergerTest {
|
|||||||
void testMergeStatusFields() {
|
void testMergeStatusFields() {
|
||||||
final ControllerServiceEntity nodeOneControllerserviceEntity = getControllerServiceEntity("id1", RunStatus.Stopped.name(), ValidationStatus.VALIDATING.name());
|
final ControllerServiceEntity nodeOneControllerserviceEntity = getControllerServiceEntity("id1", RunStatus.Stopped.name(), ValidationStatus.VALIDATING.name());
|
||||||
final ControllerServiceEntity nodeTwoControllerServiceEntity = getControllerServiceEntity("id2", RunStatus.Validating.name(), ValidationStatus.INVALID.name());
|
final ControllerServiceEntity nodeTwoControllerServiceEntity = getControllerServiceEntity("id2", RunStatus.Validating.name(), ValidationStatus.INVALID.name());
|
||||||
final Map<NodeIdentifier, ControllerServiceEntity> entityMap = new HashMap();
|
final Map<NodeIdentifier, ControllerServiceEntity> entityMap = new HashMap<>();
|
||||||
entityMap.put(getNodeIdentifier("node1", 8000), nodeOneControllerserviceEntity);
|
entityMap.put(getNodeIdentifier("node1", 8000), nodeOneControllerserviceEntity);
|
||||||
entityMap.put(getNodeIdentifier("node2", 8010), nodeTwoControllerServiceEntity);
|
entityMap.put(getNodeIdentifier("node2", 8010), nodeTwoControllerServiceEntity);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class ReportingTaskEntityMergerTest {
|
|||||||
void testMergeStatusFields() {
|
void testMergeStatusFields() {
|
||||||
final ReportingTaskEntity nodeOneReportingTaskEntity = getReportingTaskEntity("id1", ReportingTaskStatusDTO.RUNNING, ValidationStatus.VALID.name());
|
final ReportingTaskEntity nodeOneReportingTaskEntity = getReportingTaskEntity("id1", ReportingTaskStatusDTO.RUNNING, ValidationStatus.VALID.name());
|
||||||
final ReportingTaskEntity nodeTwoReportingTaskEntity = getReportingTaskEntity("id2", ReportingTaskStatusDTO.RUNNING, ValidationStatus.VALIDATING.name());
|
final ReportingTaskEntity nodeTwoReportingTaskEntity = getReportingTaskEntity("id2", ReportingTaskStatusDTO.RUNNING, ValidationStatus.VALIDATING.name());
|
||||||
final Map<NodeIdentifier, ReportingTaskEntity> entityMap = new HashMap();
|
final Map<NodeIdentifier, ReportingTaskEntity> entityMap = new HashMap<>();
|
||||||
entityMap.put(getNodeIdentifier("node1", 8000), nodeOneReportingTaskEntity);
|
entityMap.put(getNodeIdentifier("node1", 8000), nodeOneReportingTaskEntity);
|
||||||
entityMap.put(getNodeIdentifier("node2", 8010), nodeTwoReportingTaskEntity);
|
entityMap.put(getNodeIdentifier("node2", 8010), nodeTwoReportingTaskEntity);
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import org.apache.nifi.events.EventReporter;
|
|||||||
import org.apache.nifi.flowfile.FlowFile;
|
import org.apache.nifi.flowfile.FlowFile;
|
||||||
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
import org.apache.nifi.flowfile.attributes.CoreAttributes;
|
||||||
import org.apache.nifi.flowfile.attributes.SiteToSiteAttributes;
|
import org.apache.nifi.flowfile.attributes.SiteToSiteAttributes;
|
||||||
import org.apache.nifi.groups.ProcessGroup;
|
|
||||||
import org.apache.nifi.groups.RemoteProcessGroup;
|
import org.apache.nifi.groups.RemoteProcessGroup;
|
||||||
import org.apache.nifi.processor.Processor;
|
import org.apache.nifi.processor.Processor;
|
||||||
import org.apache.nifi.processor.Relationship;
|
import org.apache.nifi.processor.Relationship;
|
||||||
@ -76,7 +75,6 @@ public class TestStandardRemoteGroupPort {
|
|||||||
private SiteToSiteClient siteToSiteClient;
|
private SiteToSiteClient siteToSiteClient;
|
||||||
private Transaction transaction;
|
private Transaction transaction;
|
||||||
private EventReporter eventReporter;
|
private EventReporter eventReporter;
|
||||||
private ProcessGroup processGroup;
|
|
||||||
private static final String REMOTE_CLUSTER_URL = "http://node0.example.com:8080/nifi";
|
private static final String REMOTE_CLUSTER_URL = "http://node0.example.com:8080/nifi";
|
||||||
private StandardRemoteGroupPort port;
|
private StandardRemoteGroupPort port;
|
||||||
private SharedSessionState sessionState;
|
private SharedSessionState sessionState;
|
||||||
@ -98,7 +96,6 @@ public class TestStandardRemoteGroupPort {
|
|||||||
private void setupMock(final SiteToSiteTransportProtocol protocol,
|
private void setupMock(final SiteToSiteTransportProtocol protocol,
|
||||||
final TransferDirection direction,
|
final TransferDirection direction,
|
||||||
final SiteToSiteClientConfig siteToSiteClientConfig) throws Exception {
|
final SiteToSiteClientConfig siteToSiteClientConfig) throws Exception {
|
||||||
processGroup = null;
|
|
||||||
remoteGroup = mock(RemoteProcessGroup.class);
|
remoteGroup = mock(RemoteProcessGroup.class);
|
||||||
scheduler = null;
|
scheduler = null;
|
||||||
siteToSiteClient = mock(SiteToSiteClient.class);
|
siteToSiteClient = mock(SiteToSiteClient.class);
|
||||||
|
@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
|
|
||||||
class ByteRangeStreamingOutputTest {
|
class ByteRangeStreamingOutputTest {
|
||||||
|
|
||||||
private static final byte[] INPUT_BYTES = String.class.getSimpleName().getBytes(StandardCharsets.UTF_8);;
|
private static final byte[] INPUT_BYTES = String.class.getSimpleName().getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
private static final long NOT_SATISFIABLE_LENGTH = 1000;
|
private static final long NOT_SATISFIABLE_LENGTH = 1000;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
|
|
||||||
class StreamingOutputResponseBuilderTest {
|
class StreamingOutputResponseBuilderTest {
|
||||||
|
|
||||||
private static final byte[] INPUT_BYTES = String.class.getSimpleName().getBytes(StandardCharsets.UTF_8);;
|
private static final byte[] INPUT_BYTES = String.class.getSimpleName().getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
private static final String RANGE = "bytes=0-%d".formatted(INPUT_BYTES.length);
|
private static final String RANGE = "bytes=0-%d".formatted(INPUT_BYTES.length);
|
||||||
|
|
||||||
|
@ -20,11 +20,12 @@ import org.apache.nifi.authorization.user.NiFiUser;
|
|||||||
import org.apache.nifi.groups.ProcessGroup;
|
import org.apache.nifi.groups.ProcessGroup;
|
||||||
import org.apache.nifi.util.StringUtils;
|
import org.apache.nifi.util.StringUtils;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.stream.Stream;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@ -52,30 +53,30 @@ public class RegexSearchQueryParserTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<Object[]> data() {
|
private static Stream<Arguments> data() {
|
||||||
return Arrays.asList(new Object[][]{
|
return Stream.of(
|
||||||
{"", "", new String[]{}, new String[]{}},
|
Arguments.of("", "", new String[]{}, new String[]{}),
|
||||||
{"lorem ipsum", "lorem ipsum", new String[]{}, new String[]{}},
|
Arguments.of("lorem ipsum", "lorem ipsum", new String[]{}, new String[]{}),
|
||||||
{"lorem ipsum ", "lorem ipsum ", new String[]{}, new String[]{}},
|
Arguments.of("lorem ipsum ", "lorem ipsum ", new String[]{}, new String[]{}),
|
||||||
{"a:b c:d lorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}},
|
Arguments.of("a:b c:d lorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}),
|
||||||
{"a:b\tc:d\tlorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}},
|
Arguments.of("a:b\tc:d\tlorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}),
|
||||||
{"a:b c:d lorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}},
|
Arguments.of("a:b c:d lorem ipsum", "lorem ipsum", new String[]{"a", "c"}, new String[]{"b", "d"}),
|
||||||
{"1a:1b c2:d2 lorem ipsum", "lorem ipsum", new String[]{"1a", "c2"}, new String[]{"1b", "d2"}},
|
Arguments.of("1a:1b c2:d2 lorem ipsum", "lorem ipsum", new String[]{"1a", "c2"}, new String[]{"1b", "d2"}),
|
||||||
{"1:2 3:4 lorem ipsum", "lorem ipsum", new String[]{"1", "3"}, new String[]{"2", "4"}},
|
Arguments.of("1:2 3:4 lorem ipsum", "lorem ipsum", new String[]{"1", "3"}, new String[]{"2", "4"}),
|
||||||
{"a:b lorem c:d ipsum", "lorem c:d ipsum", new String[]{"a"}, new String[]{"b"}},
|
Arguments.of("a:b lorem c:d ipsum", "lorem c:d ipsum", new String[]{"a"}, new String[]{"b"}),
|
||||||
{"a:b lorem ipsum c:d", "lorem ipsum c:d", new String[]{"a"}, new String[]{"b"}},
|
Arguments.of("a:b lorem ipsum c:d", "lorem ipsum c:d", new String[]{"a"}, new String[]{"b"}),
|
||||||
{"a:b lorem ipsum c:d ", "lorem ipsum c:d ", new String[]{"a"}, new String[]{"b"}},
|
Arguments.of("a:b lorem ipsum c:d ", "lorem ipsum c:d ", new String[]{"a"}, new String[]{"b"}),
|
||||||
{"lorem ipsum a:b", "lorem ipsum a:b", new String[]{}, new String[]{}},
|
Arguments.of("lorem ipsum a:b", "lorem ipsum a:b", new String[]{}, new String[]{}),
|
||||||
{"a:b c:d", StringUtils.EMPTY, new String[]{"a", "c"}, new String[]{"b", "d"}},
|
Arguments.of("a:b c:d", StringUtils.EMPTY, new String[]{"a", "c"}, new String[]{"b", "d"}),
|
||||||
{"a:b c:d ", StringUtils.EMPTY, new String[]{"a", "c"}, new String[]{"b", "d"}},
|
Arguments.of("a:b c:d ", StringUtils.EMPTY, new String[]{"a", "c"}, new String[]{"b", "d"}),
|
||||||
{"a: lorem ipsum", "a: lorem ipsum", new String[]{}, new String[]{}},
|
Arguments.of("a: lorem ipsum", "a: lorem ipsum", new String[]{}, new String[]{}),
|
||||||
{":b lorem ipsum", ":b lorem ipsum", new String[]{}, new String[]{}},
|
Arguments.of(":b lorem ipsum", ":b lorem ipsum", new String[]{}, new String[]{}),
|
||||||
{":b lorem ipsum", ":b lorem ipsum", new String[]{}, new String[]{}},
|
Arguments.of(":b lorem ipsum", ":b lorem ipsum", new String[]{}, new String[]{}),
|
||||||
{"a:b a:b lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b"}},
|
Arguments.of("a:b a:b lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b"}),
|
||||||
{"a:b a:c lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b"}},
|
Arguments.of("a:b a:c lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b"}),
|
||||||
{"a:b-c", StringUtils.EMPTY, new String[]{"a"}, new String[]{"b-c"}},
|
Arguments.of("a:b-c", StringUtils.EMPTY, new String[]{"a"}, new String[]{"b-c"}),
|
||||||
{"a:b-c lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b-c"}},
|
Arguments.of("a:b-c lorem ipsum", "lorem ipsum", new String[]{"a"}, new String[]{"b-c"}),
|
||||||
{"a:b-c d:e lorem ipsum", "lorem ipsum", new String[]{"a", "d"}, new String[]{"b-c", "e"}}
|
Arguments.of("a:b-c d:e lorem ipsum", "lorem ipsum", new String[]{"a", "d"}, new String[]{"b-c", "e"})
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,55 +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.web.revision;
|
|
||||||
|
|
||||||
import org.apache.nifi.authorization.user.NiFiUser;
|
|
||||||
import org.apache.nifi.authorization.user.StandardNiFiUser.Builder;
|
|
||||||
import org.apache.nifi.web.FlowModification;
|
|
||||||
import org.apache.nifi.web.Revision;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class TestNaiveRevisionManager {
|
|
||||||
private static final String CLIENT_1 = "client-1";
|
|
||||||
private static final String COMPONENT_1 = "component-1";
|
|
||||||
private static final NiFiUser USER_1 = new Builder().identity("user-1").build();
|
|
||||||
|
|
||||||
private RevisionUpdate<Object> components(final Revision revision) {
|
|
||||||
return new StandardRevisionUpdate<>(null, new FlowModification(revision, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
private RevisionUpdate<Object> components(final Revision revision, final Revision... additionalRevisions) {
|
|
||||||
final Set<Revision> revisionSet = new HashSet<>();
|
|
||||||
for (final Revision rev : additionalRevisions) {
|
|
||||||
revisionSet.add(rev);
|
|
||||||
}
|
|
||||||
return components(revision, revisionSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RevisionUpdate<Object> components(final Revision revision, final Set<Revision> additionalRevisions) {
|
|
||||||
final Set<RevisionUpdate<Object>> components = new HashSet<>();
|
|
||||||
for (final Revision rev : additionalRevisions) {
|
|
||||||
components.add(new StandardRevisionUpdate<>(null, new FlowModification(rev, null)));
|
|
||||||
}
|
|
||||||
return new StandardRevisionUpdate<>(null, new FlowModification(revision, null), additionalRevisions);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -98,7 +98,7 @@ public class TestDatabaseUserGroupProvider extends DatabaseBaseTest {
|
|||||||
private void createUser(final String userIdentifier, final String userIdentity) {
|
private void createUser(final String userIdentifier, final String userIdentity) {
|
||||||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
final String sql = "INSERT INTO UGP_USER(IDENTIFIER, IDENTITY) VALUES (?, ?)";
|
final String sql = "INSERT INTO UGP_USER(IDENTIFIER, IDENTITY) VALUES (?, ?)";
|
||||||
final int updatedRows1 = jdbcTemplate.update(sql, new Object[] {userIdentifier, userIdentity});
|
final int updatedRows1 = jdbcTemplate.update(sql, userIdentifier, userIdentity);
|
||||||
assertEquals(1, updatedRows1);
|
assertEquals(1, updatedRows1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public class TestDatabaseUserGroupProvider extends DatabaseBaseTest {
|
|||||||
private void createGroup(final String groupIdentifier, final String groupIdentity) {
|
private void createGroup(final String groupIdentifier, final String groupIdentity) {
|
||||||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
final String sql = "INSERT INTO UGP_GROUP(IDENTIFIER, IDENTITY) VALUES (?, ?)";
|
final String sql = "INSERT INTO UGP_GROUP(IDENTIFIER, IDENTITY) VALUES (?, ?)";
|
||||||
final int updatedRows1 = jdbcTemplate.update(sql, new Object[] {groupIdentifier, groupIdentity});
|
final int updatedRows1 = jdbcTemplate.update(sql, groupIdentifier, groupIdentity);
|
||||||
assertEquals(1, updatedRows1);
|
assertEquals(1, updatedRows1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class TestDatabaseUserGroupProvider extends DatabaseBaseTest {
|
|||||||
private void addUserToGroup(final String userIdentifier, final String groupIdentifier) {
|
private void addUserToGroup(final String userIdentifier, final String groupIdentifier) {
|
||||||
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
final String sql = "INSERT INTO UGP_USER_GROUP(USER_IDENTIFIER, GROUP_IDENTIFIER) VALUES (?, ?)";
|
final String sql = "INSERT INTO UGP_USER_GROUP(USER_IDENTIFIER, GROUP_IDENTIFIER) VALUES (?, ?)";
|
||||||
final int updatedRows1 = jdbcTemplate.update(sql, new Object[] {userIdentifier, groupIdentifier});
|
final int updatedRows1 = jdbcTemplate.update(sql, userIdentifier, groupIdentifier);
|
||||||
assertEquals(1, updatedRows1);
|
assertEquals(1, updatedRows1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class S3BundlePersistenceProviderIT {
|
|||||||
try {
|
try {
|
||||||
s3Client.close();
|
s3Client.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();;
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
|
|||||||
|
|
||||||
private ConnectionEntity defaultedModifyClasspathInputConnection;
|
private ConnectionEntity defaultedModifyClasspathInputConnection;
|
||||||
private ConnectionEntity successConnection;
|
private ConnectionEntity successConnection;
|
||||||
private ConnectionEntity failureConnection;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
|
void testLoadsClassFromDefaultedDynamicModification() throws NiFiClientException, IOException, InterruptedException {
|
||||||
@ -100,6 +99,6 @@ class DefaultedDynamicClassPathModificationIT extends NiFiSystemIT {
|
|||||||
|
|
||||||
defaultedModifyClasspathInputConnection = getClientUtil().createConnection(generateFlowFileProcessor, defaultedModifyClasspathProcessor, "success");
|
defaultedModifyClasspathInputConnection = getClientUtil().createConnection(generateFlowFileProcessor, defaultedModifyClasspathProcessor, "success");
|
||||||
successConnection = getClientUtil().createConnection(defaultedModifyClasspathProcessor, terminateSuccess, "success");
|
successConnection = getClientUtil().createConnection(defaultedModifyClasspathProcessor, terminateSuccess, "success");
|
||||||
failureConnection = getClientUtil().createConnection(defaultedModifyClasspathProcessor, terminateFailure, "failure");
|
getClientUtil().createConnection(defaultedModifyClasspathProcessor, terminateFailure, "failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
pom.xml
1
pom.xml
@ -1000,6 +1000,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<printFailingErrors>true</printFailingErrors>
|
<printFailingErrors>true</printFailingErrors>
|
||||||
<linkXRef>false</linkXRef>
|
<linkXRef>false</linkXRef>
|
||||||
|
<includeTests>true</includeTests>
|
||||||
<targetJdk>${maven.compiler.release}</targetJdk>
|
<targetJdk>${maven.compiler.release}</targetJdk>
|
||||||
<rulesets>
|
<rulesets>
|
||||||
<ruleset>${maven.multiModuleProjectDirectory}/pmd-ruleset.xml</ruleset>
|
<ruleset>${maven.multiModuleProjectDirectory}/pmd-ruleset.xml</ruleset>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user