diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-07 18:07:09 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-07 18:13:22 -0400 |
commit | 71a2c192c13200c5f864bca610e1ba6cf99e8e82 (patch) | |
tree | ca4b6f8cc12a00b494b3337215bac6e2eca9a8e0 /models-interactions/model-actors/actor.test | |
parent | da708d64dc27f36ed5da733fca14ebfb4cc2832b (diff) |
Fix sonars in policy-models actors
Fixed:
- use "var"
- don't throw generic Exception
Issue-ID: POLICY-3094
Change-Id: I020addb9511fd665b5fed48e7d40719e27039224
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.test')
3 files changed, 12 insertions, 8 deletions
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java index 304d4cd44..7aa5b9470 100644 --- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java +++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ import lombok.Getter; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; -import org.onap.policy.common.endpoints.http.client.HttpClientFactory; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.parameters.BeanValidationResult; @@ -116,7 +115,7 @@ public class BasicActor { */ private MyConfig readConfig(String yamlConfigFile) { try { - String yaml = ResourceUtils.getResourceAsString(yamlConfigFile); + var yaml = ResourceUtils.getResourceAsString(yamlConfigFile); if (yaml == null) { throw new FileNotFoundException(yamlConfigFile); } @@ -139,7 +138,7 @@ public class BasicActor { stopOtherServices(); if (config.getHttpClients() != null) { - HttpClientFactory factory = HttpClientFactoryInstance.getClientFactory(); + var factory = HttpClientFactoryInstance.getClientFactory(); for (BusTopicParams params : config.getHttpClients()) { factory.build(params); } diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java index f30802c32..3e06f1c11 100644 --- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java @@ -31,6 +31,7 @@ import org.mockito.Mock; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.parameters.TopicParameters; @@ -97,13 +98,17 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation /** * Starts the topic. + * + * @throws InterruptedException if interrupted + * @throws BidirectionalTopicClientException if the client cannot be built */ - protected static void initBeforeClass(String sinkTopic, String sourceTopic) throws Exception { + protected static void initBeforeClass(String sinkTopic, String sourceTopic) + throws InterruptedException, BidirectionalTopicClientException { Util.buildDmaapSim(); // note: the sink and source names are swapped for the simulator - TopicParameters ptopic = new TopicParameters(); + var ptopic = new TopicParameters(); ptopic.setTopic(sourceTopic); ptopic.setManaged(true); ptopic.setServers(List.of("localhost")); diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java index 766e0fb2d..39adbf55d 100644 --- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java +++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java @@ -53,7 +53,7 @@ public class BasicOperation { protected static final String EVENT_VERSION = "my-event-version"; protected static final Executor blockingExecutor = command -> { - Thread thread = new Thread(command); + var thread = new Thread(command); thread.setDaemon(true); thread.start(); }; @@ -137,7 +137,7 @@ public class BasicOperation { */ protected <R> void verifyRequest(String expectedJsonFile, R request, String... ignore) throws CoderException { String json = coder.encode(request, true); - String expected = ResourceUtils.getResourceAsString(expectedJsonFile); + var expected = ResourceUtils.getResourceAsString(expectedJsonFile); // strip various items, because they change for each request for (String stripper : ignore) { |