You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by va...@apache.org on 2023/08/07 11:08:26 UTC
[qpid-broker-j] branch main updated: QPID-8653: [Broker-J] Code cleanup: collection type arguments, collection factory methods, lambdas (#216)
This is an automated email from the ASF dual-hosted git repository.
vavrtom pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/main by this push:
new 609f1bfb86 QPID-8653: [Broker-J] Code cleanup: collection type arguments, collection factory methods, lambdas (#216)
609f1bfb86 is described below
commit 609f1bfb86fe22594759cbde89ec7acf64791651
Author: Daniil Kirilyuk <da...@gmail.com>
AuthorDate: Mon Aug 7 13:08:20 2023 +0200
QPID-8653: [Broker-J] Code cleanup: collection type arguments, collection factory methods, lambdas (#216)
---
.../management/plugin/HttpManagementUtil.java | 15 +-
.../auth/OAuth2InteractiveAuthenticator.java | 61 +++---
.../controller/AbstractManagementController.java | 3 +-
.../plugin/controller/CategoryController.java | 1 -
.../controller/CategoryControllerFactory.java | 1 -
.../controller/ControllerManagementResponse.java | 3 +-
.../plugin/controller/ConverterHelper.java | 1 -
.../controller/GenericCategoryController.java | 3 +-
.../controller/GenericLegacyConfiguredObject.java | 4 +-
.../latest/LatestManagementController.java | 36 ++--
.../latest/LatestManagementControllerAdapter.java | 5 +-
.../v6_1/LegacyManagementControllerFactory.java | 2 -
.../v6_1/category/BindingController.java | 28 +--
.../v6_1/category/ConsumerController.java | 7 +-
.../v6_1/category/DestinationController.java | 6 +-
.../v6_1/category/ExchangeController.java | 4 +-
.../category/LegacyCategoryControllerFactory.java | 77 +++----
.../v6_1/category/SessionController.java | 4 +-
.../v7_0/LegacyManagementControllerFactory.java | 2 -
.../v7_0/category/LegacyCategoryController.java | 1 -
.../category/LegacyCategoryControllerFactory.java | 21 +-
.../plugin/filter/AuthenticationCheckFilter.java | 10 +-
.../management/plugin/report/QueueReport.java | 1 -
.../query/ConfiguredObjectExpressionFactory.java | 118 +++++------
.../plugin/servlet/rest/AbstractServlet.java | 3 +-
.../rest/ConfiguredObjectToMapConverter.java | 21 +-
.../servlet/rest/PluginClassProviderAction.java | 6 +-
.../plugin/servlet/rest/RequestInfo.java | 9 +-
.../plugin/servlet/rest/RequestInfoParser.java | 2 +-
.../plugin/servlet/rest/RestServlet.java | 16 +-
.../servlet/rest/RestUserPreferenceHandler.java | 2 +-
.../plugin/servlet/rest/SaslServlet.java | 2 +-
.../plugin/servlet/rest/TimeZoneServlet.java | 2 +-
.../servlet/rest/VirtualHostQueryServlet.java | 2 +-
.../plugin/session/LoginLogoutReporter.java | 20 +-
.../auth/OAuth2InteractiveAuthenticatorTest.java | 14 +-
.../auth/OAuth2PreemptiveAuthenticatorTest.java | 13 +-
.../controller/GenericCategoryControllerTest.java | 48 ++---
.../LatestManagementControllerAdapterTest.java | 70 +++----
.../latest/LatestManagementControllerTest.java | 141 ++++++-------
.../v6_1/LegacyManagementControllerTest.java | 20 +-
.../v6_1/category/BindingControllerTest.java | 60 +++---
.../v6_1/category/BrokerControllerTest.java | 12 +-
.../v6_1/category/ConsumerControllerTest.java | 60 +++---
.../v6_1/category/DestinationControllerTest.java | 17 +-
.../v6_1/category/ExchangeControllerTest.java | 15 +-
.../category/LegacyCategoryControllerTest.java | 4 +-
.../v6_1/category/PortControllerTest.java | 6 +-
.../v6_1/category/QueueControllerTest.java | 15 +-
.../v6_1/category/SessionControllerTest.java | 11 +-
.../v6_1/category/VirtualHostControllerTest.java | 6 +-
.../v7_0/LegacyManagementControllerTest.java | 13 +-
.../LegacyCategoryController_v8_0Test.java | 11 +-
.../management/plugin/report/ReportRunnerTest.java | 20 +-
.../servlet/query/ConfiguredObjectQueryTest.java | 226 ++++++---------------
.../rest/ConfiguredObjectToMapConverterTest.java | 30 ++-
.../plugin/servlet/rest/RequestInfoParserTest.java | 25 ++-
.../rest/RestUserPreferenceHandlerTest.java | 195 ++++++++----------
58 files changed, 606 insertions(+), 925 deletions(-)
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
index 54bcc5aa77..8524458c25 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.management.plugin;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
@@ -249,22 +248,14 @@ public class HttpManagementUtil
{
if (pathInfo == null || pathInfo.length() == 0)
{
- return Collections.emptyList();
+ return List.of();
}
String[] pathInfoElements = pathInfo.substring(1).split("/");
for (int i = 0; i < pathInfoElements.length; i++)
{
- try
- {
- // double decode to allow slashes in object names. first decoding happens in request.getPathInfo().
- pathInfoElements[i] = URLDecoder.decode(pathInfoElements[i], StandardCharsets.UTF_8.name());
- }
- catch (UnsupportedEncodingException e)
- {
- throw new IllegalArgumentException("Servlet at " + servletPath
- + " could not decode path element: " + pathInfoElements[i], e);
- }
+ // double decode to allow slashes in object names. first decoding happens in request.getPathInfo().
+ pathInfoElements[i] = URLDecoder.decode(pathInfoElements[i], StandardCharsets.UTF_8);
}
return Arrays.asList(pathInfoElements);
}
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticator.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticator.java
index 9ac0335c9a..b292adbb6b 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticator.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticator.java
@@ -167,41 +167,37 @@ public class OAuth2InteractiveAuthenticator implements HttpRequestInteractiveAut
final NamedAddressSpace addressSpace = configuration.getPort(request).getAddressSpace(request.getServerName());
- return new AuthenticationHandler()
+ return response ->
{
- @Override
- public void handleAuthentication(final HttpServletResponse response) throws IOException
+ AuthenticationResult authenticationResult = oauth2Provider.authenticateViaAuthorizationCode(authorizationCode, redirectUri, addressSpace);
+ try
{
- AuthenticationResult authenticationResult = oauth2Provider.authenticateViaAuthorizationCode(authorizationCode, redirectUri, addressSpace);
- try
- {
- SubjectCreator subjectCreator = port.getSubjectCreator(request.isSecure(), request.getServerName());
- SubjectAuthenticationResult result = subjectCreator.createResultWithGroups(authenticationResult);
- Subject original = result.getSubject();
+ SubjectCreator subjectCreator = port.getSubjectCreator(request.isSecure(), request.getServerName());
+ SubjectAuthenticationResult result = subjectCreator.createResultWithGroups(authenticationResult);
+ Subject original = result.getSubject();
- if (original == null)
- {
- throw new SecurityException("Only authenticated users can access the management interface");
- }
+ if (original == null)
+ {
+ throw new SecurityException("Only authenticated users can access the management interface");
+ }
- Broker broker = (Broker) oauth2Provider.getParent();
- HttpManagementUtil.createServletConnectionSubjectAssertManagementAccessAndSave(broker, request, original);
+ Broker broker = (Broker) oauth2Provider.getParent();
+ HttpManagementUtil.createServletConnectionSubjectAssertManagementAccessAndSave(broker, request, original);
- LOGGER.debug("Successful login. Redirect to original resource {}", originalRequestUri);
- response.sendRedirect(originalRequestUri);
+ LOGGER.debug("Successful login. Redirect to original resource {}", originalRequestUri);
+ response.sendRedirect(originalRequestUri);
+ }
+ catch (SecurityException e)
+ {
+ if (e instanceof AccessControlException)
+ {
+ LOGGER.info("User '{}' is not authorised for management", authenticationResult.getMainPrincipal());
+ response.sendError(403, "User is not authorised for management");
}
- catch (SecurityException e)
+ else
{
- if (e instanceof AccessControlException)
- {
- LOGGER.info("User '{}' is not authorised for management", authenticationResult.getMainPrincipal());
- response.sendError(403, "User is not authorised for management");
- }
- else
- {
- LOGGER.info("Authentication failed", authenticationResult.getCause());
- response.sendError(401);
- }
+ LOGGER.info("Authentication failed", authenticationResult.getCause());
+ response.sendError(401);
}
}
};
@@ -225,14 +221,7 @@ public class OAuth2InteractiveAuthenticator implements HttpRequestInteractiveAut
if (oauth2Provider.getPostLogoutURI() != null)
{
final String postLogoutRedirect = oauth2Provider.getPostLogoutURI().toString();
- return new LogoutHandler()
- {
- @Override
- public void handleLogout(final HttpServletResponse response) throws IOException
- {
- response.sendRedirect(postLogoutRedirect);
- }
- };
+ return response -> response.sendRedirect(postLogoutRedirect);
}
}
return null;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/AbstractManagementController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/AbstractManagementController.java
index 1c80b6699e..8f48eb6252 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/AbstractManagementController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/AbstractManagementController.java
@@ -24,7 +24,6 @@ import static org.apache.qpid.server.management.plugin.controller.ConverterHelpe
import static org.apache.qpid.server.management.plugin.ManagementException.createBadRequestManagementException;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -164,7 +163,7 @@ public abstract class AbstractManagementController implements ManagementControll
"POST".equalsIgnoreCase(request.getMethod()));
int responseCode = HttpServletResponse.SC_OK;
ResponseType responseType = ResponseType.EMPTY;
- Map<String, String> headers = Collections.emptyMap();
+ Map<String, String> headers = Map.of();
if (response != null)
{
responseCode = HttpServletResponse.SC_CREATED;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryController.java
index 9e2c011416..b2c87bcdb2 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryController.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import org.apache.qpid.server.management.plugin.ManagementResponse;
-import org.apache.qpid.server.management.plugin.ManagementController;
import org.apache.qpid.server.management.plugin.ManagementException;
import org.apache.qpid.server.model.ConfiguredObject;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryControllerFactory.java
index 552b2cd668..8a22135f0d 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/CategoryControllerFactory.java
@@ -24,7 +24,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.apache.qpid.server.management.plugin.ManagementController;
import org.apache.qpid.server.plugin.Pluggable;
import org.apache.qpid.server.plugin.QpidServiceLoader;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ControllerManagementResponse.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ControllerManagementResponse.java
index 0d7772e4ae..aa63385c37 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ControllerManagementResponse.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ControllerManagementResponse.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.management.plugin.controller;
-import java.util.Collections;
import java.util.Map;
import jakarta.servlet.http.HttpServletResponse;
@@ -37,7 +36,7 @@ public class ControllerManagementResponse implements ManagementResponse
public ControllerManagementResponse(final ResponseType type, final Object body)
{
- this(type, body, HttpServletResponse.SC_OK, Collections.emptyMap());
+ this(type, body, HttpServletResponse.SC_OK, Map.of());
}
public ControllerManagementResponse(final ResponseType type,
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ConverterHelper.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ConverterHelper.java
index b4fc1807c1..575d07a294 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ConverterHelper.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/ConverterHelper.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import org.apache.qpid.server.management.plugin.HttpManagementUtil;
import org.apache.qpid.server.management.plugin.ManagementException;
public class ConverterHelper
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryController.java
index 8dafe29c82..c593c66c8e 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryController.java
@@ -24,7 +24,6 @@ import static org.apache.qpid.server.management.plugin.ManagementException.creat
import static org.apache.qpid.server.management.plugin.ManagementException.createInternalServerErrorManagementException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -151,7 +150,7 @@ public abstract class GenericCategoryController implements CategoryController
final boolean isSecure) throws ManagementException
{
- Object result = get(root, path, Collections.emptyMap());
+ Object result = get(root, path, Map.of());
if (result instanceof LegacyConfiguredObject)
{
final LegacyConfiguredObject legacyConfiguredObject = (LegacyConfiguredObject) result;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericLegacyConfiguredObject.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericLegacyConfiguredObject.java
index 678cef0a34..7a5a8f81ee 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericLegacyConfiguredObject.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/GenericLegacyConfiguredObject.java
@@ -21,9 +21,9 @@
package org.apache.qpid.server.management.plugin.controller;
import java.util.Collection;
-import java.util.Collections;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
import org.apache.qpid.server.management.plugin.ManagementResponse;
@@ -71,7 +71,7 @@ public class GenericLegacyConfiguredObject implements LegacyConfiguredObject
{
return children.stream().map(_managementController::convertFromNextVersion).collect(Collectors.toSet());
}
- return Collections.emptySet();
+ return Set.of();
}
@Override
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
index 528a594085..9f22bf1e97 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
@@ -33,8 +33,6 @@ import static org.apache.qpid.server.model.ConfiguredObjectTypeRegistry.returnsC
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -81,21 +79,19 @@ public class LatestManagementController extends AbstractManagementController
private static final String EXTRACT_INITIAL_CONFIG_PARAM = "extractInitialConfig";
private static final String EXCLUDE_INHERITED_CONTEXT_PARAM = "excludeInheritedContext";
private static final String SINGLETON_MODEL_OBJECT_RESPONSE_AS_LIST = "singletonModelObjectResponseAsList";
- private static final Set<String> RESERVED_PARAMS =
- new HashSet<>(Arrays.asList(DEPTH_PARAM,
- SORT_PARAM,
- OVERSIZE_PARAM,
- ACTUALS_PARAM,
- EXTRACT_INITIAL_CONFIG_PARAM,
- CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM,
- EXCLUDE_INHERITED_CONTEXT_PARAM,
- SINGLETON_MODEL_OBJECT_RESPONSE_AS_LIST));
+ private static final Set<String> RESERVED_PARAMS = Set.of(DEPTH_PARAM,
+ SORT_PARAM,
+ OVERSIZE_PARAM,
+ ACTUALS_PARAM,
+ EXTRACT_INITIAL_CONFIG_PARAM,
+ CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM,
+ EXCLUDE_INHERITED_CONTEXT_PARAM,
+ SINGLETON_MODEL_OBJECT_RESPONSE_AS_LIST);
private static final int DEFAULT_DEPTH = 0;
private static final int DEFAULT_OVERSIZE = 120;
private static final Class<? extends ConfiguredObject>[] EMPTY_HIERARCHY = new Class[0];
-
private final ConcurrentMap<ConfiguredObject<?>, ConfiguredObjectFinder> _configuredObjectFinders =
new ConcurrentHashMap<>();
private final Set<String> _supportedCategories;
@@ -111,11 +107,11 @@ public class LatestManagementController extends AbstractManagementController
_userPreferenceHandler = new RestUserPreferenceHandler(preferenceOperationTimeout == null
? DEFAULT_PREFERENCE_OPERATION_TIMEOUT
: preferenceOperationTimeout);
- _supportedCategories = Collections.unmodifiableSet(httpManagement.getModel()
- .getSupportedCategories()
- .stream()
- .map(Class::getSimpleName)
- .collect(Collectors.toSet()));
+ _supportedCategories = httpManagement.getModel()
+ .getSupportedCategories()
+ .stream()
+ .map(Class::getSimpleName)
+ .collect(Collectors.toUnmodifiableSet());
}
@Override
@@ -149,7 +145,7 @@ public class LatestManagementController extends AbstractManagementController
Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(category.toLowerCase());
if (hierarchy == null)
{
- return Collections.emptyList();
+ return List.of();
}
return Arrays.stream(hierarchy).map(Class::getSimpleName).collect(Collectors.toList());
}
@@ -559,7 +555,7 @@ public class LatestManagementController extends AbstractManagementController
oversizeThreshold,
isSecureOrAllowedOnInsecureChannel,
excludeInheritedContext);
- return responseAsList ? Collections.singletonList(object) : object;
+ return responseAsList ? List.of(object) : object;
}
else if (content instanceof Collection)
{
@@ -652,7 +648,7 @@ public class LatestManagementController extends AbstractManagementController
if (targetObjects == null)
{
- targetObjects = Collections.emptySet();
+ targetObjects = Set.of();
}
else if (filterPredicate != null)
{
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapter.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapter.java
index f0e65588bf..d25e4a6566 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapter.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapter.java
@@ -27,7 +27,6 @@ import static org.apache.qpid.server.model.ConfiguredObjectTypeRegistry.returnsC
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -368,9 +367,7 @@ public class LatestManagementControllerAdapter implements ManagementController
}
catch (RuntimeException e)
{
- throw ManagementException.toManagementException(e,
- getCategoryMapping(getCategory()),
- Collections.emptyList());
+ throw ManagementException.toManagementException(e, getCategoryMapping(getCategory()), List.of());
}
catch (Error e)
{
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerFactory.java
index d625b483e9..9b809fae03 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerFactory.java
@@ -23,8 +23,6 @@ package org.apache.qpid.server.management.plugin.controller.v6_1;
import org.apache.qpid.server.management.plugin.HttpManagementConfiguration;
import org.apache.qpid.server.management.plugin.ManagementController;
import org.apache.qpid.server.management.plugin.ManagementControllerFactory;
-import org.apache.qpid.server.management.plugin.controller.CategoryControllerFactory;
-import org.apache.qpid.server.management.plugin.controller.TypeControllerFactory;
import org.apache.qpid.server.plugin.PluggableService;
@PluggableService
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
index 922e0e1168..e113769578 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingController.java
@@ -26,7 +26,6 @@ import static org.apache.qpid.server.management.plugin.ManagementException.creat
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -277,7 +276,7 @@ public class BindingController implements CategoryController
return (LegacyConfiguredObject) _nextVersionManagementController.get(root,
type.toLowerCase(),
path,
- Collections.emptyMap());
+ Map.of());
}
@Override
@@ -287,7 +286,7 @@ public class BindingController implements CategoryController
Map<String, Object> parameters,
boolean isPost, final boolean isSecure) throws ManagementException
{
- Object result = get(root, path, Collections.emptyMap());
+ Object result = get(root, path, Map.of());
if (result instanceof Collection && ((Collection)result).size() == 1)
{
LegacyConfiguredObject object = (LegacyConfiguredObject) ((Collection<?>)result).iterator().next();
@@ -360,10 +359,7 @@ public class BindingController implements CategoryController
{
try
{
- return _nextVersionManagementController.get(root,
- ExchangeController.TYPE.toLowerCase(),
- exchangePath,
- Collections.emptyMap());
+ return _nextVersionManagementController.get(root, ExchangeController.TYPE.toLowerCase(), exchangePath, Map.of());
}
catch (ManagementException e)
{
@@ -371,17 +367,14 @@ public class BindingController implements CategoryController
{
throw e;
}
- return Collections.emptyList();
+ return List.of();
}
}
-
private Collection<LegacyConfiguredObject> getExchangeBindings(final LegacyConfiguredObject nextVersionExchange,
final String queueName,
final String bindingName)
{
-
- @SuppressWarnings("unchecked")
Object items = nextVersionExchange.getAttribute("bindings");
if (items instanceof Collection)
{
@@ -395,7 +388,7 @@ public class BindingController implements CategoryController
.map(b -> createManageableBinding(b, nextVersionExchange))
.collect(Collectors.toList());
}
- return Collections.emptyList();
+ return List.of();
}
private LegacyConfiguredObject createManageableBinding(final Binding binding,
@@ -437,9 +430,8 @@ public class BindingController implements CategoryController
private static final String QUEUE = "queue";
private static final String EXCHANGE = "exchange";
private static final Collection<String> ATTRIBUTE_NAMES =
- Collections.unmodifiableSet(Stream.concat(GenericLegacyConfiguredObject.AVAILABLE_ATTRIBUTES.stream(),
- Stream.of(ARGUMENTS, QUEUE, EXCHANGE))
- .collect(Collectors.toSet()));
+ Stream.concat(LegacyConfiguredObject.AVAILABLE_ATTRIBUTES.stream(), Stream.of(ARGUMENTS, QUEUE, EXCHANGE))
+ .collect(Collectors.toUnmodifiableSet());
private final String _bindingKey;
private final Map<String, Object> _arguments;
@@ -534,7 +526,7 @@ public class BindingController implements CategoryController
@Override
public Collection<LegacyConfiguredObject> getChildren(final String category)
{
- return Collections.emptyList();
+ return List.of();
}
@Override
@@ -550,7 +542,7 @@ public class BindingController implements CategoryController
{
if ("getStatistics".equals(operation))
{
- return new ControllerManagementResponse(ResponseType.DATA, Collections.emptyMap());
+ return new ControllerManagementResponse(ResponseType.DATA, Map.of());
}
throw createBadRequestManagementException("No operation is available for Binding");
}
@@ -605,7 +597,7 @@ public class BindingController implements CategoryController
@Override
public Map<String, Object> getStatistics()
{
- return Collections.emptyMap();
+ return Map.of();
}
}
}
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerController.java
index 9f215e76bb..1874f3f6e9 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerController.java
@@ -24,7 +24,6 @@ import static org.apache.qpid.server.management.plugin.ManagementException.creat
import static org.apache.qpid.server.management.plugin.ManagementException.createInternalServerErrorManagementException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -102,7 +101,7 @@ public class ConsumerController implements CategoryController
final Object queues = getNextVersionManagementController().get(root,
"Queue",
virtualHostPath,
- Collections.emptyMap());
+ Map.of());
Collection<LegacyConfiguredObject> consumers;
if (queues instanceof LegacyConfiguredObject)
@@ -149,7 +148,7 @@ public class ConsumerController implements CategoryController
Map<String, Object> parameters,
boolean isPost, final boolean isSecure) throws ManagementException
{
- Object result = get( root, path, Collections.emptyMap());
+ Object result = get( root, path, Map.of());
if (result instanceof Collection && ((Collection)result).size() == 1)
{
LegacyConfiguredObject object = (LegacyConfiguredObject) ((Collection<?>)result).iterator().next();
@@ -229,7 +228,7 @@ public class ConsumerController implements CategoryController
.collect(Collectors.toList());
}
}
- return Collections.emptyList();
+ return List.of();
}
static class LegacyConsumer extends GenericLegacyConfiguredObject
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationController.java
index df70c1b4de..d8cf479eb9 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationController.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.management.plugin.controller.v6_1.category;
import static org.apache.qpid.server.management.plugin.ManagementException.createBadRequestManagementException;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -75,8 +74,7 @@ public class DestinationController extends LegacyCategoryController
if (exchange != null)
{
converted.put(ALTERNATE_BINDING,
- Collections.singletonMap("destination",
- exchange.getAttribute(LegacyConfiguredObject.NAME)));
+ Map.of("destination", exchange.getAttribute(LegacyConfiguredObject.NAME)));
}
else
{
@@ -99,7 +97,7 @@ public class DestinationController extends LegacyCategoryController
final Object result = getNextVersionManagementController().get(root,
ExchangeController.TYPE,
exchangePath,
- Collections.emptyMap());
+ Map.of());
if (result instanceof Collection)
{
final Collection<?> exchanges = (Collection<?>) result;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeController.java
index c5a63a1e3a..595112c3fb 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeController.java
@@ -21,7 +21,7 @@
package org.apache.qpid.server.management.plugin.controller.v6_1.category;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -84,7 +84,7 @@ public class ExchangeController extends DestinationController
b.getArguments()))
.collect(Collectors.toList());
}
- return Collections.emptyList();
+ return List.of();
}
return super.getChildren(category);
}
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
index 5878851119..77e8f32d6c 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
@@ -20,10 +20,6 @@
*/
package org.apache.qpid.server.management.plugin.controller.v6_1.category;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -64,47 +60,40 @@ public class LegacyCategoryControllerFactory implements CategoryControllerFactor
static final String CATEGORY_CONNECTION = "Connection";
static final String CATEGORY_SESSION = SessionController.TYPE;
static final String CATEGORY_SYSTEM_CONFIG = "SystemConfig";
- static final Set<String> SUPPORTED_CATEGORIES =
- Collections.unmodifiableSet(new HashSet<>(Arrays.asList(CATEGORY_BROKER,
- CATEGORY_BROKER_LOGGER,
- CATEGORY_BROKER_LOG_INCLUSION_RULE,
- CATEGORY_AUTHENTICATION_PROVIDER,
- CATEGORY_USER,
- CATEGORY_ACCESS_CONTROL_PROVIDER,
- CATEGORY_PLUGIN,
- CATEGORY_TRUST_STORE,
- CATEGORY_KEY_STORE,
- CATEGORY_PORT,
- CATEGORY_VIRTUAL_HOST_ALIAS,
- CATEGORY_GROUP_PROVIDER,
- CATEGORY_GROUP,
- CATEGORY_GROUP_MEMBER,
- CATEGORY_VIRTUAL_HOST_NODE,
- CATEGORY_REMOTE_REPLICATION_NODE,
- CATEGORY_VIRTUAL_HOST,
- CATEGORY_VIRTUAL_HOST_LOGGER,
- CATEGORY_VIRTUAL_HOST_LOG_INCLUSION_RULE,
- CATEGORY_VIRTUAL_HOST_ACCESS_CONTROL_PROVIDER,
- CATEGORY_EXCHANGE,
- CATEGORY_QUEUE,
- CATEGORY_BINDING,
- CATEGORY_CONSUMER,
- CATEGORY_CONNECTION,
- CATEGORY_SESSION
- )));
+ static final Set<String> SUPPORTED_CATEGORIES = Set.of(CATEGORY_BROKER,
+ CATEGORY_BROKER_LOGGER,
+ CATEGORY_BROKER_LOG_INCLUSION_RULE,
+ CATEGORY_AUTHENTICATION_PROVIDER,
+ CATEGORY_USER,
+ CATEGORY_ACCESS_CONTROL_PROVIDER,
+ CATEGORY_PLUGIN,
+ CATEGORY_TRUST_STORE,
+ CATEGORY_KEY_STORE,
+ CATEGORY_PORT,
+ CATEGORY_VIRTUAL_HOST_ALIAS,
+ CATEGORY_GROUP_PROVIDER,
+ CATEGORY_GROUP,
+ CATEGORY_GROUP_MEMBER,
+ CATEGORY_VIRTUAL_HOST_NODE,
+ CATEGORY_REMOTE_REPLICATION_NODE,
+ CATEGORY_VIRTUAL_HOST,
+ CATEGORY_VIRTUAL_HOST_LOGGER,
+ CATEGORY_VIRTUAL_HOST_LOG_INCLUSION_RULE,
+ CATEGORY_VIRTUAL_HOST_ACCESS_CONTROL_PROVIDER,
+ CATEGORY_EXCHANGE,
+ CATEGORY_QUEUE,
+ CATEGORY_BINDING,
+ CATEGORY_CONSUMER,
+ CATEGORY_CONNECTION,
+ CATEGORY_SESSION);
- private static final Map<String, String> DEFAULT_TYPES = Collections.unmodifiableMap(new HashMap<String, String>()
- {
- {
- put(CATEGORY_BROKER_LOGGER, "Broker");
- put(CATEGORY_TRUST_STORE, "FileTrustStore");
- put(CATEGORY_KEY_STORE, "FileKeyStore");
- put(CATEGORY_GROUP, "ManagedGroup");
- put(CATEGORY_GROUP_MEMBER, "ManagedGroupMember");
- put(CATEGORY_VIRTUAL_HOST, "ProvidedStore");
- put(CATEGORY_QUEUE, "standard");
- }
- });
+ private static final Map<String, String> DEFAULT_TYPES = Map.of(CATEGORY_BROKER_LOGGER, "Broker",
+ CATEGORY_TRUST_STORE, "FileTrustStore",
+ CATEGORY_KEY_STORE, "FileKeyStore",
+ CATEGORY_GROUP, "ManagedGroup",
+ CATEGORY_GROUP_MEMBER, "ManagedGroupMember",
+ CATEGORY_VIRTUAL_HOST, "ProvidedStore",
+ CATEGORY_QUEUE, "standard");
@Override
public CategoryController createController(final String type,
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionController.java
index a279e7c56e..1bc1e7e53f 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionController.java
@@ -21,7 +21,7 @@
package org.apache.qpid.server.management.plugin.controller.v6_1.category;
import java.util.Collection;
-import java.util.Collections;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -68,7 +68,7 @@ public class SessionController extends LegacyCategoryController
{
final LegacyConfiguredObject nextVersionSession = getNextVersionLegacyConfiguredObject();
final ManagementResponse result =
- nextVersionSession.invoke("getConsumers", Collections.emptyMap(), true);
+ nextVersionSession.invoke("getConsumers", Map.of(), true);
if (result != null && result.getResponseCode() == 200 && result.getType() == ResponseType.MODEL_OBJECT)
{
final Object objects = result.getBody();
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerFactory.java
index 30d022df82..497788f53d 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerFactory.java
@@ -23,8 +23,6 @@ package org.apache.qpid.server.management.plugin.controller.v7_0;
import org.apache.qpid.server.management.plugin.HttpManagementConfiguration;
import org.apache.qpid.server.management.plugin.ManagementController;
import org.apache.qpid.server.management.plugin.ManagementControllerFactory;
-import org.apache.qpid.server.management.plugin.controller.CategoryControllerFactory;
-import org.apache.qpid.server.management.plugin.controller.TypeControllerFactory;
import org.apache.qpid.server.plugin.PluggableService;
@PluggableService
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryController.java
index deffdf819f..ea6251ed07 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryController.java
@@ -27,7 +27,6 @@ import org.apache.qpid.server.management.plugin.controller.GenericLegacyConfigur
import org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject;
import org.apache.qpid.server.management.plugin.controller.LegacyManagementController;
import org.apache.qpid.server.management.plugin.controller.TypeController;
-import org.apache.qpid.server.management.plugin.controller.latest.LatestManagementControllerAdapter;
public class LegacyCategoryController extends GenericCategoryController
{
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
index e413d26304..fa5799dbe0 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
@@ -61,7 +61,7 @@ public class LegacyCategoryControllerFactory implements CategoryControllerFactor
private static final String CATEGORY_SESSION = "Session";
static final String CATEGORY_SYSTEM_CONFIG = "SystemConfig";
public static final Map<String, String> SUPPORTED_CATEGORIES =
- Collections.unmodifiableMap(new HashMap<String, String>()
+ Collections.unmodifiableMap(new HashMap<>()
{
{
put(CATEGORY_BROKER_LOGGER, CATEGORY_BROKER);
@@ -92,18 +92,13 @@ public class LegacyCategoryControllerFactory implements CategoryControllerFactor
}
});
- public static final Map<String, String> DEFAULT_TYPES = Collections.unmodifiableMap(new HashMap<String, String>()
- {
- {
- put(CATEGORY_BROKER_LOGGER, "Broker");
- put(CATEGORY_TRUST_STORE, "FileTrustStore");
- put(CATEGORY_KEY_STORE, "FileKeyStore");
- put(CATEGORY_GROUP, "ManagedGroup");
- put(CATEGORY_GROUP_MEMBER, "ManagedGroupMember");
- put(CATEGORY_VIRTUAL_HOST, "ProvidedStore");
- put(CATEGORY_QUEUE, "standard");
- }
- });
+ public static final Map<String, String> DEFAULT_TYPES = Map.of(CATEGORY_BROKER_LOGGER, "Broker",
+ CATEGORY_TRUST_STORE, "FileTrustStore",
+ CATEGORY_KEY_STORE, "FileKeyStore",
+ CATEGORY_GROUP, "ManagedGroup",
+ CATEGORY_GROUP_MEMBER, "ManagedGroupMember",
+ CATEGORY_VIRTUAL_HOST, "ProvidedStore",
+ CATEGORY_QUEUE, "standard");
@Override
public CategoryController createController(final String type,
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/AuthenticationCheckFilter.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/AuthenticationCheckFilter.java
index 9172db4e53..a5dee1cb18 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/AuthenticationCheckFilter.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/AuthenticationCheckFilter.java
@@ -150,14 +150,10 @@ public class AuthenticationCheckFilter implements Filter
{
try
{
- Subject.doAs(subject, new PrivilegedExceptionAction<Void>()
+ Subject.doAs(subject, (PrivilegedExceptionAction<Void>) () ->
{
- @Override
- public Void run() throws IOException, ServletException
- {
- chain.doFilter(request, response);
- return null;
- }
+ chain.doFilter(request, response);
+ return null;
});
}
catch (PrivilegedActionException e)
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java
index 6ce96bf690..5fad1fd0e3 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java
@@ -21,7 +21,6 @@
package org.apache.qpid.server.management.plugin.report;
import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.VirtualHost;
/**
* <p>
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java
index 69113f99a6..53e2df2c68 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java
@@ -25,7 +25,6 @@ import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
import java.time.chrono.IsoChronology;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@@ -93,18 +92,14 @@ public class ConfiguredObjectExpressionFactory
@Override
ConfiguredObjectExpression asExpression(final List<Expression> args)
{
- return new ConfiguredObjectExpression()
+ return object ->
{
- @Override
- public Object evaluate(final ConfiguredObject<?> object)
+ StringBuilder buf = new StringBuilder();
+ for(Expression expr : args)
{
- StringBuilder buf = new StringBuilder();
- for(Expression expr : args)
- {
- buf.append(expr.evaluate(object));
- }
- return buf.toString();
+ buf.append(expr.evaluate(object));
}
+ return buf.toString();
};
}
},
@@ -117,14 +112,7 @@ public class ConfiguredObjectExpressionFactory
{
throw new IllegalArgumentException(NOW.name() + " does not accept arguments.");
}
- return new ConfiguredObjectExpression()
- {
- @Override
- public Object evaluate(final ConfiguredObject<?> object)
- {
- return new Date();
- }
- };
+ return object -> new Date();
}
},
@@ -186,32 +174,28 @@ public class ConfiguredObjectExpressionFactory
throw new IllegalArgumentException(DATE_ADD.name() + " requires two arguments.");
}
- return new ConfiguredObjectExpression()
+ return object ->
{
- @Override
- public Object evaluate(final ConfiguredObject<?> object)
+ Object date = args.get(0).evaluate(object);
+ Object period = args.get(1).evaluate(object);
+ if (!(date instanceof Date) || !(period instanceof String))
{
- Object date = args.get(0).evaluate(object);
- Object period = args.get(1).evaluate(object);
- if (!(date instanceof Date) || !(period instanceof String))
- {
- throw new IllegalArgumentException(String.format("%s requires a (Date, String) not a"
- + " (%s,%s)",
- DATE_ADD,
- date.getClass().getSimpleName(),
- period.getClass().getSimpleName()));
- }
- try
- {
- Date copy = new Date(((Date) date).getTime());
- final Duration duration = DATATYPE_FACTORY.newDuration((String) period);
- duration.addTo(copy);
- return copy;
- }
- catch (IllegalArgumentException e)
- {
- throw new IllegalArgumentException(DATE_ADD + " requires an ISO-8601 format duration.", e);
- }
+ throw new IllegalArgumentException(String.format("%s requires a (Date, String) not a"
+ + " (%s,%s)",
+ DATE_ADD,
+ date.getClass().getSimpleName(),
+ period.getClass().getSimpleName()));
+ }
+ try
+ {
+ Date copy = new Date(((Date) date).getTime());
+ final Duration duration = DATATYPE_FACTORY.newDuration((String) period);
+ duration.addTo(copy);
+ return copy;
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new IllegalArgumentException(DATE_ADD + " requires an ISO-8601 format duration.", e);
}
};
}
@@ -226,39 +210,35 @@ public class ConfiguredObjectExpressionFactory
throw new IllegalArgumentException(TO_STRING.name() + " requires (Object[,{printf format specifier},[{timezone name}]]).");
}
- return new ConfiguredObjectExpression()
+ return object ->
{
- @Override
- public Object evaluate(final ConfiguredObject<?> object)
+ Object obj = args.get(0).evaluate(object);
+ Object format = args.size() > 1 ? args.get(1).evaluate(object) : null;
+ Object timezoneName = args.size() > 2 ? args.get(2).evaluate(object) : null;
+ if (obj instanceof Date)
+ {
+ final Calendar cal = timezoneName == null ? Calendar.getInstance(UTC) : Calendar.getInstance(TimeZone.getTimeZone(
+ (String) timezoneName));
+ cal.setTime((Date) obj);
+ if (format == null)
+ {
+ return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(cal.toInstant().atZone(ZoneId.of(timezoneName == null ? "UTC" : (String)timezoneName)));
+ }
+ else
+ {
+ return String.format((String)format, cal);
+ }
+ }
+ else
{
- Object obj = args.get(0).evaluate(object);
- Object format = args.size() > 1 ? args.get(1).evaluate(object) : null;
- Object timezoneName = args.size() > 2 ? args.get(2).evaluate(object) : null;
- if (obj instanceof Date)
+ // TODO If obj itself is another configured object perhaps we should just use its name or id? The CO.toString value probably isn't too useful.
+ if (format == null)
{
- final Calendar cal = timezoneName == null ? Calendar.getInstance(UTC) : Calendar.getInstance(TimeZone.getTimeZone(
- (String) timezoneName));
- cal.setTime((Date) obj);
- if (format == null)
- {
- return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(cal.toInstant().atZone(ZoneId.of(timezoneName == null ? "UTC" : (String)timezoneName)));
- }
- else
- {
- return String.format((String)format, cal);
- }
+ return String.valueOf(obj);
}
else
{
- // TODO If obj itself is another configured object perhaps we should just use its name or id? The CO.toString value probably isn't too useful.
- if (format == null)
- {
- return String.valueOf(obj);
- }
- else
- {
- return String.format((String)format, obj);
- }
+ return String.format((String)format, obj);
}
}
};
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
index f736b3ce8d..d90c7244aa 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/AbstractServlet.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -353,7 +352,7 @@ public abstract class AbstractServlet extends HttpServlet
private Map<String, Object> getResponseHeaders(final Object content)
{
- Map<String, Object> headers = Collections.emptyMap();
+ Map<String, Object> headers = Map.of();
if (content instanceof CustomRestHeaders)
{
CustomRestHeaders customRestHeaders = (CustomRestHeaders) content;
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
index 135dae638f..afec0d20d5 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
-import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.Named;
public class ConfiguredObjectToMapConverter
@@ -216,7 +215,7 @@ public class ConfiguredObjectToMapConverter
final ConfiguredObject<?> confObject, Map<String, Object> object)
{
- Map<String, Object> statMap = new TreeMap<String,Object>(confObject.getStatistics());
+ Map<String, Object> statMap = new TreeMap<>(confObject.getStatistics());
if(!statMap.isEmpty())
{
@@ -233,14 +232,7 @@ public class ConfiguredObjectToMapConverter
{
List<Class<? extends ConfiguredObject>> childTypes = new ArrayList<>(confObject.getModel().getChildTypes(clazz));
- Collections.sort(childTypes, new Comparator<Class<? extends ConfiguredObject>>()
- {
- @Override
- public int compare(final Class<? extends ConfiguredObject> o1, final Class<? extends ConfiguredObject> o2)
- {
- return o1.getSimpleName().compareTo(o2.getSimpleName());
- }
- });
+ childTypes.sort(Comparator.comparing(Class::getSimpleName));
ConverterOptions childConverterOptions = new ConverterOptions(converterOptions, converterOptions.getDepth() - 1);
for(Class<? extends ConfiguredObject> childClass : childTypes)
@@ -255,14 +247,7 @@ public class ConfiguredObjectToMapConverter
}
else
{
- Collections.sort(sortedChildren, new Comparator<ConfiguredObject>()
- {
- @Override
- public int compare(final ConfiguredObject o1, final ConfiguredObject o2)
- {
- return o1.getName().compareTo(o2.getName());
- }
- });
+ sortedChildren.sort(Comparator.comparing((ConfiguredObject o) -> o.getName()));
}
List<Map<String, Object>> childObjects = new ArrayList<>();
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java
index cd14abc582..355b60a72c 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java
@@ -20,7 +20,6 @@ package org.apache.qpid.server.management.plugin.servlet.rest;/*
*/
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -44,7 +43,7 @@ public class PluginClassProviderAction implements Action
String className = (String) request.get("plugin");
QpidServiceLoader serviceLoader = new QpidServiceLoader();
final Class<Pluggable> clazz = (Class<Pluggable>) Class.forName("org.apache.qpid.server.plugin."+className);
- List<String> values = new ArrayList<String>();
+ List<String> values = new ArrayList<>();
for(Pluggable instance : serviceLoader.instancesOf(clazz))
{
values.add(instance.getType());
@@ -53,8 +52,7 @@ public class PluginClassProviderAction implements Action
}
catch (ClassNotFoundException e)
{
- return Collections.emptyList();
+ return List.of();
}
-
}
}
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfo.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfo.java
index cc67cd7a19..1e4060569a 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfo.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfo.java
@@ -19,7 +19,6 @@
package org.apache.qpid.server.management.plugin.servlet.rest;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -42,20 +41,18 @@ public class RequestInfo
Map<String, List<String>> queryParameters,
final boolean hierarchySatisfied)
{
- return new RequestInfo(RequestType.MODEL_OBJECT, modelParts, null, Collections.<String>emptyList(), queryParameters, hierarchySatisfied );
+ return new RequestInfo(RequestType.MODEL_OBJECT, modelParts, null, List.of(), queryParameters, hierarchySatisfied );
}
public static RequestInfo createOperationRequestInfo(final List<String> modelParts, final String operationName, Map<String, List<String>> queryParameters)
{
- return new RequestInfo(RequestType.OPERATION, modelParts, operationName, Collections.<String>emptyList(), queryParameters,
+ return new RequestInfo(RequestType.OPERATION, modelParts, operationName, List.of(), queryParameters,
true);
}
public static RequestInfo createPreferencesRequestInfo(final List<String> modelParts, final List<String> preferencesParts)
{
- return new RequestInfo(RequestType.USER_PREFERENCES, modelParts, null, preferencesParts, Collections.<String,
- List<String>>emptyMap(),
- true);
+ return new RequestInfo(RequestType.USER_PREFERENCES, modelParts, null, preferencesParts, Map.of(), true);
}
public static RequestInfo createPreferencesRequestInfo(final List<String> modelParts, final List<String> preferencesParts, Map<String, List<String>> queryParameters)
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParser.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParser.java
index bcbc7cf81d..1f254d3d72 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParser.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParser.java
@@ -249,7 +249,7 @@ public class RequestInfoParser
}
if (!query.containsKey(key))
{
- query.put(key, new ArrayList<String>());
+ query.put(key, new ArrayList<>());
}
query.get(key).add(value);
}
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
index af6847c217..21bc766a6e 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.management.plugin.servlet.rest;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -304,7 +303,7 @@ public class RestServlet extends AbstractServlet
{
if (Strings.isNullOrEmpty(queryString))
{
- return Collections.emptyMap();
+ return Map.of();
}
Map<String, List<String>> query = new LinkedHashMap<>();
final String[] pairs = queryString.split("&");
@@ -322,15 +321,8 @@ public class RestServlet extends AbstractServlet
String key;
String value;
- try
- {
- key = URLDecoder.decode(pair.get(0), "UTF-8");
- value = pair.get(1) == null ? null : URLDecoder.decode(pair.get(1), "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e);
- }
+ key = URLDecoder.decode(pair.get(0), StandardCharsets.UTF_8);
+ value = pair.get(1) == null ? null : URLDecoder.decode(pair.get(1), StandardCharsets.UTF_8);
if (!query.containsKey(key))
{
query.put(key, new ArrayList<>());
@@ -395,7 +387,7 @@ public class RestServlet extends AbstractServlet
public Map<String, List<String>> getParameters()
{
- return Collections.unmodifiableMap(_query);
+ return _query;
}
@Override
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
index 50c506ccb3..0295a5e726 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
@@ -278,7 +278,7 @@ public class RestUserPreferenceHandler
final String type = preference.getType();
if (!preferences.containsKey(type))
{
- preferences.put(type, new ArrayList<Map<String, Object>>());
+ preferences.put(type, new ArrayList<>());
}
preferences.get(type).add(preference.getAttributes());
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
index 6ccc39fc6c..5cca8a6f8e 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
@@ -88,7 +88,7 @@ public class SaslServlet extends AbstractServlet
final AuthenticationProvider<?> authenticationProvider = getAuthenticationProvider(request);
final List<String> mechanismsList = authenticationProvider.getAvailableMechanisms(request.isSecure());
final String[] mechanisms = mechanismsList.toArray(new String[mechanismsList.size()]);
- final Map<String, Object> outputObject = new LinkedHashMap<String, Object>();
+ final Map<String, Object> outputObject = new LinkedHashMap<>();
final Subject subject = Subject.getSubject(AccessController.getContext());
final Principal principal = AuthenticatedPrincipal.getOptionalAuthenticatedPrincipalFromSubject(subject);
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/TimeZoneServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/TimeZoneServlet.java
index 5fc2583ece..6bf91d6d00 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/TimeZoneServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/TimeZoneServlet.java
@@ -54,7 +54,7 @@ public class TimeZoneServlet extends AbstractServlet
public List<TimeZoneDetails> getTimeZones()
{
- List<TimeZoneDetails> timeZoneDetails = new ArrayList<TimeZoneDetails>();
+ List<TimeZoneDetails> timeZoneDetails = new ArrayList<>();
String[] ids = TimeZone.getAvailableIDs();
long currentTime = System.currentTimeMillis();
Date currentDate = new Date(currentTime);
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/VirtualHostQueryServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/VirtualHostQueryServlet.java
index 8fb27f5e5a..593b0f2485 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/VirtualHostQueryServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/VirtualHostQueryServlet.java
@@ -183,7 +183,7 @@ public class VirtualHostQueryServlet extends QueryServlet<VirtualHost<?>>
private List<ConfiguredObject<?>> getObjects(final List<Class<? extends ConfiguredObject>> hierarchy,
Collection<ConfiguredObject<?>> parents)
{
- Collection<ConfiguredObject<?>> children = Collections.emptyList();
+ Collection<ConfiguredObject<?>> children = List.of();
for(Class<? extends ConfiguredObject> childClass : hierarchy)
{
children = new HashSet<>();
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporter.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporter.java
index fd39cd641f..96ee814a8e 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporter.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/session/LoginLogoutReporter.java
@@ -72,14 +72,10 @@ public class LoginLogoutReporter implements HttpSessionBindingListener
{
LOGGER.debug("User logging in : {}", _principal);
- Subject.doAs(_subject, new PrivilegedAction<Void>()
+ Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
- @Override
- public Void run()
- {
- getEventLogger().message(ManagementConsoleMessages.OPEN(_principal.getName()));
- return null;
- }
+ getEventLogger().message(ManagementConsoleMessages.OPEN(_principal.getName()));
+ return null;
});
}
@@ -87,14 +83,10 @@ public class LoginLogoutReporter implements HttpSessionBindingListener
{
LOGGER.debug("User logging out : {}", _principal);
- Subject.doAs(_subject, new PrivilegedAction<Void>()
+ Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
- @Override
- public Void run()
- {
- getEventLogger().message(ManagementConsoleMessages.CLOSE(_principal.getName()));
- return null;
- }
+ getEventLogger().message(ManagementConsoleMessages.CLOSE(_principal.getName()));
+ return null;
});
}
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
index 1324a76e99..15012b36be 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2InteractiveAuthenticatorTest.java
@@ -117,7 +117,7 @@ public class OAuth2InteractiveAuthenticatorTest extends UnitTestBase
{
Map<String, Object> sessionAttributes = new HashMap<>();
HttpServletRequest mockRequest = createMockRequest(TEST_REQUEST_HOST, TEST_REQUEST_PATH,
- Collections.singletonMap("baz", "fnord"), sessionAttributes);
+ Map.of("baz", "fnord"), sessionAttributes);
HttpRequestInteractiveAuthenticator.AuthenticationHandler authenticationHandler = _authenticator.getAuthenticationHandler(mockRequest,
_mockConfiguration);
@@ -310,17 +310,17 @@ public class OAuth2InteractiveAuthenticatorTest extends UnitTestBase
SubjectAuthenticationResult mockSuccessfulSubjectAuthenticationResult = mock(SubjectAuthenticationResult.class);
SubjectAuthenticationResult mockUnauthorizedSubjectAuthenticationResult = mock(SubjectAuthenticationResult.class);
final Subject successfulSubject = new Subject(true,
- Collections.singleton(new AuthenticatedPrincipal(new UsernamePrincipal(
+ Set.of(new AuthenticatedPrincipal(new UsernamePrincipal(
TEST_AUTHORIZED_USER,
null))),
- Collections.emptySet(),
- Collections.emptySet());
+ Set.of(),
+ Set.of());
final Subject unauthorizedSubject = new Subject(true,
- Collections.singleton(new AuthenticatedPrincipal(new UsernamePrincipal(
+ Set.of(new AuthenticatedPrincipal(new UsernamePrincipal(
TEST_UNAUTHORIZED_USER,
null))),
- Collections.emptySet(),
- Collections.emptySet());
+ Set.of(),
+ Set.of());
AuthenticationResult mockSuccessfulAuthenticationResult = mock(AuthenticationResult.class);
AuthenticationResult mockUnauthorizedAuthenticationResult = mock(AuthenticationResult.class);
AuthenticationResult failedAuthenticationResult = new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
index 2a871dd4e0..3a80ea8492 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/auth/OAuth2PreemptiveAuthenticatorTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.Principal;
-import java.util.Collections;
import java.util.Set;
import javax.security.auth.Subject;
@@ -132,17 +131,17 @@ public class OAuth2PreemptiveAuthenticatorTest extends UnitTestBase
SubjectAuthenticationResult mockSuccessfulSubjectAuthenticationResult = mock(SubjectAuthenticationResult.class);
SubjectAuthenticationResult mockUnauthorizedSubjectAuthenticationResult = mock(SubjectAuthenticationResult.class);
final Subject successfulSubject = new Subject(true,
- Collections.singleton(new AuthenticatedPrincipal(new UsernamePrincipal(
+ Set.of(new AuthenticatedPrincipal(new UsernamePrincipal(
TEST_AUTHORIZED_USER,
null))),
- Collections.emptySet(),
- Collections.emptySet());
+ Set.of(),
+ Set.of());
final Subject unauthorizedSubject = new Subject(true,
- Collections.singleton(new AuthenticatedPrincipal(new UsernamePrincipal(
+ Set.of(new AuthenticatedPrincipal(new UsernamePrincipal(
TEST_UNAUTHORIZED_USER,
null))),
- Collections.emptySet(),
- Collections.emptySet());
+ Set.of(),
+ Set.of());
AuthenticationResult mockSuccessfulAuthenticationResult = mock(AuthenticationResult.class);
AuthenticationResult mockUnauthorizedAuthenticationResult = mock(AuthenticationResult.class);
AuthenticationResult failedAuthenticationResult = new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryControllerTest.java
index 3cf4805473..8433013468 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/GenericCategoryControllerTest.java
@@ -29,10 +29,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -66,7 +65,7 @@ public class GenericCategoryControllerTest extends UnitTestBase
_nextVersionManagementController,
TEST_CATEGORY,
DEFAULT_TYPE,
- Collections.singleton(_typeController))
+ Set.of(_typeController))
{
@Override
protected LegacyConfiguredObject convertNextVersionLegacyConfiguredObject(final LegacyConfiguredObject object)
@@ -104,9 +103,8 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void get()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("testParam", Collections.singletonList("testValue"));
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, List<String>> parameters = Map.of("testParam", List.of("testValue"));
final LegacyConfiguredObject result = mock(LegacyConfiguredObject.class);
when(result.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn(DEFAULT_TYPE);
final LegacyConfiguredObject convertedResult = mock(LegacyConfiguredObject.class);
@@ -120,8 +118,8 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void createOrUpdate()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, Object> attributes = Collections.singletonMap("test", "testValue");
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, Object> attributes = Map.of("test", "testValue");
final LegacyConfiguredObject result = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject convertedResult = mock(LegacyConfiguredObject.class);
when(result.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn(DEFAULT_TYPE);
@@ -139,9 +137,8 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void delete()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("testParam", Collections.singletonList("testValue"));
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, List<String>> parameters = Map.of("testParam", List.of("testValue"));
final int result = 1;
when(_nextVersionManagementController.delete(_root, TEST_CATEGORY, path, parameters)).thenReturn(result);
@@ -153,9 +150,9 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void invoke()
{
- final List<String> path = Arrays.asList("test1", "test2");
+ final List<String> path = List.of("test1", "test2");
final String operationName = "testOperation";
- final Map<String, Object> operationParameters = Collections.singletonMap("testParam", "testValue");
+ final Map<String, Object> operationParameters = Map.of("testParam", "testValue");
final LegacyConfiguredObject result = mock(LegacyConfiguredObject.class);
when(result.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn(DEFAULT_TYPE);
@@ -163,7 +160,7 @@ public class GenericCategoryControllerTest extends UnitTestBase
when(_nextVersionManagementController.get(eq(_root),
eq(TEST_CATEGORY),
eq(path),
- eq(Collections.emptyMap()))).thenReturn(result);
+ eq(Map.of()))).thenReturn(result);
when(_typeController.convertFromNextVersion(result)).thenReturn(convertedResult);
@@ -175,16 +172,15 @@ public class GenericCategoryControllerTest extends UnitTestBase
assertThat(response, is(notNullValue()));
assertThat(response.getResponseCode(), is(equalTo(200)));
assertThat(response.getBody(), is(equalTo(operationValue)));
- verify(_nextVersionManagementController).get(_root, TEST_CATEGORY, path, Collections.emptyMap());
+ verify(_nextVersionManagementController).get(_root, TEST_CATEGORY, path, Map.of());
verify(convertedResult).invoke(operationName, operationParameters, true);
}
@Test
public void getPreferences()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("testParam", Collections.singletonList("testValue"));
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, List<String>> parameters = Map.of("testParam", List.of("testValue"));
final Object result = mock(Object.class);
when(_nextVersionManagementController.getPreferences(_root,
@@ -200,9 +196,8 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void setPreferences()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("testParam", Collections.singletonList("testValue"));
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, List<String>> parameters = Map.of("testParam", List.of("testValue"));
final Object preferences = mock(Object.class);
_controller.setPreferences(_root, path, preferences, parameters, true);
@@ -218,9 +213,8 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void deletePreferences()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("testParam", Collections.singletonList("testValue"));
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, List<String>> parameters = Map.of("testParam", List.of("testValue"));
_controller.deletePreferences(_root, path, parameters);
@@ -236,9 +230,9 @@ public class GenericCategoryControllerTest extends UnitTestBase
@Test
public void convertAttributesToNextVersion()
{
- final List<String> path = Arrays.asList("test1", "test2");
- final Map<String, Object> attributes = Collections.singletonMap("testParam", "testValue");
- final Map<String, Object> convertedAttributes = Collections.singletonMap("testParam", "testValue2");
+ final List<String> path = List.of("test1", "test2");
+ final Map<String, Object> attributes = Map.of("testParam", "testValue");
+ final Map<String, Object> convertedAttributes = Map.of("testParam", "testValue2");
when(_typeController.convertAttributesToNextVersion(_root, path, attributes)).thenReturn(convertedAttributes);
final Map<String, Object> converted = _controller.convertAttributesToNextVersion(_root, path, attributes);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapterTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapterTest.java
index d650972fa0..c582b96a17 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapterTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerAdapterTest.java
@@ -30,9 +30,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -107,7 +105,7 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
public void getCategoryHierarchy()
{
final Broker<?> object = BrokerTestHelper.createBrokerMock();
- final Collection<String> expected = Arrays.asList("VirtualHostNode", "VirtualHost", "Queue");
+ final Collection<String> expected = List.of("VirtualHostNode", "VirtualHost", "Queue");
assertThat(_adapter.getCategoryHierarchy(object, "Queue"), is(equalTo(expected)));
}
@@ -118,15 +116,14 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
- virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
final String nodeName = virtualHost.getParent().getName();
final ManagementRequest request = mockManagementRequest(virtualHost.getBroker(),
"GET",
"queue",
- Arrays.asList(nodeName, hostName),
- Collections.singletonMap("name",
- Collections.singletonList("foo")));
+ List.of(nodeName, hostName),
+ Map.of("name", List.of("foo")));
final ManagementResponse response = _adapter.handleGet(request);
assertThat(response, is(notNullValue()));
@@ -155,9 +152,9 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final Broker root = virtualHost.getBroker();
final ManagementRequest request =
- mockManagementRequest(root, "PUT", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
+ mockManagementRequest(root, "PUT", "queue", List.of(nodeName, hostName), Map.of());
- when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap(
+ when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Map.of(
"name",
queueName)));
when(request.getRequestURL()).thenReturn("test");
@@ -183,11 +180,9 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final Broker root = virtualHost.getBroker();
final ManagementRequest request =
- mockManagementRequest(root, "POST", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
+ mockManagementRequest(root, "POST", "queue", List.of(nodeName, hostName), Map.of());
- when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap(
- "name",
- queueName)));
+ when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Map.of("name", queueName)));
when(request.getRequestURL()).thenReturn("test");
final ManagementResponse response = _adapter.handlePut(request);
@@ -207,16 +202,15 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
- virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
assertThat(virtualHost.getQueueCount(), is(equalTo(1L)));
final String nodeName = virtualHost.getParent().getName();
final ManagementRequest request = mockManagementRequest(virtualHost.getBroker(),
"DELETE",
"queue",
- Arrays.asList(nodeName, hostName),
- Collections.singletonMap("name",
- Collections.singletonList("foo")));
+ List.of(nodeName, hostName),
+ Map.of("name", List.of("foo")));
final ManagementResponse response = _adapter.handleDelete(request);
assertThat(response, is(notNullValue()));
assertThat(response.getResponseCode(), is(equalTo(200)));
@@ -230,13 +224,12 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
- virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
final String nodeName = virtualHost.getParent().getName();
- final Object response = _adapter.get(virtualHost.getBroker(), "queue", Arrays.asList(nodeName, hostName),
- Collections.singletonMap("name",
- Collections.singletonList("foo")));
+ final Object response = _adapter.get(virtualHost.getBroker(), "queue", List.of(nodeName, hostName),
+ Map.of("name", List.of("foo")));
assertThat(response, is(instanceOf(Collection.class)));
final Collection data = (Collection) response;
@@ -259,17 +252,15 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final Broker root = virtualHost.getBroker();
final ManagementRequest request =
- mockManagementRequest(root, "POST", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
+ mockManagementRequest(root, "POST", "queue", List.of(nodeName, hostName), Map.of());
- when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap(
- "name",
- queueName)));
+ when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Map.of("name", queueName)));
when(request.getRequestURL()).thenReturn("test");
final Object response = _adapter.createOrUpdate(virtualHost.getBroker(),
"queue",
- Arrays.asList(nodeName, hostName),
- Collections.singletonMap("name", queueName),
+ List.of(nodeName, hostName),
+ Map.of("name", queueName),
true);
assertThat(response, is(instanceOf(LegacyConfiguredObject.class)));
@@ -284,15 +275,12 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
- virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
assertThat(virtualHost.getQueueCount(), is(equalTo(1L)));
final String nodeName = virtualHost.getParent().getName();
- _adapter.delete(virtualHost.getBroker(),
- "queue",
- Arrays.asList(nodeName, hostName, queueName),
- Collections.emptyMap());
+ _adapter.delete(virtualHost.getBroker(), "queue", List.of(nodeName, hostName, queueName), Map.of());
assertThat(virtualHost.getQueueCount(), is(equalTo(0L)));
}
@@ -304,10 +292,10 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String queueName = "foo";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
- Queue queue = virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ Queue queue = virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
assertThat(virtualHost.getQueueCount(), is(equalTo(1L)));
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName);
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName);
Map<String, Object> message = new HashMap<>();
message.put("address", "foo");
@@ -318,7 +306,7 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
"virtualhost",
path,
"publishMessage",
- Collections.singletonMap("message", message),
+ Map.of("message", message),
true,
true);
@@ -336,14 +324,10 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
final String queueName = "foo";
- virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
+ virtualHost.createChild(Queue.class, Map.of(Queue.NAME, queueName));
assertThat(virtualHost.getQueueCount(), is(equalTo(1L)));
- final Object formatted = _adapter.formatConfiguredObject(virtualHost,
- Collections.singletonMap("depth",
- Collections.singletonList(
- "1")),
- true);
+ final Object formatted = _adapter.formatConfiguredObject(virtualHost, Map.of("depth",List.of("1")), true);
assertThat(formatted, is(notNullValue()));
assertThat(formatted, is(instanceOf(Map.class)));
@@ -372,8 +356,8 @@ public class LatestManagementControllerAdapterTest extends UnitTestBase
final QueueManagingVirtualHost<?> virtualHost = BrokerTestHelper.createVirtualHost(hostName, this);
final Broker root = virtualHost.getBroker();
final ConfiguredObject<?> virtualHostNode = virtualHost.getParent();
- when(root.getChildren(VirtualHostNode.class)).thenReturn(Collections.singletonList(virtualHostNode));
- when(virtualHostNode.getChildren(VirtualHost.class)).thenReturn(Collections.singletonList(virtualHost));
+ when(root.getChildren(VirtualHostNode.class)).thenReturn(List.of(virtualHostNode));
+ when(virtualHostNode.getChildren(VirtualHost.class)).thenReturn(List.of(virtualHost));
when(virtualHostNode.getChildByName(VirtualHost.class, hostName)).thenReturn(virtualHost);
return virtualHost;
}
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerTest.java
index e45e3a4bb0..469967ce57 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementControllerTest.java
@@ -33,14 +33,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.PrivilegedAction;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -121,7 +120,7 @@ public class LatestManagementControllerTest extends UnitTestBase
public void getCategoryHierarchyForBrokerRootAndQueueCategory()
{
final Broker<?> object = BrokerTestHelper.createBrokerMock();
- final Collection<String> expected = Arrays.asList("VirtualHostNode", "VirtualHost", "Queue");
+ final Collection<String> expected = List.of("VirtualHostNode", "VirtualHost", "Queue");
assertThat(_controller.getCategoryHierarchy(object, "Queue"), is(equalTo(expected)));
}
@@ -129,7 +128,7 @@ public class LatestManagementControllerTest extends UnitTestBase
public void getCategoryHierarchyForVirtualHostRootAndExchangeCategory() throws Exception
{
final QueueManagingVirtualHost<?> object = BrokerTestHelper.createVirtualHost("test", this);
- final Collection<String> expected = Collections.singletonList("Exchange");
+ final Collection<String> expected = List.of("Exchange");
assertThat(_controller.getCategoryHierarchy(object, "Exchange"), is(equalTo(expected)));
}
@@ -138,7 +137,7 @@ public class LatestManagementControllerTest extends UnitTestBase
public void getCategoryHierarchyForBrokerRootAndUnknownCategory()
{
final Broker<?> object = BrokerTestHelper.createBrokerMock();
- final Collection<String> expected = Collections.emptyList();
+ final Collection<String> expected = List.of();
assertThat(_controller.getCategoryHierarchy(object, "Binding"), is(equalTo(expected)));
}
@@ -157,8 +156,8 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- when(request.getPath()).thenReturn(Arrays.asList("*", hostName));
- when(request.getParameters()).thenReturn(Collections.emptyMap());
+ when(request.getPath()).thenReturn(List.of("*", hostName));
+ when(request.getParameters()).thenReturn(Map.of());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
@@ -175,9 +174,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar");
when(request.getPath()).thenReturn(path);
- when(request.getParameters()).thenReturn(Collections.emptyMap());
+ when(request.getParameters()).thenReturn(Map.of());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
@@ -194,12 +193,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- List<String> path = Arrays.asList(virtualHost.getParent().getName(),
- hostName,
- "bar",
- "userpreferences");
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar", "userpreferences");
when(request.getPath()).thenReturn(path);
- when(request.getParameters()).thenReturn(Collections.emptyMap());
+ when(request.getParameters()).thenReturn(Map.of());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
@@ -216,9 +212,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar", "visiblepreferences");
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar", "visiblepreferences");
when(request.getPath()).thenReturn(path);
- when(request.getParameters()).thenReturn(Collections.emptyMap());
+ when(request.getParameters()).thenReturn(Map.of());
when(request.getMethod()).thenReturn("GET");
final RequestType type = _controller.getRequestType(request);
@@ -232,9 +228,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
final String nodeName = virtualHost.getParent().getName();
- final List<String> path = Arrays.asList(nodeName, hostName, "foo");
+ final List<String> path = List.of(nodeName, hostName, "foo");
- final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Collections.emptyMap());
+ final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Map.of());
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(Queue.class)));
@@ -248,9 +244,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
final String nodeName = virtualHost.getParent().getName();
- final List<String> path = Arrays.asList(nodeName, hostName);
+ final List<String> path = List.of(nodeName, hostName);
- final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Collections.emptyMap());
+ final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Map.of());
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(Collection.class)));
@@ -272,9 +268,9 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- final List<String> path = Arrays.asList("*", hostName);
+ final List<String> path = List.of("*", hostName);
- final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Collections.emptyMap());
+ final Object object = _controller.get(virtualHost.getBroker(), "queue", path, Map.of());
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(Collection.class)));
@@ -297,12 +293,12 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar", "bar2");
- final List<String> path = Arrays.asList("*", hostName);
+ final List<String> path = List.of("*", hostName);
final Object object = _controller.get(virtualHost.getBroker(),
"queue",
path,
- Collections.singletonMap(Queue.NAME, Arrays.asList("foo", "bar")));
+ Map.of(Queue.NAME, List.of("foo", "bar")));
assertThat(object, is(notNullValue()));
assertThat(object, is(instanceOf(Collection.class)));
@@ -325,12 +321,12 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar");
final Object object = _controller.createOrUpdate(virtualHost.getBroker(),
"queue",
path,
- new HashMap<>(Collections.singletonMap(Queue.NAME, "bar")),
+ new HashMap<>(Map.of(Queue.NAME, "bar")),
false);
assertThat(object, is(notNullValue()));
@@ -343,14 +339,14 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar");
try
{
_controller.createOrUpdate(virtualHost.getBroker(),
"queue",
path,
- new HashMap<>(Collections.singletonMap(Queue.NAME, "bar")),
+ Map.of(Queue.NAME, "bar"),
true);
fail("Post update should fail for non existing");
}
@@ -365,12 +361,12 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "bar");
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar");
final Object object = _controller.createOrUpdate(virtualHost.getBroker(),
"queue",
path,
- new HashMap<>(Collections.singletonMap(Queue.NAME, "bar")),
+ Map.of(Queue.NAME, "bar"),
true);
assertThat(object, is(nullValue()));
@@ -381,12 +377,12 @@ public class LatestManagementControllerTest extends UnitTestBase
{
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName);
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName);
final Object object = _controller.createOrUpdate(virtualHost.getBroker(),
"queue",
path,
- new HashMap<>(Collections.singletonMap(Queue.NAME, "bar")),
+ Map.of(Queue.NAME, "bar"),
true);
assertThat(object, is(notNullValue()));
@@ -400,9 +396,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "bar");
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName, "bar");
- int count = _controller.delete(virtualHost.getBroker(), "queue", path, Collections.emptyMap());
+ int count = _controller.delete(virtualHost.getBroker(), "queue", path, Map.of());
assertThat(count, is(equalTo(1)));
}
@@ -413,12 +409,12 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName);
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName);
int count = _controller.delete(virtualHost.getBroker(),
"queue",
path,
- Collections.singletonMap(Queue.NAME, Arrays.asList("foo", "bar", "bar2")));
+ Map.of(Queue.NAME, List.of("foo", "bar", "bar2")));
assertThat(count, is(equalTo(2)));
}
@@ -429,9 +425,9 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "*");
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName, "*");
- int count = _controller.delete(virtualHost.getBroker(), "queue", path, Collections.emptyMap());
+ int count = _controller.delete(virtualHost.getBroker(), "queue", path, Map.of());
assertThat(count, is(equalTo(2)));
}
@@ -442,7 +438,7 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName);
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName);
Map<String, Object> message = new HashMap<>();
message.put("address", "foo");
@@ -453,7 +449,7 @@ public class LatestManagementControllerTest extends UnitTestBase
"virtualhost",
path,
"publishMessage",
- Collections.singletonMap("message", message),
+ Map.of("message", message),
true,
true);
@@ -470,14 +466,14 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "default";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
final String preferencesType = "X-type-preference";
- final Map<String, Object> preferenceValue = Collections.singletonMap("foo", "bar");
+ final Map<String, Object> preferenceValue = Map.of("foo", "bar");
final Subject testSubject = createTestSubject();
final String prefernceName = "test";
createPreferences(testSubject, virtualHost, preferencesType, prefernceName, preferenceValue);
- List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "userpreferences");
+ List<String> path = List.of(virtualHost.getParent().getName(), hostName, "userpreferences");
final Object preferences = Subject.doAs(testSubject, (PrivilegedAction<Object>) () ->
- _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path, Collections.emptyMap()));
+ _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path, Map.of()));
assertPreference(preferencesType, prefernceName, preferenceValue, preferences);
}
@@ -489,29 +485,28 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "default";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
final String preferencesType = "X-type";
- final Map<String, Object> preferenceValue = Collections.singletonMap("foo", "bar");
+ final Map<String, Object> preferenceValue = Map.of("foo", "bar");
final Subject testSubject = createTestSubject();
final String preferenceName = "pref";
final UUID id = createPreferences(testSubject, virtualHost, preferencesType, preferenceName, preferenceValue);
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(), hostName, "userpreferences");
- final Map<String, Object> newValue = Collections.singletonMap("foo", "bar2");
+ final List<String> path = List.of(virtualHost.getParent().getName(), hostName, "userpreferences");
+ final Map<String, Object> newValue = Map.of("foo", "bar2");
final Map<String, Object> data = new HashMap<>();
data.put("id", id.toString());
data.put("name", preferenceName);
data.put("value", newValue);
- final Map<String, List<Object>> modifiedPreferences = Collections.singletonMap(preferencesType,
- Collections.singletonList(data));
+ final Map<String, List<Object>> modifiedPreferences = Map.of(preferencesType, List.of(data));
Subject.doAs(testSubject, (PrivilegedAction<Void>) () -> {
_controller.setPreferences(virtualHost.getBroker(),
"virtualhost",
path,
modifiedPreferences,
- Collections.emptyMap(),
+ Map.of(),
true);
return null;
});
final Object preferences = Subject.doAs(testSubject, (PrivilegedAction<Object>) () ->
- _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path, Collections.emptyMap()));
+ _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path, Map.of()));
assertPreference(preferencesType, preferenceName, newValue, preferences);
}
@@ -522,12 +517,12 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName);
final String preferencesType = "X-type";
- final Map<String, Object> preferenceValue = Collections.singletonMap("foo", "bar");
+ final Map<String, Object> preferenceValue = Map.of("foo", "bar");
final Subject testSubject = createTestSubject();
final String preferenceName = "pref";
createPreferences(testSubject, virtualHost, preferencesType, preferenceName, preferenceValue);
- final List<String> path = Arrays.asList(virtualHost.getParent().getName(),
+ final List<String> path = List.of(virtualHost.getParent().getName(),
hostName,
"userpreferences",
preferencesType,
@@ -537,14 +532,14 @@ public class LatestManagementControllerTest extends UnitTestBase
_controller.deletePreferences(virtualHost.getBroker(),
"virtualhost",
path,
- Collections.emptyMap());
+ Map.of());
return null;
});
- final List<String> path2 = Arrays.asList(virtualHost.getParent().getName(), hostName, "userpreferences");
+ final List<String> path2 = List.of(virtualHost.getParent().getName(), hostName, "userpreferences");
final Object preferences = Subject.doAs(testSubject, (PrivilegedAction<Object>) () ->
- _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path2, Collections.emptyMap()));
+ _controller.getPreferences(virtualHost.getBroker(), "virtualhost", path2, Map.of()));
assertThat(preferences, is(notNullValue()));
assertThat(preferences, is(instanceOf(Map.class)));
@@ -558,11 +553,7 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- final Object formatted = _controller.formatConfiguredObject(virtualHost,
- Collections.singletonMap("depth",
- Collections.singletonList(
- "1")),
- true);
+ final Object formatted = _controller.formatConfiguredObject(virtualHost, Map.of("depth", List.of("1")), true);
assertThat(formatted, is(notNullValue()));
assertThat(formatted, is(instanceOf(Map.class)));
@@ -595,11 +586,7 @@ public class LatestManagementControllerTest extends UnitTestBase
final String hostName = "test";
final QueueManagingVirtualHost<?> virtualHost = createVirtualHostWithQueue(hostName, "foo", "bar");
- final Object formatted = _controller.formatConfiguredObject(Collections.singletonList(virtualHost),
- Collections.singletonMap("depth",
- Collections.singletonList(
- "1")),
- true);
+ final Object formatted = _controller.formatConfiguredObject(List.of(virtualHost), Map.of("depth", List.of("1")), true);
assertThat(formatted, is(notNullValue()));
assertThat(formatted, is(instanceOf(Collection.class)));
@@ -642,7 +629,7 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- when(request.getPath()).thenReturn(Arrays.asList(nodeName, hostName, "foo"));
+ when(request.getPath()).thenReturn(List.of(nodeName, hostName, "foo"));
when(request.getMethod()).thenReturn("GET");
final ManagementResponse response = _controller.handleGet(request);
@@ -666,8 +653,8 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- when(request.getPath()).thenReturn(Arrays.asList(nodeName, hostName));
- when(request.getParameters()).thenReturn(Collections.emptyMap());
+ when(request.getPath()).thenReturn(List.of(nodeName, hostName));
+ when(request.getParameters()).thenReturn(Map.of());
when(request.getMethod()).thenReturn("GET");
final ManagementResponse response = _controller.handleGet(request);
@@ -701,8 +688,8 @@ public class LatestManagementControllerTest extends UnitTestBase
final ManagementRequest request = mock(ManagementRequest.class);
when(request.getCategory()).thenReturn("queue");
doReturn(virtualHost.getBroker()).when(request).getRoot();
- when(request.getPath()).thenReturn(Arrays.asList(nodeName, hostName));
- when(request.getParameters()).thenReturn(Collections.singletonMap("name", Collections.singletonList("bar")));
+ when(request.getPath()).thenReturn(List.of(nodeName, hostName));
+ when(request.getParameters()).thenReturn(Map.of("name", List.of("bar")));
when(request.getMethod()).thenReturn("GET");
ManagementResponse response = _controller.handleGet(request);
@@ -726,11 +713,11 @@ public class LatestManagementControllerTest extends UnitTestBase
final QueueManagingVirtualHost<?> virtualHost = BrokerTestHelper.createVirtualHost(hostName, this);
final Broker root = virtualHost.getBroker();
final ConfiguredObject<?> virtualHostNode = virtualHost.getParent();
- when(root.getChildren(VirtualHostNode.class)).thenReturn(Collections.singletonList(virtualHostNode));
- when(virtualHostNode.getChildren(VirtualHost.class)).thenReturn(Collections.singletonList(virtualHost));
+ when(root.getChildren(VirtualHostNode.class)).thenReturn(List.of(virtualHostNode));
+ when(virtualHostNode.getChildren(VirtualHost.class)).thenReturn(List.of(virtualHost));
when(virtualHostNode.getChildByName(VirtualHost.class, hostName)).thenReturn(virtualHost);
Stream.of(queueName)
- .forEach(n -> virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, n)));
+ .forEach(n -> virtualHost.createChild(Queue.class, Map.of(Queue.NAME, n)));
return virtualHost;
}
@@ -754,7 +741,7 @@ public class LatestManagementControllerTest extends UnitTestBase
null,
new GenericPreferenceValueFactory().createInstance(
preferenceValue));
- final List<Preference> preferenceList = Collections.singletonList(preference);
+ final List<Preference> preferenceList = List.of(preference);
final Future<Void> result = Subject.doAs(testSubject,
(PrivilegedAction<Future<Void>>) () -> virtualHost.getUserPreferences()
.updateOrAppend(
@@ -771,9 +758,9 @@ public class LatestManagementControllerTest extends UnitTestBase
when(provider.getName()).thenReturn("name");
return new Subject(false,
- Collections.singleton(new AuthenticatedPrincipal(new UsernamePrincipal("user", provider))),
- Collections.emptySet(),
- Collections.emptySet());
+ Set.of(new AuthenticatedPrincipal(new UsernamePrincipal("user", provider))),
+ Set.of(),
+ Set.of());
}
private void assertPreference(final String expectedType,
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerTest.java
index b8862fc7ba..15f64a4b50 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/LegacyManagementControllerTest.java
@@ -30,9 +30,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -61,10 +59,10 @@ public class LegacyManagementControllerTest extends UnitTestBase
@Test
public void convertQueryParameters()
{
- final Map<String, List<String>> parameters = Collections.singletonMap("actuals", Collections.singletonList("true"));
+ final Map<String, List<String>> parameters = Map.of("actuals", List.of("true"));
final Map<String, List<String>> converted = _controller.convertQueryParameters(parameters);
assertThat(converted, is(notNullValue()));
- assertThat(converted.get("excludeInheritedContext"), is(equalTo(Collections.singletonList("true"))));
+ assertThat(converted.get("excludeInheritedContext"), is(equalTo(List.of("true"))));
}
@Test
@@ -72,17 +70,15 @@ public class LegacyManagementControllerTest extends UnitTestBase
{
final String objectName = "test-object";
final String hostName = "test-vhn";
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final Map<String, List<String>> parameters = Map.of();
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject vhn = mock(LegacyConfiguredObject.class);
- when(object.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME,
- LegacyConfiguredObject.TYPE));
+ when(object.getAttributeNames()).thenReturn(List.of(LegacyConfiguredObject.NAME, LegacyConfiguredObject.TYPE));
when(object.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(objectName);
when(object.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("Broker");
when(object.getCategory()).thenReturn("Broker");
- when(object.getChildren("VirtualHostNode")).thenReturn(Collections.singletonList(vhn));
- when(vhn.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME,
- LegacyConfiguredObject.TYPE));
+ when(object.getChildren("VirtualHostNode")).thenReturn(List.of(vhn));
+ when(vhn.getAttributeNames()).thenReturn(List.of(LegacyConfiguredObject.NAME, LegacyConfiguredObject.TYPE));
when(vhn.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(hostName);
when(vhn.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("VirtualHostNode");
when(vhn.getCategory()).thenReturn("VirtualHostNode");
@@ -113,9 +109,9 @@ public class LegacyManagementControllerTest extends UnitTestBase
@Test
public void get()
{
- final List<String> path = Collections.emptyList();
+ final List<String> path = List.of();
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final Map<String, List<String>> parameters = Map.of();
final ConfiguredObject<?> root = mock(ConfiguredObject.class);
when(_nextVersionManagementController.get(eq(root), eq(BrokerController.TYPE), eq(path), any())).thenReturn(object);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingControllerTest.java
index e2c7fe93fc..30a28900e7 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BindingControllerTest.java
@@ -33,12 +33,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -103,11 +102,10 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void get()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("actuals", Collections.singletonList("true"));
+ final List<String> path = List.of("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
+ final Map<String, List<String>> parameters = Map.of("actuals", List.of("true"));
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
when(_managementController.getCategoryHierarchy(_root, "Binding")).thenReturn(hierarchy);
final LegacyConfiguredObject exchange1 = mock(LegacyConfiguredObject.class);
@@ -121,15 +119,15 @@ public class BindingControllerTest extends UnitTestBase
when(exchange2.getParent("VirtualHost")).thenReturn(vh);
final LegacyConfiguredObject queue = mock(LegacyConfiguredObject.class);
when(queue.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("my-queue");
- final Collection<LegacyConfiguredObject> queues = Collections.singletonList(queue);
+ final Collection<LegacyConfiguredObject> queues = List.of(queue);
when(vh.getChildren("Queue")).thenReturn(queues);
final Binding binding = mock(Binding.class);
when(binding.getName()).thenReturn("my-binding");
when(binding.getDestination()).thenReturn("my-queue");
when(binding.getBindingKey()).thenReturn("my-binding");
- final Collection<Binding> bindings = Collections.singletonList(binding);
+ final Collection<Binding> bindings = List.of(binding);
when(exchange2.getAttribute("bindings")).thenReturn(bindings);
- final Collection<LegacyConfiguredObject> exchanges = Arrays.asList(exchange1, exchange2);
+ final Collection<LegacyConfiguredObject> exchanges = List.of(exchange1, exchange2);
doReturn(exchanges).when(_nextVersionManagementController).get(any(), eq("exchange"), any(), any());
@@ -149,12 +147,12 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void createOrUpdate()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-exchange");
+ final List<String> path = List.of("my-vhn", "my-vh", "my-exchange");
final Map<String, Object> attributes = new HashMap<>();
attributes.put("name", "my-binding");
attributes.put("queue", "my-queue");
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
doReturn(hierarchy).when(_managementController).getCategoryHierarchy(_root, "Binding");
final LegacyConfiguredObject exchange = mock(LegacyConfiguredObject.class);
@@ -193,9 +191,9 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void delete()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
+ final List<String> path = List.of("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
doReturn(hierarchy).when(_managementController).getCategoryHierarchy(_root, "Binding");
@@ -208,7 +206,7 @@ public class BindingControllerTest extends UnitTestBase
doReturn(exchange).when(_nextVersionManagementController).get(any(), eq("exchange"), any(), any());
- int result = _controller.delete(_root, path, Collections.emptyMap());
+ int result = _controller.delete(_root, path, Map.of());
assertThat(result, is(equalTo(1)));
verify(exchange).invoke(eq("unbind"), any(), eq(true));
@@ -217,13 +215,13 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void invoke()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
+ final List<String> path = List.of("my-vhn", "my-vh", "my-exchange", "my-queue", "my-binding");
final String operationName = "getStatistics";
- final Map<String, Object> parameters = Collections.emptyMap();
+ final Map<String, Object> parameters = Map.of();
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "exchange", "queue", "binding");
when(_managementController.getCategoryHierarchy(_root, "Binding")).thenReturn(hierarchy);
@@ -234,15 +232,15 @@ public class BindingControllerTest extends UnitTestBase
when(exchange.getParent("VirtualHost")).thenReturn(vh);
final LegacyConfiguredObject queue = mock(LegacyConfiguredObject.class);
when(queue.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("my-queue");
- final Collection<LegacyConfiguredObject> queues = Collections.singletonList(queue);
+ final Collection<LegacyConfiguredObject> queues = List.of(queue);
when(vh.getChildren("Queue")).thenReturn(queues);
final Binding binding = mock(Binding.class);
when(binding.getName()).thenReturn("my-binding");
when(binding.getDestination()).thenReturn("my-queue");
when(binding.getBindingKey()).thenReturn("my-binding");
- final Collection<Binding> bindings = Collections.singletonList(binding);
+ final Collection<Binding> bindings = List.of(binding);
when(exchange.getAttribute("bindings")).thenReturn(bindings);
- final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(exchange);
+ final Collection<LegacyConfiguredObject> exchanges = List.of(exchange);
doReturn(exchanges).when(_nextVersionManagementController).get(any(), eq("exchange"), any(), any());
@@ -251,14 +249,14 @@ public class BindingControllerTest extends UnitTestBase
assertThat(result, is(notNullValue()));
assertThat(result.getResponseCode(), is(equalTo(200)));
assertThat(result.getBody(), is(notNullValue()));
- assertThat(result.getBody(), is(equalTo(Collections.emptyMap())));
+ assertThat(result.getBody(), is(equalTo(Map.of())));
}
@Test
public void getPreferences()
{
- final List<String> path = Arrays.asList("vhn", "vh", "exchange", "queue", "binding");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("vhn", "vh", "exchange", "queue", "binding");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.getPreferences(_root, path, parameters);
@@ -273,15 +271,13 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void setPreferences()
{
- final List<String> path = Arrays.asList("vhn", "vh", "exchange", "queue", "binding");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("vhn", "vh", "exchange", "queue", "binding");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.setPreferences(_root,
path,
- Collections.singletonMap("Binding-Preferences",
- Collections.singleton(Collections.singletonMap("value",
- "foo"))),
+ Map.of("Binding-Preferences", Set.of(Map.of("value", "foo"))),
parameters,
true);
fail("Binding preferences are unknown");
@@ -295,13 +291,11 @@ public class BindingControllerTest extends UnitTestBase
@Test
public void deletePreferences()
{
- final List<String> path = Arrays.asList("vhn", "vh", "exchange", "queue", "binding");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("vhn", "vh", "exchange", "queue", "binding");
+ final Map<String, List<String>> parameters = Map.of();
try
{
- _controller.deletePreferences(_root,
- path,
- parameters);
+ _controller.deletePreferences(_root, path, parameters);
fail("Binding preferences are unknown");
}
catch (ManagementException e)
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerControllerTest.java
index 0d79f221e5..8b16ae9293 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerControllerTest.java
@@ -26,9 +26,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -62,7 +63,7 @@ public class BrokerControllerTest extends UnitTestBase
when(object.getAttribute("context")).thenReturn(context);
final BrokerController controller =
- new BrokerController(_legacyVersionManagementController, Collections.emptySet());
+ new BrokerController(_legacyVersionManagementController, Set.of());
assertThat(controller.getCategory(), is(equalTo("Broker")));
final LegacyConfiguredObject converted = controller.convertFromNextVersion(object);
@@ -84,12 +85,11 @@ public class BrokerControllerTest extends UnitTestBase
attributes.put("statisticsReportingEnabled", true);
final BrokerController controller =
- new BrokerController(_legacyVersionManagementController, Collections.emptySet());
+ new BrokerController(_legacyVersionManagementController, Set.of());
assertThat(controller.getCategory(), is(equalTo("Broker")));
- final Map<String, Object> converted = controller.convertAttributesToNextVersion(mock(ConfiguredObject.class),
- Collections.emptyList(),
- attributes);
+ final Map<String, Object> converted =
+ controller.convertAttributesToNextVersion(mock(ConfiguredObject.class), List.of(), attributes);
assertThat(converted.size(), is(equalTo(2)));
assertThat(converted.get("statisticsReportingEnabled"), is(equalTo(true)));
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerControllerTest.java
index e63223843e..fd63c690ef 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ConsumerControllerTest.java
@@ -31,11 +31,10 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -98,11 +97,10 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void get()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-session", "my-queue", "my-consumer");
- final Map<String, List<String>> parameters =
- Collections.singletonMap("actuals", Collections.singletonList("true"));
+ final List<String> path = List.of("my-vhn", "my-vh", "my-session", "my-queue", "my-consumer");
+ final Map<String, List<String>> parameters = Map.of("actuals", List.of("true"));
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "session", "queue", "consumer");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "session", "queue", "consumer");
when(_managementController.getCategoryHierarchy(_root, "Consumer")).thenReturn(hierarchy);
final LegacyConfiguredObject session = mock(LegacyConfiguredObject.class);
@@ -112,7 +110,7 @@ public class ConsumerControllerTest extends UnitTestBase
final LegacyConfiguredObject consumer = mock(LegacyConfiguredObject.class);
when(consumer.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("my-consumer");
when(consumer.getAttribute("session")).thenReturn(session);
- final Collection<LegacyConfiguredObject> consumers = Collections.singletonList(consumer);
+ final Collection<LegacyConfiguredObject> consumers = List.of(consumer);
final LegacyConfiguredObject queue1 = mock(LegacyConfiguredObject.class);
when(queue1.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("my-queue1");
@@ -120,13 +118,13 @@ public class ConsumerControllerTest extends UnitTestBase
when(queue2.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("my-queue");
when(queue2.getChildren(ConsumerController.TYPE)).thenReturn(consumers);
- final Collection<LegacyConfiguredObject> queues = Arrays.asList(queue1, queue2);
+ final Collection<LegacyConfiguredObject> queues = List.of(queue1, queue2);
doReturn(queues).when(_nextVersionManagementController)
.get(eq(_root),
eq("Queue"),
- eq(Arrays.asList("my-vhn", "my-vh")),
- eq(Collections.emptyMap()));
+ eq(List.of("my-vhn", "my-vh")),
+ eq(Map.of()));
final Object result = _controller.get(_root, path, parameters);
assertThat(result, is(instanceOf(Collection.class)));
@@ -145,8 +143,8 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void delete()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-queue", "my-consumer");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("my-vhn", "my-vh", "my-queue", "my-consumer");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.delete(_root, path, parameters);
@@ -161,8 +159,8 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void createOrUpdate()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-queue", "my-consumer");
- final Map<String, Object> attributes = Collections.singletonMap(LegacyConfiguredObject.NAME, "my-consumer" );
+ final List<String> path = List.of("my-vhn", "my-vh", "my-queue", "my-consumer");
+ final Map<String, Object> attributes = Map.of(LegacyConfiguredObject.NAME, "my-consumer" );
try
{
_controller.createOrUpdate(_root, path, attributes, true);
@@ -177,8 +175,8 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void invoke()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-session", "my-queue", "my-consumer");
- final List<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "session", "queue", "consumer");
+ final List<String> path = List.of("my-vhn", "my-vh", "my-session", "my-queue", "my-consumer");
+ final List<String> hierarchy = List.of("virtualhostnode", "virtualhost", "session", "queue", "consumer");
when(_managementController.getCategoryHierarchy(_root, "Consumer")).thenReturn(hierarchy);
final LegacyConfiguredObject consumer = mock(LegacyConfiguredObject.class);
@@ -191,19 +189,19 @@ public class ConsumerControllerTest extends UnitTestBase
final Object stats = mock(Object.class);
final ManagementResponse statistics = new ControllerManagementResponse(ResponseType.DATA, stats);
- when(consumer.invoke(eq("getStatistics"), eq(Collections.emptyMap()), eq(false))).thenReturn(statistics);
- final Collection<LegacyConfiguredObject> consumers = Collections.singletonList(consumer);
+ when(consumer.invoke(eq("getStatistics"), eq(Map.of()), eq(false))).thenReturn(statistics);
+ final Collection<LegacyConfiguredObject> consumers = List.of(consumer);
when(queue.getChildren(ConsumerController.TYPE)).thenReturn(consumers);
- final Collection<LegacyConfiguredObject> queues = Collections.singletonList(queue);
+ final Collection<LegacyConfiguredObject> queues = List.of(queue);
doReturn(queues).when(_nextVersionManagementController)
.get(eq(_root),
eq("Queue"),
- eq(Arrays.asList("my-vhn", "my-vh")),
- eq(Collections.emptyMap()));
+ eq(List.of("my-vhn", "my-vh")),
+ eq(Map.of()));
- ManagementResponse response = _controller.invoke(_root, path, "getStatistics", Collections.emptyMap(), false, false);
+ ManagementResponse response = _controller.invoke(_root, path, "getStatistics", Map.of(), false, false);
assertThat(response, is(notNullValue()));
assertThat(response.getResponseCode(), is(equalTo(200)));
assertThat(response.getBody(), is(notNullValue()));
@@ -213,8 +211,8 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void getPreferences()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-queue", "my-consumer");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("my-vhn", "my-vh", "my-queue", "my-consumer");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.getPreferences(_root, path, parameters);
@@ -229,15 +227,13 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void setPreferences()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-queue", "my-consumer");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("my-vhn", "my-vh", "my-queue", "my-consumer");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.setPreferences(_root,
path,
- Collections.singletonMap("Consumer-Preferences",
- Collections.singleton(Collections.singletonMap("value",
- "foo"))),
+ Map.of("Consumer-Preferences", Set.of(Map.of("value", "foo"))),
parameters,
true);
fail("Consumer preferences are unknown");
@@ -251,8 +247,8 @@ public class ConsumerControllerTest extends UnitTestBase
@Test
public void deletePreferences()
{
- final List<String> path = Arrays.asList("my-vhn", "my-vh", "my-queue", "my-consumer");
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("my-vhn", "my-vh", "my-queue", "my-consumer");
+ final Map<String, List<String>> parameters = Map.of();
try
{
_controller.deletePreferences(_root,
@@ -287,7 +283,7 @@ public class ConsumerControllerTest extends UnitTestBase
when(nextVersionConfiguredObject.getAttribute("queue")).thenReturn(queue2);
when(nextVersionConfiguredObject.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("test-consumer");
when(nextVersionConfiguredObject.getParent(eq("Queue"))).thenReturn(queue2);
- final Collection<LegacyConfiguredObject> consumers = Collections.singletonList(nextVersionConfiguredObject);
+ final Collection<LegacyConfiguredObject> consumers = List.of(nextVersionConfiguredObject);
when(queue2.getChildren(ConsumerController.TYPE)).thenReturn(consumers);
final LegacyConfiguredObject convertedSession = mock(LegacyConfiguredObject.class);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationControllerTest.java
index 588a733b83..3fc6738af1 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/DestinationControllerTest.java
@@ -29,12 +29,11 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -74,24 +73,24 @@ public class DestinationControllerTest extends UnitTestBase
"Queue",
new String[]{"VirtualHost"},
null,
- Collections.emptySet());
+ Set.of());
assertThat(controller.getCategory(), is(equalTo("Queue")));
assertThat(controller.getParentCategories(), is(equalTo(new String[]{"VirtualHost"})));
final ConfiguredObject root = mock(ConfiguredObject.class);
- final List<String> exchangePath = Arrays.asList("vhn", "vh");
+ final List<String> exchangePath = List.of("vhn", "vh");
final LegacyConfiguredObject exchange = mock(LegacyConfiguredObject.class);
when(exchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
when(exchange.getCategory()).thenReturn(ExchangeController.TYPE);
- final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(exchange);
+ final Collection<LegacyConfiguredObject> exchanges = List.of(exchange);
when(_nextVersionManagementController.get(eq(root),
eq(ExchangeController.TYPE),
eq(exchangePath),
- eq(Collections.emptyMap()))).thenReturn(exchanges);
+ eq(Map.of()))).thenReturn(exchanges);
- final Collection<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange");
+ final Collection<String> hierarchy = List.of("virtualhostnode", "virtualhost", "exchange");
when(_nextVersionManagementController.getCategoryHierarchy(eq(root), eq(ExchangeController.TYPE))).thenReturn(hierarchy);
- final List<String> path = Arrays.asList("vhn", "vh", queueName);
+ final List<String> path = List.of("vhn", "vh", queueName);
final Map<String, Object> converted = controller.convertAttributesToNextVersion(root,
path,
attributes);
@@ -120,7 +119,7 @@ public class DestinationControllerTest extends UnitTestBase
final LegacyConfiguredObject alternateExchange = mock(LegacyConfiguredObject.class);
when(alternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(alternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
- final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(alternateExchange);
+ final Collection<LegacyConfiguredObject> exchanges = List.of(alternateExchange);
when(vh.getChildren(ExchangeController.TYPE)).thenReturn(exchanges);
final LegacyConfiguredObject converted = mock(LegacyConfiguredObject.class);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeControllerTest.java
index 068e57a2d3..f6c9101607 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/ExchangeControllerTest.java
@@ -26,9 +26,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -57,8 +57,7 @@ public class ExchangeControllerTest extends UnitTestBase
@Test
public void convertNextVersionLegacyConfiguredObject()
{
- final ExchangeController exchangeController =
- new ExchangeController(_legacyManagementController, Collections.emptySet());
+ final ExchangeController exchangeController = new ExchangeController(_legacyManagementController, Set.of());
final String exchangeName = "testExchange";
final String alternateExchangeName = "altExchange";
@@ -77,7 +76,7 @@ public class ExchangeControllerTest extends UnitTestBase
when(nextVersionExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionExchange.getAttribute("alternateBinding")).thenReturn(alternateBinding);
when(nextVersionExchange.getAttribute(AbstractConfiguredObject.NAME)).thenReturn(exchangeName);
- when(nextVersionExchange.getAttribute("bindings")).thenReturn(Collections.singletonList(nextVersionBinding));
+ when(nextVersionExchange.getAttribute("bindings")).thenReturn(List.of(nextVersionBinding));
when(nextVersionExchange.getParent(VirtualHostController.TYPE)).thenReturn(nextVersionVirtualHost);
when(nextVersionBinding.getDestination()).thenReturn(queueName);
@@ -86,9 +85,9 @@ public class ExchangeControllerTest extends UnitTestBase
when(nextVersionAlternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionAlternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
- when(nextVersionVirtualHost.getChildren(ExchangeController.TYPE)).thenReturn(Arrays.asList(nextVersionExchange,
- nextVersionAlternateExchange));
- when(nextVersionVirtualHost.getChildren(QueueController.TYPE)).thenReturn(Collections.singletonList(queue));
+ when(nextVersionVirtualHost.getChildren(ExchangeController.TYPE))
+ .thenReturn(List.of(nextVersionExchange, nextVersionAlternateExchange));
+ when(nextVersionVirtualHost.getChildren(QueueController.TYPE)).thenReturn(List.of(queue));
final LegacyConfiguredObject convertedExchange = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject convertedAltExchange = mock(LegacyConfiguredObject.class);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerTest.java
index 58bd0cd394..f9eb607612 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerTest.java
@@ -27,7 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Collections;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -53,7 +53,7 @@ public class LegacyCategoryControllerTest extends UnitTestBase
VirtualHostNode.TYPE,
new String[]{BrokerController.TYPE},
null,
- Collections.emptySet());
+ Set.of());
}
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/PortControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/PortControllerTest.java
index 385105dd17..48f6927af9 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/PortControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/PortControllerTest.java
@@ -28,10 +28,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -53,7 +53,7 @@ public class PortControllerTest extends UnitTestBase
final ManagementController nextVersionManagementController = mock(ManagementController.class);
when(legacyManagementController.getNextVersionManagementController()).thenReturn(
nextVersionManagementController);
- _portController = new PortController(legacyManagementController, Collections.emptySet());
+ _portController = new PortController(legacyManagementController, Set.of());
}
@Test
@@ -93,7 +93,7 @@ public class PortControllerTest extends UnitTestBase
attributes.put(LegacyConfiguredObject.CONTEXT, context);
final ConfiguredObject<?> root = mock(ConfiguredObject.class);
- final List<String> path = Collections.emptyList();
+ final List<String> path = List.of();
final Map<String, Object> converted = _portController.convertAttributesToNextVersion(root, path, attributes);
assertThat(converted, is(instanceOf(Map.class)));
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/QueueControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/QueueControllerTest.java
index 13ef8e00ab..bc2edcee89 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/QueueControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/QueueControllerTest.java
@@ -29,12 +29,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.text.NumberFormat;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -60,7 +59,7 @@ public class QueueControllerTest extends UnitTestBase
final ManagementController nextVersionManagementController = mock(ManagementController.class);
when(_legacyVersionManagementController.getNextVersionManagementController()).thenReturn(
nextVersionManagementController);
- _queueController = new QueueController(_legacyVersionManagementController, Collections.emptySet());
+ _queueController = new QueueController(_legacyVersionManagementController, Set.of());
}
@Test
@@ -86,7 +85,7 @@ public class QueueControllerTest extends UnitTestBase
when(nextVersionQueue.getAttribute(AbstractConfiguredObject.NAME)).thenReturn(queueName);
when(nextVersionQueue.getAttribute("overflowPolicy")).thenReturn("PRODUCER_FLOW_CONTROL");
when(nextVersionQueue.getAttribute("maximumQueueDepthBytes")).thenReturn(10000L);
- when(nextVersionQueue.getAttribute("context")).thenReturn(Collections.singletonMap("queue.queueFlowResumeLimit", "70"));
+ when(nextVersionQueue.getAttribute("context")).thenReturn(Map.of("queue.queueFlowResumeLimit", "70"));
when(nextVersionQueue.getAttribute("messageGroupType")).thenReturn("SHARED_GROUPS");
when(nextVersionQueue.getAttribute("messageGroupKeyOverride")).thenReturn("test");
@@ -95,14 +94,14 @@ public class QueueControllerTest extends UnitTestBase
when(nextVersionExchange.getAttribute(AbstractConfiguredObject.NAME)).thenReturn(exchangeName);
when(nextVersionExchange.getCategory()).thenReturn(ExchangeController.TYPE);
- when(nextVersionExchange.getAttribute("bindings")).thenReturn(Collections.singletonList(nextVersionBinding));
+ when(nextVersionExchange.getAttribute("bindings")).thenReturn(List.of(nextVersionBinding));
when(nextVersionAlternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionAlternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(nextVersionAlternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
- when(nextVersionVirtualHost.getChildren(ExchangeController.TYPE)).thenReturn(Arrays.asList(nextVersionExchange, nextVersionAlternateExchange));
- when(nextVersionVirtualHost.getChildren(QueueController.TYPE)).thenReturn(Collections.singletonList(nextVersionExchange));
+ when(nextVersionVirtualHost.getChildren(ExchangeController.TYPE)).thenReturn(List.of(nextVersionExchange, nextVersionAlternateExchange));
+ when(nextVersionVirtualHost.getChildren(QueueController.TYPE)).thenReturn(List.of(nextVersionExchange));
final LegacyConfiguredObject convertedExchange = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject convertedAltExchange = mock(LegacyConfiguredObject.class);
@@ -143,7 +142,7 @@ public class QueueControllerTest extends UnitTestBase
final ConfiguredObject<?> root = mock(ConfiguredObject.class);
- final List path = Arrays.asList("my-vhn", "my-vh", "testQueue");
+ final List path = List.of("my-vhn", "my-vh", "testQueue");
final Map<String, Object> converted = _queueController.convertAttributesToNextVersion(root, path, attributes);
assertThat(converted, is(notNullValue()));
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionControllerTest.java
index f4fed190ae..aa43f6688e 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/SessionControllerTest.java
@@ -29,7 +29,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import org.junit.jupiter.api.BeforeEach;
@@ -55,7 +57,7 @@ public class SessionControllerTest extends UnitTestBase
final ManagementController nextVersionManagementController = mock(ManagementController.class);
when(_legacyManagementController.getNextVersionManagementController()).thenReturn(
nextVersionManagementController);
- _sessionController = new SessionController(_legacyManagementController, Collections.emptySet());
+ _sessionController = new SessionController(_legacyManagementController, Set.of());
}
@Test
@@ -70,9 +72,8 @@ public class SessionControllerTest extends UnitTestBase
when(nextVersionSession.getAttribute(LegacyConfiguredObject.ID)).thenReturn(sessionID);
final ManagementResponse operationResult = new ControllerManagementResponse(ResponseType.MODEL_OBJECT,
- Collections.singletonList(
- nextVersionConsumer));
- when(nextVersionSession.invoke(eq("getConsumers"), eq(Collections.emptyMap()), eq(true))).thenReturn(
+ List.of(nextVersionConsumer));
+ when(nextVersionSession.invoke(eq("getConsumers"), eq(Map.of()), eq(true))).thenReturn(
operationResult);
final LegacyConfiguredObject convertedConsumer = mock(LegacyConfiguredObject.class);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/VirtualHostControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/VirtualHostControllerTest.java
index 076a22ef2e..e3fe2ac70f 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/VirtualHostControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/VirtualHostControllerTest.java
@@ -28,10 +28,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -54,7 +54,7 @@ public class VirtualHostControllerTest extends UnitTestBase
when(legacyManagementController.getNextVersionManagementController()).thenReturn(
nextVersionManagementController);
when(legacyManagementController.getVersion()).thenReturn("6.1");
- _virtualHostController = new VirtualHostController(legacyManagementController, Collections.emptySet());
+ _virtualHostController = new VirtualHostController(legacyManagementController, Set.of());
}
@Test
@@ -85,7 +85,7 @@ public class VirtualHostControllerTest extends UnitTestBase
attributes.put(LegacyConfiguredObject.CONTEXT, context);
final ConfiguredObject<?> root = mock(ConfiguredObject.class);
- final List<String> path = Collections.singletonList("test-vhn");
+ final List<String> path = List.of("test-vhn");
Map<String, Object> converted = _virtualHostController.convertAttributesToNextVersion(root, path, attributes);
assertThat(converted, is(notNullValue()));
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerTest.java
index f9c1645893..b1111f6759 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v7_0/LegacyManagementControllerTest.java
@@ -27,9 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -56,7 +54,7 @@ public class LegacyManagementControllerTest extends UnitTestBase
@Test
public void convertQueryParameters()
{
- final Map<String, List<String>> parameters = Collections.singletonMap("depth", Collections.singletonList("1"));
+ final Map<String, List<String>> parameters = Map.of("depth", List.of("1"));
final Map<String, List<String>> converted = _controller.convertQueryParameters(parameters);
assertThat(converted, is(equalTo(parameters)));
}
@@ -66,16 +64,15 @@ public class LegacyManagementControllerTest extends UnitTestBase
{
final String objectName = "test-object";
final String hostName = "test-vhn";
- final Map<String, List<String>> parameters = Collections.singletonMap("depth", Collections.singletonList("1"));
+ final Map<String, List<String>> parameters = Map.of("depth", List.of("1"));
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject vhn = mock(LegacyConfiguredObject.class);
- when(object.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME,
- LegacyConfiguredObject.TYPE));
+ when(object.getAttributeNames()).thenReturn(List.of(LegacyConfiguredObject.NAME, LegacyConfiguredObject.TYPE));
when(object.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(objectName);
when(object.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("Broker");
when(object.getCategory()).thenReturn("Broker");
- when(object.getChildren("VirtualHostNode")).thenReturn(Collections.singletonList(vhn));
- when(vhn.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME,
+ when(object.getChildren("VirtualHostNode")).thenReturn(List.of(vhn));
+ when(vhn.getAttributeNames()).thenReturn(List.of(LegacyConfiguredObject.NAME,
LegacyConfiguredObject.TYPE));
when(vhn.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(hostName);
when(vhn.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("VirtualHostNode");
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v8_0/category/LegacyCategoryController_v8_0Test.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v8_0/category/LegacyCategoryController_v8_0Test.java
index ca2ceb5271..f92b9e9acf 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v8_0/category/LegacyCategoryController_v8_0Test.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/controller/v8_0/category/LegacyCategoryController_v8_0Test.java
@@ -33,11 +33,10 @@ import static org.mockito.AdditionalMatchers.not;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -77,7 +76,7 @@ public class LegacyCategoryController_v8_0Test
TEST_CATEGORY,
PARENT_CATEGORY,
DEFAULT_TYPE,
- Collections.emptySet());
+ Set.of());
_root = mock(ConfiguredObject.class);
}
@@ -85,8 +84,8 @@ public class LegacyCategoryController_v8_0Test
@Test
public void getExistingPortWithSetAllowDenyTlsProtocolSettings()
{
- final List<String> path = Arrays.asList("port", PORT_NAME);
- final Map<String, List<String>> parameters = Collections.emptyMap();
+ final List<String> path = List.of("port", PORT_NAME);
+ final Map<String, List<String>> parameters = Map.of();
final LegacyConfiguredObject nextVersionPort = createNewVersionPortMock();
when(_nextVersionManagementController.get(_root,
@@ -104,7 +103,7 @@ public class LegacyCategoryController_v8_0Test
@Test
public void testCreatePortWithSetAllowDenyTlsProtocolSettings()
{
- final List<String> path = Arrays.asList("port", PORT_NAME);
+ final List<String> path = List.of("port", PORT_NAME);
final Map<String, String> oldContext = new HashMap<>();
oldContext.put(OLD_CONTEXT_TLS_PROTOCOL_WHITE_LIST,PROTOCOL_ALLOW_LIST);
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/report/ReportRunnerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/report/ReportRunnerTest.java
index c82cf448c6..2733d5c2b5 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/report/ReportRunnerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/report/ReportRunnerTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.when;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -51,18 +50,15 @@ public class ReportRunnerTest extends UnitTestBase
@Test
public void testTextReportCountsMessages()
{
- ReportRunner<String> runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME,
- Collections.emptyMap());
+ ReportRunner<String> runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME, Map.of());
Queue queue = createMockQueue();
assertEquals("There are 0 messages on the queue.", runner.runReport(queue));
- runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME,
- Collections.emptyMap());
+ runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME, Map.of());
Queue queue1 = createMockQueue(createMockMessageForQueue());
assertEquals("There are 1 messages on the queue.", runner.runReport(queue1));
- runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME,
- Collections.emptyMap());
+ runner = (ReportRunner<String>) ReportRunner.createRunner(TestTextReport.NAME, Map.of());
Queue queue2 = createMockQueue(createMockMessageForQueue(), createMockMessageForQueue());
assertEquals("There are 2 messages on the queue.", runner.runReport(queue2));
}
@@ -122,7 +118,7 @@ public class ReportRunnerTest extends UnitTestBase
{
try
{
- ReportRunner.createRunner("unknown", Collections.<String, String[]>emptyMap());
+ ReportRunner.createRunner("unknown", Map.of());
fail("Unknown report name should throw exception");
}
catch(IllegalArgumentException e)
@@ -134,10 +130,10 @@ public class ReportRunnerTest extends UnitTestBase
@Test
public void testBinaryReportWithLimit() throws Exception
{
- Queue queue = createMockQueue(createMessageWithAppProperties(Collections.singletonMap("key", 1)),
- createMessageWithAppProperties(Collections.singletonMap("key", 2)),
- createMessageWithAppProperties(Collections.singletonMap("key", 3)),
- createMessageWithAppProperties(Collections.singletonMap("key", 4)));
+ Queue queue = createMockQueue(createMessageWithAppProperties(Map.of("key", 1)),
+ createMessageWithAppProperties(Map.of("key", 2)),
+ createMessageWithAppProperties(Map.of("key", 3)),
+ createMessageWithAppProperties(Map.of("key", 4)));
Map<String, String[]> parameterMap = new HashMap<>();
parameterMap.put("propertyName", new String[]{"key"});
parameterMap.put("limit", new String[] { "3" });
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java
index fc604ba551..f926e07270 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java
@@ -36,12 +36,10 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -79,25 +77,21 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final UUID objectUuid = UUID.randomUUID();
final String objectName = "obj1";
- ConfiguredObject obj1 = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(ConfiguredObject.NAME, objectName);
- }});
+ ConfiguredObject obj1 = createCO(Map.of(ConfiguredObject.ID, objectUuid, ConfiguredObject.NAME, objectName));
_objects.add(obj1);
_query = new ConfiguredObjectQuery(_objects, null, null);
final List<String> headers = _query.getHeaders();
- assertEquals(Lists.newArrayList(ConfiguredObject.ID, ConfiguredObject.NAME), headers, "Unexpected headers");
+ assertEquals(List.of(ConfiguredObject.ID, ConfiguredObject.NAME), headers, "Unexpected headers");
List<List<Object>> results = _query.getResults();
assertEquals(1, (long) results.size(), "Unexpected number of results");
List<Object> row = results.iterator().next();
- assertEquals(Lists.newArrayList(objectUuid, objectName), row, "Unexpected row");
+ assertEquals(List.of(objectUuid, objectName), row, "Unexpected row");
}
@Test
@@ -145,18 +139,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final UUID object2Uuid = UUID.randomUUID();
final String object2Name = "obj2";
- ConfiguredObject obj1 = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, object1Uuid);
- put(ConfiguredObject.NAME, object1Name);
- put("foo", "bar");
- }});
+ ConfiguredObject obj1 = createCO(Map.of(ConfiguredObject.ID, object1Uuid,
+ ConfiguredObject.NAME, object1Name,
+ "foo", "bar"));
- ConfiguredObject obj2 = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, object2Uuid);
- put(ConfiguredObject.NAME, object2Name);
- }});
+ ConfiguredObject obj2 = createCO(Map.of(ConfiguredObject.ID, object2Uuid, ConfiguredObject.NAME, object2Name));
_objects.add(obj1);
_objects.add(obj2);
@@ -168,10 +155,10 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row1 = iterator.next();
- assertEquals(Lists.newArrayList(object1Uuid, object1Name), row1, "Unexpected row");
+ assertEquals(List.of(object1Uuid, object1Name), row1, "Unexpected row");
List<Object> row2 = iterator.next();
- assertEquals(Lists.newArrayList(object2Uuid, object2Name), row2, "Unexpected row");
+ assertEquals(List.of(object2Uuid, object2Name), row2, "Unexpected row");
}
@Test
@@ -179,11 +166,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject obj = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(NUMBER_ATTR, 1234);
- }});
+ ConfiguredObject obj = createCO(Map.of(ConfiguredObject.ID, objectUuid, NUMBER_ATTR, 1234));
_objects.add(obj);
@@ -195,26 +178,23 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
assertEquals(1, (long) results.size(), "Unexpected number of results");
final List<String> headers = _query.getHeaders();
- assertEquals(Lists.newArrayList(ConfiguredObject.ID, NUMBER_ATTR), headers, "Unexpected headers");
+ assertEquals(List.of(ConfiguredObject.ID, NUMBER_ATTR), headers, "Unexpected headers");
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row = iterator.next();
- assertEquals(Lists.newArrayList(objectUuid, 1234), row, "Unexpected row");
+ assertEquals(List.of(objectUuid, 1234), row, "Unexpected row");
}
@Test
public void testSelectClause_NonExistingColumn()
{
- ConfiguredObject obj = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, UUID.randomUUID());
- }});
+ ConfiguredObject obj = createCO(Map.of(ConfiguredObject.ID, UUID.randomUUID()));
_objects.add(obj);
_query = new ConfiguredObjectQuery(_objects, "foo", null);
List<List<Object>> results = _query.getResults();
assertEquals(1, (long) results.size(), "Unexpected number of results");
- assertEquals(Collections.singletonList("foo"), _query.getHeaders(), "Unexpected headers");
+ assertEquals(List.of("foo"), _query.getHeaders(), "Unexpected headers");
assertEquals(Collections.singletonList(null), results.get(0), "Unexpected row");
}
@@ -223,12 +203,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject obj = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(ConfiguredObject.NAME, "myObj");
- put(NUMBER_ATTR, 1234);
- }});
+ ConfiguredObject obj = createCO(Map.of(ConfiguredObject.ID, objectUuid,
+ ConfiguredObject.NAME, "myObj",
+ NUMBER_ATTR, 1234));
_objects.add(obj);
@@ -240,11 +217,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
assertEquals(1, (long) results.size(), "Unexpected number of results");
final List<String> headers = _query.getHeaders();
- assertEquals(Lists.newArrayList(ConfiguredObject.ID, "alias"), headers, "Unexpected headers");
+ assertEquals(List.of(ConfiguredObject.ID, "alias"), headers, "Unexpected headers");
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row = iterator.next();
- assertEquals(Lists.newArrayList(objectUuid, "myObj1234"), row, "Unexpected row");
+ assertEquals(List.of(objectUuid, "myObj1234"), row, "Unexpected row");
}
@Test
@@ -253,17 +230,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final UUID objectUuid = UUID.randomUUID();
final String objectName = "obj2";
- ConfiguredObject nonMatch = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, UUID.randomUUID());
- put(ConfiguredObject.NAME, "obj1");
- }});
+ ConfiguredObject nonMatch = createCO(Map.of(ConfiguredObject.ID, UUID.randomUUID(), ConfiguredObject.NAME, "obj1"));
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(ConfiguredObject.NAME, objectName);
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid, ConfiguredObject.NAME, objectName));
_objects.add(nonMatch);
_objects.add(match);
@@ -271,7 +240,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
_query = new ConfiguredObjectQuery(_objects, null, String.format("name = '%s'", objectName));
final List<String> headers = _query.getHeaders();
- assertEquals(Lists.newArrayList(ConfiguredObject.ID, ConfiguredObject.NAME), headers, "Unexpected headers");
+ assertEquals(List.of(ConfiguredObject.ID, ConfiguredObject.NAME), headers, "Unexpected headers");
List<List<Object>> results = _query.getResults();
assertEquals(1, (long) results.size(), "Unexpected number of results");
@@ -290,17 +259,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final Date yesterday = new Date(now - oneDayInMillis);
final Date tomorrow = new Date(now + oneDayInMillis);
- ConfiguredObject nonMatch = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, UUID.randomUUID());
- put(DATE_ATTR, yesterday);
- }});
+ ConfiguredObject nonMatch = createCO(Map.of(ConfiguredObject.ID, UUID.randomUUID(),
+ DATE_ATTR, yesterday));
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(DATE_ATTR, tomorrow);
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid,
+ DATE_ATTR, tomorrow));
_objects.add(nonMatch);
_objects.add(match);
@@ -327,17 +290,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject nonMatch = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, UUID.randomUUID());
- put(DATE_ATTR, new Date(0));
- }});
+ ConfiguredObject nonMatch = createCO(Map.of(ConfiguredObject.ID, UUID.randomUUID(), DATE_ATTR, new Date(0)));
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(DATE_ATTR, new Date(now));
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid, DATE_ATTR, new Date(now)));
_objects.add(nonMatch);
_objects.add(match);
@@ -360,11 +315,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(DATE_ATTR, new Date(0));
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid, DATE_ATTR, new Date(0)));
_objects.add(match);
@@ -388,11 +339,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(DATE_ATTR, new Date(0));
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid, DATE_ATTR, new Date(0)));
_objects.add(match);
@@ -405,7 +352,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row = iterator.next();
- assertEquals(Lists.newArrayList(objectUuid, "1970-01-01T00:00:00Z"), row, "Unexpected row");
+ assertEquals(List.of(objectUuid, "1970-01-01T00:00:00Z"), row, "Unexpected row");
}
@Test
@@ -413,11 +360,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject match = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(DATE_ATTR, new Date(0));
- }});
+ ConfiguredObject match = createCO(Map.of(ConfiguredObject.ID, objectUuid, DATE_ATTR, new Date(0)));
_objects.add(match);
@@ -429,11 +372,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
null);
List<List<Object>> results = _query.getResults();
- assertEquals((long) 1, (long) results.size(), "Unexpected number of results");
+ assertEquals(1, (long) results.size(), "Unexpected number of results");
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row = iterator.next();
- assertEquals(Lists.newArrayList(objectUuid, "1970-01-01 UTC"), row, "Unexpected row");
+ assertEquals(List.of(objectUuid, "1970-01-01 UTC"), row, "Unexpected row");
}
@Test
@@ -441,12 +384,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject obj = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(ENUM_ATTR, Snakes.PYTHON);
- put(ENUM2_ATTR, Snakes.PYTHON);
- }});
+ ConfiguredObject obj = createCO(Map.of(ConfiguredObject.ID, objectUuid,
+ ENUM_ATTR, Snakes.PYTHON,
+ ENUM2_ATTR, Snakes.PYTHON));
_objects.add(obj);
@@ -466,8 +406,8 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
String.format("'%s' = %s", Snakes.PYTHON, ENUM_ATTR));
results = _query.getResults();
- assertEquals((long) 1, (long) results.size(),
- "Unexpected number of results - enum constant equality with enumAttr");
+ assertEquals(1, (long) results.size(),
+ "Unexpected number of results - enum constant equality with enumAttr");
row = _query.getResults().iterator().next();
assertEquals(objectUuid, row.get(0), "Unexpected row");
@@ -494,12 +434,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
final UUID objectUuid = UUID.randomUUID();
- ConfiguredObject obj = createCO(new HashMap<String, Object>()
- {{
- put(ConfiguredObject.ID, objectUuid);
- put(ENUM_ATTR, Snakes.PYTHON);
- put(ENUM2_ATTR, Snakes.PYTHON);
- }});
+ ConfiguredObject obj = createCO(Map.of(ConfiguredObject.ID, objectUuid,
+ ENUM_ATTR, Snakes.PYTHON,
+ ENUM2_ATTR, Snakes.PYTHON));
_objects.add(obj);
@@ -554,14 +491,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
for (int i = 0; i < NUMBER_OF_OBJECTS; ++i)
{
final int foo = (i + 1) % NUMBER_OF_OBJECTS;
- ConfiguredObject object = createCO(new HashMap<String, Object>()
- {{
- put("foo", foo);
- }});
+ ConfiguredObject object = createCO(Map.of("foo", foo));
_objects.add(object);
}
- ConfiguredObject object = createCO(new HashMap<String, Object>()
+ ConfiguredObject object = createCO(new HashMap<>()
{{
put("foo", null);
}});
@@ -586,20 +520,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
@Test
public void testAliasInOrderByClause()
{
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 2);
- }}));
+ _objects.add(createCO(Map.of("foo", 2)));
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 1);
- }}));
+ _objects.add(createCO(Map.of("foo", 1)));
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 4);
- }}));
+ _objects.add(createCO(Map.of("foo", 4)));
_query = new ConfiguredObjectQuery(_objects, "foo AS bar", null, "bar ASC");
assertQueryResults(new Object[][]{{1}, {2}, {4}}, _query.getResults());
@@ -608,17 +533,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
@Test
public void testExpressionToTermsOfAliasInOrderByClause()
{
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo1", "A");
- put("foo2", "B");
- }}));
+ _objects.add(createCO(Map.of("foo1", "A", "foo2", "B")));
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo1", "A");
- put("foo2", "A");
- }}));
+ _objects.add(createCO(Map.of("foo1", "A", "foo2", "A")));
_query = new ConfiguredObjectQuery(_objects, "foo1 AS bar1, foo2", null, "CONCAT(bar, foo2) ASC");
assertQueryResults(new Object[][]{{"A", "A"}, {"A", "B"}}, _query.getResults());
@@ -627,20 +544,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
@Test
public void testDelimitedAliasInOrderByClause()
{
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 2);
- }}));
+ _objects.add(createCO(Map.of("foo", 2)));
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 1);
- }}));
+ _objects.add(createCO(Map.of("foo", 1)));
- _objects.add(createCO(new HashMap<String, Object>()
- {{
- put("foo", 4);
- }}));
+ _objects.add(createCO(Map.of("foo", 4)));
_query = new ConfiguredObjectQuery(_objects, "foo AS \"yogi bear\"", null, "\"yogi bear\" DESC");
assertQueryResults(new Object[][]{{4}, {2}, {1}}, _query.getResults());
@@ -651,25 +559,13 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
{
ConfiguredObject object;
- object = createCO(new HashMap<String, Object>()
- {{
- put("foo", 1);
- put("bar", 1);
- }});
+ object = createCO(Map.of("foo", 1, "bar", 1));
_objects.add(object);
- object = createCO(new HashMap<String, Object>()
- {{
- put("foo", 1);
- put("bar", 2);
- }});
+ object = createCO(Map.of("foo", 1, "bar", 2));
_objects.add(object);
- object = createCO(new HashMap<String, Object>()
- {{
- put("foo", 2);
- put("bar", 0);
- }});
+ object = createCO(Map.of("foo", 2, "bar", 0));
_objects.add(object);
_query = new ConfiguredObjectQuery(_objects, "foo,bar", null, "foo, bar");
@@ -741,10 +637,7 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
for(int i=0;i<numberOfTestObjects;i++)
{
final String name = "test-" + i;
- ConfiguredObject object = createCO(new HashMap<String, Object>()
- {{
- put("name", name);
- }});
+ ConfiguredObject object = createCO(Map.of("name", name));
_objects.add(object);
}
@@ -792,12 +685,11 @@ public class ConfiguredObjectQueryTest extends UnitTestBase
}
}
- private ConfiguredObject createCO(final HashMap<String, Object> map)
+ private ConfiguredObject createCO(final Map<String, Object> map)
{
ConfiguredObject object = mock(ConfiguredObject.class);
- Map<String, Object> orderedMap = Maps.newTreeMap();
- orderedMap.putAll(map);
+ Map<String, Object> orderedMap = new TreeMap<>(map);
when(object.getAttributeNames()).thenReturn(orderedMap.keySet());
for(String attributeName : orderedMap.keySet())
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
index 797bf1ad5b..1f8e0a0bde 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
@@ -30,9 +30,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -87,7 +85,7 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
final String statisticName = "statisticName";
final int statisticValue = 10;
- when(_configuredObject.getStatistics()).thenReturn(Collections.singletonMap(statisticName, (Number) statisticValue));
+ when(_configuredObject.getStatistics()).thenReturn(Map.of(statisticName, (Number) statisticValue));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class,
@@ -162,7 +160,7 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
when(mockChild.getModel()).thenReturn(model);
when(_configuredObject.getModel()).thenReturn(model);
configureMockToReturnOneAttribute(mockChild, childAttributeName, childAttributeValue);
- when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
+ when(_configuredObject.getChildren(TestChild.class)).thenReturn(List.of(mockChild));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
ConfiguredObject.class,
@@ -189,24 +187,24 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
final String childAttributeName = "childattribute";
final String childAttributeValue = "childvalue";
final String childActualAttributeValue = "${actualvalue}";
- final Map<String,Object> actualContext = Collections.singletonMap("key", "value");
- final Set<String> inheritedKeys = new HashSet<>(Arrays.asList("key","inheritedkey"));
+ final Map<String,Object> actualContext = Map.of("key", "value");
+ final Set<String> inheritedKeys = new HashSet<>(List.of("key","inheritedkey"));
Model model = createTestModel();
TestChild mockChild = mock(TestChild.class);
when(mockChild.getModel()).thenReturn(model);
when(_configuredObject.getModel()).thenReturn(model);
- when(_configuredObject.getAttributeNames()).thenReturn(Collections.singletonList(ConfiguredObject.CONTEXT));
+ when(_configuredObject.getAttributeNames()).thenReturn(List.of(ConfiguredObject.CONTEXT));
when(_configuredObject.getContextValue(eq(String.class), eq("key"))).thenReturn("value");
when(_configuredObject.getContextValue(eq(String.class),eq("inheritedkey"))).thenReturn("foo");
when(_configuredObject.getContextKeys(anyBoolean())).thenReturn(inheritedKeys);
when(_configuredObject.getContext()).thenReturn(actualContext);
- when(_configuredObject.getActualAttributes()).thenReturn(Collections.singletonMap(ConfiguredObject.CONTEXT, actualContext));
- when(mockChild.getAttributeNames()).thenReturn(Arrays.asList(childAttributeName, ConfiguredObject.CONTEXT));
+ when(_configuredObject.getActualAttributes()).thenReturn(Map.of(ConfiguredObject.CONTEXT, actualContext));
+ when(mockChild.getAttributeNames()).thenReturn(List.of(childAttributeName, ConfiguredObject.CONTEXT));
when(mockChild.getAttribute(childAttributeName)).thenReturn(childAttributeValue);
- when(mockChild.getActualAttributes()).thenReturn(Collections.singletonMap(childAttributeName, childActualAttributeValue));
- when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
+ when(mockChild.getActualAttributes()).thenReturn(Map.of(childAttributeName, childActualAttributeValue));
+ when(_configuredObject.getChildren(TestChild.class)).thenReturn(List.of(mockChild));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
@@ -264,7 +262,7 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
when(mockChild.getModel()).thenReturn(model);
when(_configuredObject.getModel()).thenReturn(model);
configureMockToReturnOneAttribute(mockChild, "longAttr", "this is not long");
- when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
+ when(_configuredObject.getChildren(TestChild.class)).thenReturn(List.of(mockChild));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject,
@@ -344,8 +342,8 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
configureMockToReturnOneAttribute(mockChild, "secureAttribute", "*****");
// set actual values
- when(mockChild.getActualAttributes()).thenReturn(Collections.singletonMap("secureAttribute", "secret"));
- when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
+ when(mockChild.getActualAttributes()).thenReturn(Map.of("secureAttribute", "secret"));
+ when(_configuredObject.getChildren(TestChild.class)).thenReturn(List.of(mockChild));
when(model.getParentType(TestChild.class)).thenReturn((Class)TestChild.class);
when(_configuredObject.getCategoryClass()).thenReturn(TestChild.class);
when(mockChild.isDurable()).thenReturn(true);
@@ -505,7 +503,7 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
private Model createTestModel()
{
Model model = mock(Model.class);
- final List<Class<? extends ConfiguredObject>> list = new ArrayList<Class<? extends ConfiguredObject>>();
+ final List<Class<? extends ConfiguredObject>> list = new ArrayList<>();
list.add(TestChild.class);
when(model.getChildTypes(ConfiguredObject.class)).thenReturn(list);
final ConfiguredObjectTypeRegistry typeRegistry = mock(ConfiguredObjectTypeRegistry.class);
@@ -518,7 +516,7 @@ public class ConfiguredObjectToMapConverterTest extends UnitTestBase
private void configureMockToReturnOneAttribute(ConfiguredObject mockConfiguredObject, String attributeName, Object attributeValue)
{
- when(mockConfiguredObject.getAttributeNames()).thenReturn(Arrays.asList(attributeName));
+ when(mockConfiguredObject.getAttributeNames()).thenReturn(List.of(attributeName));
when(mockConfiguredObject.getAttribute(attributeName)).thenReturn(attributeValue);
}
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParserTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParserTest.java
index 3541810ee4..113edbe3d2 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParserTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RequestInfoParserTest.java
@@ -29,8 +29,7 @@ import static org.mockito.Mockito.when;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collections;
+import java.util.List;
import jakarta.servlet.http.HttpServletRequest;
@@ -56,7 +55,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Collections.emptyList(), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -73,7 +72,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
assertTrue(info.isSingletonRequest(), "Expected exact object request");
}
@@ -87,7 +86,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName), info.getModelParts(), "Unexpected model parts");
assertFalse(info.isSingletonRequest(), "Expected exact object request");
}
@@ -128,7 +127,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName), info.getModelParts(), "Unexpected model parts");
}
@@ -146,7 +145,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -205,7 +204,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -220,7 +219,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -273,7 +272,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
}
@@ -289,7 +288,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName, vhName), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -322,7 +321,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.MODEL_OBJECT, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName), info.getModelParts(), "Unexpected model parts");
}
@Test
@@ -361,7 +360,7 @@ public class RequestInfoParserTest extends UnitTestBase
RequestInfo info = parser.parse(_request);
assertEquals(RequestType.OPERATION, info.getType(), "Unexpected request type");
- assertEquals(Arrays.asList(vhnName), info.getModelParts(), "Unexpected model parts");
+ assertEquals(List.of(vhnName), info.getModelParts(), "Unexpected model parts");
assertEquals(operationName, info.getOperationName(), "Unexpected operation name");
assertTrue(info.isSingletonRequest(), "Expected exact object request");
}
diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
index c50260acc5..3b5c174728 100644
--- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
+++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
@@ -30,8 +30,6 @@ import static org.mockito.Mockito.when;
import java.security.Principal;
import java.security.PrivilegedAction;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -41,8 +39,6 @@ import java.util.UUID;
import javax.security.auth.Subject;
-import com.google.common.collect.Lists;
-
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -83,10 +79,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
PreferenceStore preferenceStore = mock(PreferenceStore.class);
_preferenceTaskExecutor = new CurrentThreadTaskExecutor();
_preferenceTaskExecutor.start();
- _userPreferences = new UserPreferencesImpl(_preferenceTaskExecutor,
- _configuredObject,
- preferenceStore,
- Collections.emptyList());
+ _userPreferences =
+ new UserPreferencesImpl(_preferenceTaskExecutor, _configuredObject, preferenceStore, List.of());
_subject = TestPrincipalUtils.createTestSubject(MYUSER, MYGROUP);
_groupPrincipal = _subject.getPrincipals(GroupPrincipal.class).iterator().next();
_userPrincipal = _subject.getPrincipals(AuthenticatedPrincipal.class).iterator().next();
@@ -103,14 +97,12 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
public void testPutWithVisibilityList_ValidGroup()
{
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(Collections.<String>emptyList(),
- Arrays.asList("X-testtype",
- "myprefname")
- );
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype", "myprefname"));
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList(MYGROUP_SERIALIZATION));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of(MYGROUP_SERIALIZATION));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -131,12 +123,12 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
public void testPutWithVisibilityList_InvalidGroup()
{
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Arrays.asList("X-testtype", "myprefname"));
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype", "myprefname"));
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList("Invalid Group"));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of("Invalid Group"));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -157,11 +149,11 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
public void testPutByTypeAndName()
{
final String prefName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Arrays.asList("X-testtype", prefName));
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype", prefName));
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -179,11 +171,11 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
public void testReplaceViaPutByTypeAndName()
{
final String prefName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Arrays.asList("X-testtype", prefName));
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype", prefName));
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
final Preference createdPreference = Subject.doAs(_subject, (PrivilegedAction<Preference>) () ->
{
@@ -199,7 +191,7 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
final Map<String, Object> replacementPref = new HashMap<>();
replacementPref.put(Preference.ID_ATTRIBUTE, createdPreference.getId().toString());
- replacementPref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ replacementPref.put(Preference.VALUE_ATTRIBUTE, Map.of());
final String changedDescription = "Replace that maintains id";
replacementPref.put(Preference.DESCRIPTION_ATTRIBUTE, changedDescription);
@@ -239,16 +231,16 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
public void testReplaceViaPutByType()
{
final String prefName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.singletonList("X-testtype"));
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype"));
final Map<String, Object> pref = new HashMap<>();
pref.put(Preference.NAME_ATTRIBUTE, prefName);
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref.put(Preference.VALUE_ATTRIBUTE, new HashMap<>());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
- _handler.handlePUT(_configuredObject, requestInfo, Lists.newArrayList(pref));
+ _handler.handlePUT(_configuredObject, requestInfo, List.of(pref));
Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
assertEquals(1, (long) preferences.size(), "Unexpected number of preferences");
@@ -262,15 +254,15 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
final Map<String, Object> replacementPref1 = new HashMap<>();
replacementPref1.put(Preference.NAME_ATTRIBUTE, replacementPref1Name);
- replacementPref1.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ replacementPref1.put(Preference.VALUE_ATTRIBUTE, Map.of());
final Map<String, Object> replacementPref2 = new HashMap<>();
replacementPref2.put(Preference.NAME_ATTRIBUTE, replacementPref2Name);
- replacementPref2.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ replacementPref2.put(Preference.VALUE_ATTRIBUTE, Map.of());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
- _handler.handlePUT(_configuredObject, requestInfo, Lists.newArrayList(replacementPref1, replacementPref2));
+ _handler.handlePUT(_configuredObject, requestInfo, List.of(replacementPref1, replacementPref2));
Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
assertEquals(2, (long) preferences.size(), "Unexpected number of preferences after update");
@@ -296,22 +288,21 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
final String pref2Name = "mypref2name";
final String pref2Type = "X-testtype2";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList());
+ final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of());
final Map<String, Object> pref1 = new HashMap<>();
pref1.put(Preference.NAME_ATTRIBUTE, pref1Name);
- pref1.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref1.put(Preference.VALUE_ATTRIBUTE, Map.of());
pref1.put(Preference.TYPE_ATTRIBUTE, pref1Type);
final Map<String, Object> pref2 = new HashMap<>();
pref2.put(Preference.NAME_ATTRIBUTE, pref2Name);
- pref2.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref2.put(Preference.VALUE_ATTRIBUTE, Map.of());
pref2.put(Preference.TYPE_ATTRIBUTE, pref2Type);
final Map<String, List<Map<String, Object>>> payload = new HashMap<>();
- payload.put(pref1Type, Collections.singletonList(pref1));
- payload.put(pref2Type, Collections.singletonList(pref2));
+ payload.put(pref1Type, List.of(pref1));
+ payload.put(pref2Type, List.of(pref2));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -326,11 +317,11 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
final Map<String, Object> replacementPref1 = new HashMap<>();
replacementPref1.put(Preference.NAME_ATTRIBUTE, replacementPref1Name);
- replacementPref1.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ replacementPref1.put(Preference.VALUE_ATTRIBUTE, Map.of());
replacementPref1.put(Preference.TYPE_ATTRIBUTE, pref1Type);
payload.clear();
- payload.put(pref1Type, Collections.singletonList(replacementPref1));
+ payload.put(pref1Type, List.of(replacementPref1));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -348,17 +339,16 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
@Test
public void testPostToTypeWithVisibilityList_ValidGroup()
{
- final RequestInfo typeRequestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.singletonList("X-testtype"));
+ final RequestInfo typeRequestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype"));
final Map<String, Object> pref = new HashMap<>();
pref.put(Preference.NAME_ATTRIBUTE, "testPref");
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList(MYGROUP_SERIALIZATION));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of(MYGROUP_SERIALIZATION));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
- _handler.handlePOST(_configuredObject, typeRequestInfo, Collections.singletonList(pref));
+ _handler.handlePOST(_configuredObject, typeRequestInfo, List.of(pref));
Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
assertEquals(1, (long) preferences.size(), "Unexpected number of preferences");
@@ -374,18 +364,17 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
@Test
public void testPostToRootWithVisibilityList_ValidGroup()
{
- final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList());
+ final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of());
final Map<String, Object> pref = new HashMap<>();
pref.put(Preference.NAME_ATTRIBUTE, "testPref");
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList(MYGROUP_SERIALIZATION));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of(MYGROUP_SERIALIZATION));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
final Map<String, List<Map<String, Object>>> payload =
- Collections.singletonMap("X-testtype2", Collections.singletonList(pref));
+ Map.of("X-testtype2", List.of(pref));
_handler.handlePOST(_configuredObject, rootRequestInfo, payload);
Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
@@ -403,19 +392,18 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
@Test
public void testPostToTypeWithVisibilityList_InvalidGroup()
{
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.singletonList("X-testtype"));
+ final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of("X-testtype"));
final Map<String, Object> pref = new HashMap<>();
pref.put(Preference.NAME_ATTRIBUTE, "testPref");
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList("Invalid Group"));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of("Invalid Group"));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
try
{
- _handler.handlePOST(_configuredObject, requestInfo, Collections.singletonList(pref));
+ _handler.handlePOST(_configuredObject, requestInfo, List.of(pref));
fail("Expected exception not thrown");
}
catch (IllegalArgumentException e)
@@ -429,20 +417,19 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
@Test
public void testPostToRootWithVisibilityList_InvalidGroup()
{
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList());
+ final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of());
final Map<String, Object> pref = new HashMap<>();
pref.put(Preference.NAME_ATTRIBUTE, "testPref");
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
- pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, Collections.singletonList("Invalid Group"));
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
+ pref.put(Preference.VISIBILITY_LIST_ATTRIBUTE, List.of("Invalid Group"));
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
try
{
final Map<String, List<Map<String, Object>>> payload =
- Collections.singletonMap("X-testType", Collections.singletonList(pref));
+ Map.of("X-testType", List.of(pref));
_handler.handlePOST(_configuredObject, requestInfo, payload);
fail("Expected exception not thrown");
}
@@ -457,8 +444,7 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
@Test
public void testGetHasCorrectVisibilityList()
{
- final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList());
+ final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of());
final String type = "X-testtype";
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
@@ -470,10 +456,10 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
"testpref",
null,
MYUSER_SERIALIZATION,
- Collections.singleton(MYGROUP_SERIALIZATION),
- Collections.emptyMap());
+ Set.of(MYGROUP_SERIALIZATION),
+ Map.of());
Preference preference = PreferenceFactory.fromAttributes(_configuredObject, prefAttributes);
- awaitPreferenceFuture(_userPreferences.updateOrAppend(Collections.singleton(preference)));
+ awaitPreferenceFuture(_userPreferences.updateOrAppend(Set.of(preference)));
Map<String, List<Map<String, Object>>> typeToPreferenceListMap =
(Map<String, List<Map<String, Object>>>) _handler.handleGET(_userPreferences,
@@ -504,7 +490,7 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
null,
MYUSER_SERIALIZATION,
null,
- Collections.emptyMap());
+ Map.of());
Preference p1 = PreferenceFactory.fromAttributes(_configuredObject, pref1Attributes);
Map<String, Object> pref2Attributes = createPreferenceAttributes(
null,
@@ -514,14 +500,13 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
null,
MYUSER_SERIALIZATION,
null,
- Collections.emptyMap());
+ Map.of());
Preference p2 = PreferenceFactory.fromAttributes(_configuredObject, pref2Attributes);
- awaitPreferenceFuture(_userPreferences.updateOrAppend(Arrays.asList(p1, p2)));
+ awaitPreferenceFuture(_userPreferences.updateOrAppend(List.of(p1, p2)));
UUID id = p1.getId();
- final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList(),
- Collections.singletonMap("id", Collections.singletonList(id.toString())));
+ final RequestInfo rootRequestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of(), Map.of("id", List.of(id.toString())));
Map<String, List<Map<String, Object>>> typeToPreferenceListMap =
(Map<String, List<Map<String, Object>>>) _handler.handleGET(_userPreferences, rootRequestInfo);
@@ -548,7 +533,7 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
null,
MYUSER_SERIALIZATION,
null,
- Collections.emptyMap());
+ Map.of());
Preference p1 = PreferenceFactory.fromAttributes(_configuredObject, pref1Attributes);
Map<String, Object> pref2Attributes = createPreferenceAttributes(
null,
@@ -558,14 +543,13 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
null,
MYUSER_SERIALIZATION,
null,
- Collections.emptyMap());
+ Map.of());
Preference p2 = PreferenceFactory.fromAttributes(_configuredObject, pref2Attributes);
- awaitPreferenceFuture(_userPreferences.updateOrAppend(Arrays.asList(p1, p2)));
+ awaitPreferenceFuture(_userPreferences.updateOrAppend(List.of(p1, p2)));
UUID id = p1.getId();
- final RequestInfo rootRequestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList(),
- Collections.singletonMap("id", Collections.singletonList(id.toString())));
+ final RequestInfo rootRequestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of(), Map.of("id", List.of(id.toString())));
_handler.handleDELETE(_userPreferences, rootRequestInfo);
@@ -581,11 +565,11 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String preferenceType = "X-testtype";
final String preferenceName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Arrays.asList(preferenceType, preferenceName));
+ final RequestInfo requestInfo =
+ RequestInfo.createPreferencesRequestInfo(List.of(), List.of(preferenceType, preferenceName));
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
doTestDelete(preferenceType, preferenceName, requestInfo);
}
@@ -595,11 +579,7 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String preferenceType = "X-testtype";
final String preferenceName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.singletonList(preferenceType));
-
- final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of(preferenceType));
doTestDelete(preferenceType, preferenceName, requestInfo);
}
@@ -609,11 +589,10 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String preferenceType = "X-testtype";
final String preferenceName = "myprefname";
- final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList());
+ final RequestInfo requestInfo = RequestInfo.createPreferencesRequestInfo(List.of(), List.of());
final Map<String, Object> pref = new HashMap<>();
- pref.put(Preference.VALUE_ATTRIBUTE, Collections.emptyMap());
+ pref.put(Preference.VALUE_ATTRIBUTE, Map.of());
doTestDelete(preferenceType, preferenceName, requestInfo);
}
@@ -623,8 +602,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String prefName = "testpref";
final String prefType = "X-testtype";
- final RequestInfo rootRequestInfo = RequestInfo.createVisiblePreferencesRequestInfo(
- Collections.emptyList(), Collections.emptyList(), Collections.emptyMap());
+ final RequestInfo rootRequestInfo =
+ RequestInfo.createVisiblePreferencesRequestInfo(List.of(), List.of(), Map.of());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -636,8 +615,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
prefName,
null,
MYUSER_SERIALIZATION,
- Collections.singleton(MYGROUP_SERIALIZATION),
- Collections.emptyMap());
+ Set.of(MYGROUP_SERIALIZATION),
+ Map.of());
Preference p1 = PreferenceFactory.fromAttributes(_configuredObject, pref1Attributes);
preferences.add(p1);
Map<String, Object> pref2Attributes = createPreferenceAttributes(
@@ -647,8 +626,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
"testPref2",
null,
MYUSER_SERIALIZATION,
- Collections.emptySet(),
- Collections.emptyMap());
+ Set.of(),
+ Map.of());
Preference p2 = PreferenceFactory.fromAttributes(_configuredObject, pref2Attributes);
preferences.add(p2);
awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
@@ -684,8 +663,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String prefName = "testpref";
final String prefType = "X-testtype";
- final RequestInfo rootRequestInfo = RequestInfo.createVisiblePreferencesRequestInfo(
- Collections.emptyList(), Collections.singletonList(prefType), Collections.emptyMap());
+ final RequestInfo rootRequestInfo =
+ RequestInfo.createVisiblePreferencesRequestInfo(List.of(), List.of(prefType), Map.of());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -697,8 +676,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
prefName,
null,
MYUSER_SERIALIZATION,
- Collections.singleton(MYGROUP_SERIALIZATION),
- Collections.emptyMap());
+ Set.of(MYGROUP_SERIALIZATION),
+ Map.of());
Preference p1 = PreferenceFactory.fromAttributes(_configuredObject, pref1Attributes);
preferences.add(p1);
Map<String, Object> pref2Attributes = createPreferenceAttributes(
@@ -708,8 +687,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
"testPref2",
null,
MYUSER_SERIALIZATION,
- Collections.emptySet(),
- Collections.emptyMap());
+ Set.of(),
+ Map.of());
Preference p2 = PreferenceFactory.fromAttributes(_configuredObject, pref2Attributes);
preferences.add(p2);
awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
@@ -741,8 +720,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
{
final String prefName = "testpref";
final String prefType = "X-testtype";
- final RequestInfo rootRequestInfo = RequestInfo.createVisiblePreferencesRequestInfo(
- Collections.emptyList(), Arrays.asList(prefType, prefName), Collections.emptyMap());
+ final RequestInfo rootRequestInfo =
+ RequestInfo.createVisiblePreferencesRequestInfo(List.of(), List.of(prefType, prefName), Map.of());
Subject.doAs(_subject, (PrivilegedAction<Void>) () ->
{
@@ -754,8 +733,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
prefName,
null,
MYUSER_SERIALIZATION,
- Collections.singleton(MYGROUP_SERIALIZATION),
- Collections.emptyMap());
+ Set.of(MYGROUP_SERIALIZATION),
+ Map.of());
Preference p1 = PreferenceFactory.fromAttributes(_configuredObject, pref1Attributes);
preferences.add(p1);
Map<String, Object> pref2Attributes = createPreferenceAttributes(
@@ -765,8 +744,8 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
"testPref2",
null,
MYUSER_SERIALIZATION,
- Collections.emptySet(),
- Collections.emptyMap());
+ Set.of(),
+ Map.of());
Preference p2 = PreferenceFactory.fromAttributes(_configuredObject, pref2Attributes);
preferences.add(p2);
awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
@@ -801,9 +780,9 @@ public class RestUserPreferenceHandlerTest extends UnitTestBase
null,
MYUSER_SERIALIZATION,
null,
- Collections.emptyMap());
+ Map.of());
Preference preference = PreferenceFactory.fromAttributes(_configuredObject, preferenceAttributes);
- awaitPreferenceFuture(_userPreferences.updateOrAppend(Collections.singleton(preference)));
+ awaitPreferenceFuture(_userPreferences.updateOrAppend(Set.of(preference)));
Set<Preference> retrievedPreferences = awaitPreferenceFuture(_userPreferences.getPreferences());
assertEquals(1, (long) retrievedPreferences.size(), "adding pref failed");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org