Skip to content

Commit

Permalink
NIFI-14051 Removed unnecessary generic type declarations (#9562)
Browse files Browse the repository at this point in the history
Signed-off-by: David Handermann <[email protected]>
  • Loading branch information
dan-s1 authored Dec 6, 2024
1 parent 3c9ecd8 commit ba9273f
Show file tree
Hide file tree
Showing 134 changed files with 1,117 additions and 1,660 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ private Evaluator<?> buildFunctionEvaluator(final Tree tree, final Evaluator<?>
toStringEvaluator(argEvaluators.get(0), "first argument to contains")), "contains");
}
case IN: {
List<Evaluator<String>> list = new ArrayList<Evaluator<String>>();
List<Evaluator<String>> list = new ArrayList<>();
for (int i = 0; i < argEvaluators.size(); i++) {
list.add(toStringEvaluator(argEvaluators.get(i), i + "th argument to in"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public QueryResult evaluate(final HL7Message message) {
if (value instanceof List) {
possibleValues = (List<Object>) value;
} else if (value instanceof Collection) {
possibleValues = new ArrayList<Object>((Collection<Object>) value);
possibleValues = new ArrayList<>((Collection<Object>) value);
} else {
possibleValues = new ArrayList<>(1);
possibleValues.add(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public Set<String> deadlockedThreads() {
@Override
public Map<Thread.State, Double> threadStatePercentages() {
int totalThreadCount = (Integer) getMetric(THREADS_COUNT);
final Map<Thread.State, Double> threadStatePercentages = new HashMap<Thread.State, Double>();
final Map<Thread.State, Double> threadStatePercentages = new HashMap<>();
for (Thread.State state : Thread.State.values()) {
threadStatePercentages.put(state, (Integer) getMetric(REGISTRY_METRICSET_THREADS + "." + state.name().toLowerCase() + ".count") / (double) totalThreadCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,110 +243,100 @@ public void testShouldVerifyExceptionThrownWhenPortValueIsZero() {
@Test
public void testShouldHaveReasonableMaxContentLengthValues() {
// Arrange with default values:
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<>());

// Assert defaults match expectations:
assertNull(properties.getWebMaxContentSize());

// Re-arrange with specific values:
final String size = "size value";
properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.WEB_MAX_CONTENT_SIZE, size);
}});
properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(NiFiProperties.WEB_MAX_CONTENT_SIZE, size));

// Assert specific values are used:
assertEquals(properties.getWebMaxContentSize(), size);
}

@Test
public void testIsZooKeeperTlsConfigurationPresent() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "password");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_PASSWD, "password");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "password",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_PASSWD, "password",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS"));

assertTrue(properties.isZooKeeperClientSecure());
assertTrue(properties.isZooKeeperTlsConfigurationPresent());
}

@Test
public void testSomeZooKeeperTlsConfigurationIsMissing() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "password");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "password",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS"));

assertTrue(properties.isZooKeeperClientSecure());
assertFalse(properties.isZooKeeperTlsConfigurationPresent());
}

@Test
public void testZooKeeperTlsPasswordsBlank() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "");
put(NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_PASSWD, "");
put(NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.ZOOKEEPER_CLIENT_SECURE, "true",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_PASSWD, "",
NiFiProperties.ZOOKEEPER_SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_PASSWD, "",
NiFiProperties.ZOOKEEPER_SECURITY_TRUSTSTORE_TYPE, "JKS"));

assertTrue(properties.isZooKeeperClientSecure());
assertTrue(properties.isZooKeeperTlsConfigurationPresent());
}

@Test
public void testKeystorePasswordIsMissing() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks");
put(NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
put(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD, "");
put(NiFiProperties.SECURITY_TRUSTSTORE_TYPE, "JKS");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks",
NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks",
NiFiProperties.SECURITY_TRUSTSTORE_PASSWD, "",
NiFiProperties.SECURITY_TRUSTSTORE_TYPE, "JKS"));

assertFalse(properties.isTlsConfigurationPresent());
}

@Test
public void testTlsConfigurationIsPresentWithEmptyPasswords() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks");
put(NiFiProperties.SECURITY_KEYSTORE_PASSWD, "");
put(NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
put(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD, "");
put(NiFiProperties.SECURITY_TRUSTSTORE_TYPE, "JKS");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.SECURITY_KEYSTORE, "/a/keystore/filepath/keystore.jks",
NiFiProperties.SECURITY_KEYSTORE_PASSWD, "",
NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks",
NiFiProperties.SECURITY_TRUSTSTORE_PASSWD, "",
NiFiProperties.SECURITY_TRUSTSTORE_TYPE, "JKS"));

assertTrue(properties.isTlsConfigurationPresent());
}

@Test
public void testTlsConfigurationIsNotPresentWithPropertiesMissing() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
put(NiFiProperties.SECURITY_KEYSTORE_PASSWD, "password");
put(NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS");
put(NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks");
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, Map.of(
NiFiProperties.SECURITY_KEYSTORE_PASSWD, "password",
NiFiProperties.SECURITY_KEYSTORE_TYPE, "JKS",
NiFiProperties.SECURITY_TRUSTSTORE, "/a/truststore/filepath/truststore.jks"));

assertFalse(properties.isTlsConfigurationPresent());
}

@Test
public void testTlsConfigurationIsNotPresentWithNoProperties() {
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<String, String>() {{
}});
NiFiProperties properties = NiFiProperties.createBasicNiFiProperties(null, new HashMap<>());

assertFalse(properties.isTlsConfigurationPresent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public enum RecordFieldType {
MAP("map", null, new MapDataType(null));


private static final Map<String, RecordFieldType> SIMPLE_NAME_MAP = new HashMap<String, RecordFieldType>();
private static final Map<String, RecordFieldType> SIMPLE_NAME_MAP = new HashMap<>();

static {
for (RecordFieldType value : values()) {
Expand Down
Loading

0 comments on commit ba9273f

Please sign in to comment.