aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-http/src/test
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-06-21 13:53:10 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-06-23 09:06:41 +0000
commitf4c3fdc23752733a4c4f670a1cddb460747fd738 (patch)
treec17d4c94deef7bd07dd9d6235374b02bd6a3c322 /participant/participant-impl/participant-impl-http/src/test
parent4d6cd92e9e18f1702e2092ba881db0d3d9ffc37e (diff)
Remove Thread support in http participant
Due the Thread support in Intermediary, Thread support in http participant could be removed. Issue-ID: POLICY-4736 Change-Id: I2d947ab9f62b626b037c593f326e2d0af9bc7a9e Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-http/src/test')
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java141
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java14
2 files changed, 68 insertions, 87 deletions
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
index 12b8ee4c3..f0f991302 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java
@@ -21,11 +21,9 @@
package org.onap.policy.clamp.acm.participant.http.handler;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,52 +48,50 @@ class AcElementHandlerTest {
"org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
@Test
- void testUndeploy() throws IOException {
+ void testUndeploy() {
var instanceId = commonTestData.getAutomationCompositionId();
var element = commonTestData.getAutomationCompositionElement();
var acElementId = element.getId();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
- automationCompositionElementHandler.undeploy(instanceId, acElementId);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
- DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
- }
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
+ automationCompositionElementHandler.undeploy(instanceId, acElementId);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "");
+
}
@Test
- void testDeployConstraintViolations() throws IOException, PfModelException {
+ void testDeployConstraintViolations() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var element = commonTestData.getAutomationCompositionElement();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- Map<String, Object> map = new HashMap<>();
- automationCompositionElementHandler.deploy(instanceId, element, map);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
- "Constraint violations in the config request");
- }
+ Map<String, Object> map = new HashMap<>();
+ automationCompositionElementHandler.deploy(instanceId, element, map);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Constraint violations in the config request");
}
@Test
- void testDeployError() throws IOException, PfModelException {
+ void testDeployError() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var element = commonTestData.getAutomationCompositionElement();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("httpHeaders", 1);
+ automationCompositionElementHandler.deploy(instanceId, element, map);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Error extracting ConfigRequest ");
- Map<String, Object> map = new HashMap<>();
- map.put("httpHeaders", 1);
- automationCompositionElementHandler.deploy(instanceId, element, map);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Error extracting ConfigRequest ");
- }
}
@Test
@@ -109,102 +105,95 @@ class AcElementHandlerTest {
var acHttpClient = mock(AcHttpClient.class);
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, acHttpClient)) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, acHttpClient);
- automationCompositionElementHandler.deploy(instanceId, element, map);
- verify(acHttpClient).run(any(ConfigRequest.class), anyMap());
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
- }
+ automationCompositionElementHandler.deploy(instanceId, element, map);
+ verify(acHttpClient).run(any(ConfigRequest.class));
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
}
@Test
- void testUpdate() throws Exception {
+ void testUpdate() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var element = commonTestData.getAutomationCompositionElement();
var acElementId = element.getId();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.update(instanceId, element, Map.of());
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Update not supported");
- }
+ automationCompositionElementHandler.update(instanceId, element, Map.of());
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Update not supported");
}
@Test
- void testLock() throws Exception {
+ void testLock() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var acElementId = UUID.randomUUID();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.lock(instanceId, acElementId);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
- LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
- }
+ automationCompositionElementHandler.lock(instanceId, acElementId);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
+ LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
}
@Test
- void testUnlock() throws Exception {
+ void testUnlock() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var acElementId = UUID.randomUUID();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.unlock(instanceId, acElementId);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
- LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
- }
+ automationCompositionElementHandler.unlock(instanceId, acElementId);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId, null,
+ LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
}
@Test
- void testDelete() throws Exception {
+ void testDelete() throws PfModelException {
var instanceId = commonTestData.getAutomationCompositionId();
var acElementId = UUID.randomUUID();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.delete(instanceId, acElementId);
- verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
- DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
- }
+ automationCompositionElementHandler.delete(instanceId, acElementId);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, acElementId,
+ DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
}
@Test
- void testPrime() throws Exception {
+ void testPrime() throws PfModelException {
var compositionId = UUID.randomUUID();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.prime(compositionId, List.of());
- verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED,
- StateChangeResult.NO_ERROR, "Primed");
- }
+ automationCompositionElementHandler.prime(compositionId, List.of());
+ verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED,
+ StateChangeResult.NO_ERROR, "Primed");
}
@Test
- void testDeprime() throws Exception {
+ void testDeprime() throws PfModelException {
var compositionId = UUID.randomUUID();
var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
- try (var automationCompositionElementHandler =
- new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class))) {
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
- automationCompositionElementHandler.deprime(compositionId);
- verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
- StateChangeResult.NO_ERROR, "Deprimed");
- }
+ automationCompositionElementHandler.deprime(compositionId);
+ verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
+ StateChangeResult.NO_ERROR, "Deprimed");
}
}
diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
index 56170eb3e..ebeba5297 100644
--- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
+++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/webclient/AcHttpClientTest.java
@@ -21,13 +21,9 @@
package org.onap.policy.clamp.acm.participant.http.webclient;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.io.IOException;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -37,7 +33,6 @@ import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData;
import org.onap.policy.clamp.acm.participant.http.utils.MockServerRest;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@@ -73,14 +68,13 @@ class AcHttpClientTest {
void test_validRequest() {
// Add valid rest requests POST, GET
var configurationEntity = commonTestData.getConfigurationEntity();
- Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
var headers = commonTestData.getHeaders();
var configRequest =
new ConfigRequest(MOCK_URL + ":" + mockServerPort, headers, List.of(configurationEntity), 10);
var client = new AcHttpClient();
- assertDoesNotThrow(() -> client.run(configRequest, responseMap));
+ var responseMap = client.run(configRequest);
assertThat(responseMap).hasSize(2).containsKey(commonTestData.restParamsWithGet().getRestRequestId());
var restResponseMap = responseMap.get(commonTestData.restParamsWithGet().getRestRequestId());
@@ -91,14 +85,13 @@ class AcHttpClientTest {
void test_invalidRequest() {
// Add rest requests Invalid POST, Valid GET
var configurationEntity = commonTestData.getInvalidConfigurationEntity();
- Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
var headers = commonTestData.getHeaders();
var configRequest =
new ConfigRequest(MOCK_URL + ":" + mockServerPort, headers, List.of(configurationEntity), 10);
var client = new AcHttpClient();
- assertDoesNotThrow(() -> client.run(configRequest, responseMap));
+ var responseMap = client.run(configRequest);
assertThat(responseMap).hasSize(2).containsKey(commonTestData.restParamsWithGet().getRestRequestId());
var response = responseMap.get(commonTestData.restParamsWithInvalidPost().getRestRequestId());
assertThat(response.getKey()).isEqualTo(404);
@@ -108,14 +101,13 @@ class AcHttpClientTest {
void test_WrongUrl() {
// Add rest requests Invalid URL
var configurationEntity = commonTestData.getInvalidConfigurationEntity();
- Map<ToscaConceptIdentifier, Pair<Integer, String>> responseMap = new HashMap<>();
var headers = commonTestData.getHeaders();
var configRequest =
new ConfigRequest(WRONG_URL + ":" + mockServerPort, headers, List.of(configurationEntity), 10);
var client = new AcHttpClient();
- assertDoesNotThrow(() -> client.run(configRequest, responseMap));
+ var responseMap = client.run(configRequest);
assertThat(responseMap).hasSize(2).containsKey(commonTestData.restParamsWithGet().getRestRequestId());
var response = responseMap.get(commonTestData.restParamsWithInvalidPost().getRestRequestId());
assertThat(response.getKey()).isEqualTo(404);