X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-interactions%2Fmodel-actors%2Factor.appclcm%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontrolloop%2Factor%2Fappclcm%2FAppcLcmOperationTest.java;h=e933621e9906af40f2fc3452906b0b4f0546cd95;hb=49f07db935d114b72a44e446867b16262dd552aa;hp=b9999f4a1f4cb396a2caa1d5ad306a665f87230a;hpb=1dd41890f83702d47c5a957493046433989ef36c;p=policy%2Fmodels.git diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java index b9999f4a1..e933621e9 100644 --- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java +++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.controlloop.actor.appclcm; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -30,7 +31,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,9 +41,11 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.policy.appclcm.AppcLcmBody; import org.onap.policy.appclcm.AppcLcmCommonHeader; -import org.onap.policy.appclcm.AppcLcmDmaapWrapper; +import org.onap.policy.appclcm.AppcLcmMessageWrapper; import org.onap.policy.appclcm.AppcLcmOutput; import org.onap.policy.appclcm.AppcLcmResponseStatus; import org.onap.policy.common.endpoints.event.comm.TopicSink; @@ -62,7 +64,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp import org.onap.policy.simulators.AppcLcmTopicServer; import org.onap.policy.simulators.TopicServer; -public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation { +@RunWith(MockitoJUnitRunner.class) +public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation { private static final String EXPECTED_EXCEPTION = "expected exception"; private static final String PAYLOAD_KEY1 = "key-A"; @@ -72,7 +75,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation makeServer(TopicSink sink, TopicSource source) { + protected TopicServer makeServer(TopicSink sink, TopicSource source) { return new AppcLcmTopicServer(sink, source); } @@ -123,8 +126,9 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation oper.makeRequest(1)) + .withMessageContaining("missing target entity"); + } + @Test public void testConvertPayload() { // only builds a payload for ConfigModify @@ -167,7 +183,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation oper.makeRequest(2)).isInstanceOf(NullPointerException.class); + assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest(2)) + .withMessageContaining("Cannot convert payload"); } @Test public void testGetExpectedKeyValues() { oper.generateSubRequestId(2); - AppcLcmDmaapWrapper request = oper.makeRequest(2); - assertEquals(Arrays.asList(request.getBody().getInput().getCommonHeader().getSubRequestId()), + AppcLcmMessageWrapper request = oper.makeRequest(2); + assertEquals(List.of(request.getBody().getInput().getCommonHeader().getSubRequestId()), oper.getExpectedKeyValues(50, request)); } @@ -326,8 +344,8 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation