diff options
author | Harald Musum <musum@yahooinc.com> | 2023-06-07 08:32:36 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-06-07 08:32:36 +0200 |
commit | 335ade42d91443f700c31bb3448d470a0de43cd2 (patch) | |
tree | f049465b449dcfe57fd3f99bf6aa257b2eb31336 /clustercontroller-utils/src/test/java/com/yahoo | |
parent | 3fff1ac29d976607382dc21dd9d542ef56671d67 (diff) |
Modernize
Diffstat (limited to 'clustercontroller-utils/src/test/java/com/yahoo')
2 files changed, 15 insertions, 15 deletions
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/DummyStateApi.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/DummyStateApi.java index d611b0c0ea8..2fcbf22aa59 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/DummyStateApi.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/DummyStateApi.java @@ -10,6 +10,7 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.UnitStateRe import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.*; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; public class DummyStateApi implements StateRestAPI { @@ -28,8 +29,8 @@ public class DummyStateApi implements StateRestAPI { } public class SubUnitListImpl implements SubUnitList { - private Map<String, String> links = new LinkedHashMap<>(); - private Map<String, UnitResponse> values = new LinkedHashMap<>(); + private final Map<String, String> links = new LinkedHashMap<>(); + private final Map<String, UnitResponse> values = new LinkedHashMap<>(); @Override public Map<String, String> getSubUnitLinks() { return links; } @@ -156,18 +157,18 @@ public class DummyStateApi implements StateRestAPI { @Override public UnitResponse getState(UnitStateRequest request) throws StateRestApiException { checkForInducedException(); - String[] path = request.getUnitPath(); - if (path.length == 0) { + List<String> path = request.getUnitPath(); + if (path.size() == 0) { return getClusterList(request.getRecursiveLevels()); } - final DummyBackend.Cluster c = backend.getClusters().get(path[0]); + DummyBackend.Cluster c = backend.getClusters().get(path.get(0)); if (c == null) throw new MissingUnitException(path, 0); - if (path.length == 1) { + if (path.size() == 1) { return getClusterState(c, request.getRecursiveLevels()); } - final DummyBackend.Node n = c.nodes.get(path[1]); + DummyBackend.Node n = c.nodes.get(path.get(1)); if (n == null) throw new MissingUnitException(path, 1); - if (path.length == 2) { + if (path.size() == 2) { return getNodeState(n); } throw new MissingUnitException(path, 3); @@ -176,15 +177,15 @@ public class DummyStateApi implements StateRestAPI { @Override public SetResponse setUnitState(SetUnitStateRequest request) throws StateRestApiException { checkForInducedException(); - String[] path = request.getUnitPath(); - if (path.length != 2) { + List<String> path = request.getUnitPath(); + if (path.size() != 2) { throw new OperationNotSupportedForUnitException( path, "You can only set states on nodes"); } DummyBackend.Node n = null; - DummyBackend.Cluster c = backend.getClusters().get(path[0]); + DummyBackend.Cluster c = backend.getClusters().get(path.get(0)); if (c != null) { - n = c.nodes.get(path[1]); + n = c.nodes.get(path.get(1)); } if (n == null) throw new MissingUnitException(path, 2); Map<String, UnitState> newState = request.getNewState(); diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java index 47b12f883ff..29e33b7906a 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/staterestapi/StateRestAPITest.java @@ -19,6 +19,7 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.server.RestApiHandle import com.yahoo.vespa.clustercontroller.utils.test.TestTransport; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -486,9 +487,7 @@ public class StateRestAPITest { assertEquals(expected, result.getContent().toString()); } { - String path[] = new String[1]; - path[0] = "foo"; - stateApi.induceException(new OperationNotSupportedForUnitException(path, "Foo")); + stateApi.induceException(new OperationNotSupportedForUnitException(List.of("foo"), "Foo")); HttpResult result = execute(new HttpRequest().setPath("/cluster/v2")); assertEquals(405, result.getHttpReturnCode(), result.toString(true)); assertEquals("Operation not supported for resource", result.getHttpReturnCodeDescription(), result.toString(true)); |