Addressing SonarCloud code smells (#3367)

* Resolving SonarCloud code smell 

Signed-off-by: Romeet Puhar <Romeet27@outlook.com>
Signed-off-by: RP27 <38156169+RP27@users.noreply.github.com>
Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/3386/head
RP27 3 years ago committed by GitHub
parent 9a37fde460
commit 6876e1a245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/net/ExpectNetServicesReturnsAllServicesAsActive.java
  2. 7
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/net/ExpectNetServicesReturnsOnlyJsonRpcActive.java

@ -29,6 +29,7 @@ import com.google.common.net.InetAddresses;
public class ExpectNetServicesReturnsAllServicesAsActive implements Condition {
private final NetServicesTransaction transaction;
private static final String JSON_RPC_CONSTANT = "jsonrpc";
public ExpectNetServicesReturnsAllServicesAsActive(final NetServicesTransaction transaction) {
this.transaction = transaction;
@ -38,18 +39,18 @@ public class ExpectNetServicesReturnsAllServicesAsActive implements Condition {
public void verify(final Node node) {
final Map<String, Map<String, String>> result = node.execute(transaction);
assertThat(result.keySet())
.containsExactlyInAnyOrderElementsOf(Arrays.asList("p2p", "jsonrpc", "ws"));
.containsExactlyInAnyOrderElementsOf(Arrays.asList("p2p", JSON_RPC_CONSTANT, "ws"));
assertThat(InetAddresses.isUriInetAddress(result.get("p2p").get("host"))).isTrue();
final int p2pPort = Integer.valueOf(result.get("p2p").get("port"));
final int p2pPort = Integer.parseInt(result.get("p2p").get("port"));
assertThat(NetworkUtility.isValidPort(p2pPort)).isTrue();
assertThat(InetAddresses.isUriInetAddress(result.get("ws").get("host"))).isTrue();
final int wsPort = Integer.valueOf(result.get("ws").get("port"));
final int wsPort = Integer.parseInt(result.get("ws").get("port"));
assertThat(NetworkUtility.isValidPort(wsPort)).isTrue();
assertThat(InetAddresses.isUriInetAddress(result.get("jsonrpc").get("host"))).isTrue();
final int jsonRpcPort = Integer.valueOf(result.get("jsonrpc").get("port"));
assertThat(InetAddresses.isUriInetAddress(result.get(JSON_RPC_CONSTANT).get("host"))).isTrue();
final int jsonRpcPort = Integer.parseInt(result.get(JSON_RPC_CONSTANT).get("port"));
assertThat(NetworkUtility.isValidPort(jsonRpcPort)).isTrue();
}
}

@ -29,6 +29,7 @@ import com.google.common.net.InetAddresses;
public class ExpectNetServicesReturnsOnlyJsonRpcActive implements Condition {
private final NetServicesTransaction transaction;
private static final String JSON_RPC_CONSTANT = "jsonrpc";
public ExpectNetServicesReturnsOnlyJsonRpcActive(final NetServicesTransaction transaction) {
this.transaction = transaction;
@ -38,10 +39,10 @@ public class ExpectNetServicesReturnsOnlyJsonRpcActive implements Condition {
public void verify(final Node node) {
final Map<String, Map<String, String>> result = node.execute(transaction);
assertThat(result.keySet())
.containsExactlyInAnyOrderElementsOf(Collections.singletonList("jsonrpc"));
.containsExactlyInAnyOrderElementsOf(Collections.singletonList(JSON_RPC_CONSTANT));
assertThat(InetAddresses.isUriInetAddress(result.get("jsonrpc").get("host"))).isTrue();
final int jsonrpcPort = Integer.valueOf(result.get("jsonrpc").get("port"));
assertThat(InetAddresses.isUriInetAddress(result.get(JSON_RPC_CONSTANT).get("host"))).isTrue();
final int jsonrpcPort = Integer.parseInt(result.get(JSON_RPC_CONSTANT).get("port"));
assertThat(NetworkUtility.isValidPort(jsonrpcPort)).isTrue();
}
}

Loading…
Cancel
Save