summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.guard/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.guard/src/test')
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java270
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java105
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java116
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorTest.java48
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardConfigTest.java99
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardParamsTest.java96
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json10
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/resources/makeReqStd.json13
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/resources/service.yaml35
9 files changed, 0 insertions, 792 deletions
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java
deleted file mode 100644
index 9b13fa558..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Consumer;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
-import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.models.decisions.concepts.DecisionRequest;
-import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.simulators.XacmlSimulatorJaxRs;
-
-public class DecisionOperationTest extends BasicHttpOperation {
-
- @Mock
- private Consumer<OperationOutcome> started;
- @Mock
- private Consumer<OperationOutcome> completed;
-
- private GuardConfig guardConfig;
- private DecisionOperation oper;
-
- /**
- * Starts the simulator.
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- org.onap.policy.simulators.Util.buildGuardSim();
-
- BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("policy/pdpx/v1/")
- .hostname("localhost").managed(true).port(org.onap.policy.simulators.Util.XACMLSIM_SERVER_PORT)
- .build();
- HttpClientFactoryInstance.getClientFactory().build(clientParams);
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- HttpClientFactoryInstance.getClientFactory().destroy();
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- }
-
- /**
- * Sets up.
- */
- @Before
- public void setUp() throws Exception {
- super.setUpBasic();
-
- guardConfig = mock(GuardConfig.class);
- when(guardConfig.makeRequest()).thenAnswer(args -> {
- DecisionRequest req = new DecisionRequest();
- req.setAction("guard");
- req.setOnapComponent("my-onap-component");
- req.setOnapInstance("my-onap-instance");
- req.setOnapName("my-onap-name");
- return req;
- });
-
- config = guardConfig;
- initConfig();
-
- params = params.toBuilder().startCallback(started).completeCallback(completed).build();
-
- oper = new DecisionOperation(params, config);
- }
-
- /**
- * Tests "success" case with simulator.
- */
- @Test
- public void testSuccess() throws Exception {
- GuardParams opParams = GuardParams.builder().clientName(MY_CLIENT).path("decision").build();
- config = new GuardConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
-
- params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
- oper = new DecisionOperation(params, config);
-
- outcome = oper.start().get();
- assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof DecisionResponse);
- }
-
- /**
- * Tests "failure" case with simulator.
- */
- @Test
- public void testFailure() throws Exception {
- GuardParams opParams = GuardParams.builder().clientName(MY_CLIENT).path("decision").build();
- config = new GuardConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
-
- params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor)
- .payload(Map.of("clname", XacmlSimulatorJaxRs.DENY_CLNAME)).build();
- oper = new DecisionOperation(params, config);
-
- outcome = oper.start().get();
- assertEquals(OperationResult.FAILURE, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof DecisionResponse);
- }
-
- @Test
- public void testConstructor() {
- assertEquals(DEFAULT_ACTOR, oper.getActorName());
- assertEquals(DEFAULT_OPERATION, oper.getName());
- }
-
- @Test
- public void testGetPropertyNames() {
- assertThat(oper.getPropertyNames()).isEmpty();
- }
-
- @Test
- public void testStartOperationAsync() throws Exception {
- CompletableFuture<OperationOutcome> future2 = oper.start();
- executor.runAll(100);
- assertFalse(future2.isDone());
-
- DecisionResponse resp = new DecisionResponse();
- resp.setStatus(DecisionOperation.PERMIT);
- when(rawResponse.readEntity(String.class)).thenReturn(Util.translate("", resp, String.class));
-
- verify(client).post(callbackCaptor.capture(), any(), requestCaptor.capture(), any());
- callbackCaptor.getValue().completed(rawResponse);
-
- executor.runAll(100);
- assertTrue(future2.isDone());
-
- outcome = future2.get();
- assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertEquals(resp, outcome.getResponse());
-
- assertNotNull(oper.getSubRequestId());
- assertEquals(oper.getSubRequestId(), future2.get().getSubRequestId());
- }
-
- /**
- * Tests startOperationAsync() when the guard is disabled.
- */
- @Test
- public void testStartOperationAsyncDisabled() throws Exception {
- // indicate that it's disabled
- when(guardConfig.isDisabled()).thenReturn(true);
-
- CompletableFuture<OperationOutcome> future2 = oper.start();
- executor.runAll(100);
-
- verify(client, never()).post(any(), any(), any(), any());
-
- // should already be done
- assertTrue(future2.isDone());
-
- outcome = future2.get();
- assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertNull(outcome.getResponse());
-
- // ensure callbacks were invoked
- verify(started).accept(any());
- verify(completed).accept(any());
- }
-
- @Test
- public void testMakeRequest() throws CoderException {
- oper.generateSubRequestId(2);
-
- verifyPayload("makeReqStd.json", makePayload());
- verifyPayload("makeReqDefault.json", new TreeMap<>());
-
- // null payload - start with fresh parameters and operation
- params = params.toBuilder().payload(null).build();
- oper = new DecisionOperation(params, config);
- assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest());
- }
-
- private void verifyPayload(String expectedJsonFile, Map<String, Object> payload) throws CoderException {
- params.getPayload().clear();
- params.getPayload().putAll(payload);
-
- DecisionRequest request = oper.makeRequest();
-
- assertEquals("guard", request.getAction());
- assertEquals("my-onap-component", request.getOnapComponent());
- assertEquals("my-onap-instance", request.getOnapInstance());
- assertEquals("my-onap-name", request.getOnapName());
- assertNotNull(request.getRequestId());
- assertEquals(Map.of("guard", payload), request.getResource());
-
- verifyRequest(expectedJsonFile, request, "requestId");
- }
-
- @Test
- public void testPostProcessResponse() {
- DecisionResponse response = new DecisionResponse();
-
- // null status
- response.setStatus(null);
- verifyOutcome(response, OperationResult.FAILURE, "response contains no status");
-
- // permit, mixed case
- response.setStatus("peRmit");
- verifyOutcome(response, OperationResult.SUCCESS, "peRmit");
-
- // indeterminate, mixed case
- response.setStatus("inDETerminate");
- verifyOutcome(response, OperationResult.SUCCESS, "inDETerminate");
-
- // deny, mixed case
- response.setStatus("deNY");
- verifyOutcome(response, OperationResult.FAILURE, "deNY");
-
- // unknown status
- response.setStatus("unknown");
- verifyOutcome(response, OperationResult.FAILURE, "unknown");
- }
-
- private void verifyOutcome(DecisionResponse response, OperationResult expectedResult, String expectedMessage) {
- oper.postProcessResponse(outcome, BASE_URI, rawResponse, response);
- assertEquals(expectedResult, outcome.getResult());
- assertEquals(expectedMessage, outcome.getMessage());
- assertSame(response, outcome.getResponse());
- }
-
- @Override
- protected Map<String, Object> makePayload() {
- return new TreeMap<>(Map.of("hello", "world", "abc", "123"));
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java
deleted file mode 100644
index 76b784101..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class DecisionOperatorTest {
- private static final String ACTOR = "my-actor";
- private static final String OPERATION = "my-name";
- private static final String CLIENT = "my-client";
- private static final String PATH = "my-path";
- private static final int TIMEOUT = 10;
- private static final String ONAP_NAME = "onap-nap";
- private static final String ONAP_COMP = "onap-component";
- private static final String ONAP_INST = "onap-instance";
- private static final String MY_ACTION = "my-action";
-
- @Mock
- private HttpClient client;
-
- @Mock
- private HttpClientFactory factory;
-
-
- private DecisionOperator oper;
-
- /**
- * Initializes fields, including {@link #oper}, and resets the static fields used by
- * the REST server.
- */
- @Before
- public void setUp() {
- when(factory.get(CLIENT)).thenReturn(client);
-
- oper = new MyOperator();
-
- GuardParams params = GuardParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
- .action(MY_ACTION).clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
- oper.configure(paramMap);
-
- assertTrue(oper.makeConfiguration(paramMap) instanceof GuardConfig);
- }
-
- @Test
- public void testConstructor() {
- assertEquals(ACTOR, oper.getActorName());
- assertEquals(OPERATION, oper.getName());
- assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
- }
-
- @Test
- public void testDoConfigure_testGetters() {
- assertTrue(oper.getCurrentConfig() instanceof GuardConfig);
-
- // test invalid parameters
- Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, GuardParams.builder().build());
- assertThatThrownBy(() -> oper.configure(paramMap2)).isInstanceOf(ParameterValidationRuntimeException.class);
- }
-
-
- private class MyOperator extends DecisionOperator {
- public MyOperator() {
- super(ACTOR, OPERATION, null);
- }
-
- @Override
- protected HttpClientFactory getClientFactory() {
- return factory;
- }
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java
deleted file mode 100644
index 71c75b8cf..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2020 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
-
-public class GuardActorParamsTest {
- private static final String CONTAINER = "my-container";
- private static final String CLIENT = "my-client";
- private static final int TIMEOUT = 10;
- private static final String ONAP_NAME = "onap-nap";
- private static final String ONAP_COMP = "onap-component";
- private static final String ONAP_INST = "onap-instance";
- private static final String MY_ACTION = "my-action";
-
- private static final String PATH1 = "path #1";
- private static final String PATH2 = "path #2";
- private static final String URI1 = "uri #1";
- private static final String URI2 = "uri #2";
-
- private Map<String, Map<String, Object>> operations;
- private GuardActorParams params;
-
- /**
- * Initializes {@link #operations} with two items and {@link params} with a fully
- * populated object.
- */
- @Before
- public void setUp() {
- operations = new TreeMap<>();
- operations.put(PATH1, Map.of("path", URI1));
- operations.put(PATH2, Map.of("path", URI2));
-
- params = makeGuardActorParams();
- }
-
- @Test
- public void testIsDisabled() {
- // disabled by default
- assertFalse(params.isDisabled());
- }
-
- @Test
- public void testValidate() {
- assertTrue(params.validate(CONTAINER).isValid());
-
- // only a few fields are required
- GuardActorParams sparse = Util.translate(CONTAINER, Map.of(ActorParams.OPERATIONS_FIELD, operations),
- GuardActorParams.class);
- assertTrue(sparse.validate(CONTAINER).isValid());
-
- assertEquals(GuardActorParams.DEFAULT_ACTION, sparse.getAction());
-
- // check fields from superclass
- testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
- testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1));
- }
-
- private void testValidateField(String fieldName, String expected, Consumer<GuardActorParams> makeInvalid) {
-
- // original params should be valid
- ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
-
- // make invalid params
- GuardActorParams params2 = makeGuardActorParams();
- makeInvalid.accept(params2);
- result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
- assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
- }
-
- private GuardActorParams makeGuardActorParams() {
- GuardActorParams params2 = new GuardActorParams();
- params2.setClientName(CLIENT);
- params2.setTimeoutSec(TIMEOUT);
- params2.setOperations(operations);
-
- params2.setOnapName(ONAP_NAME);
- params2.setOnapComponent(ONAP_COMP);
- params2.setOnapInstance(ONAP_INST);
- params2.setAction(MY_ACTION);
-
- return params2;
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorTest.java
deleted file mode 100644
index e5c3f139d..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2020 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.stream.Collectors;
-import org.junit.Test;
-import org.onap.policy.controlloop.actor.test.BasicActor;
-
-public class GuardActorTest extends BasicActor {
-
- @Test
- public void test() {
- final GuardActor prov = new GuardActor();
-
- // verify that it has the operators we expect
- var expected = Arrays.asList(DecisionOperation.NAME).stream().sorted().collect(Collectors.toList());
- var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
-
- assertEquals(expected.toString(), actual.toString());
-
- // verify that it all plugs into the ActorService
- verifyActorService(GuardActor.NAME, "service.yaml");
-
- assertTrue(prov.getOperator(DecisionOperation.NAME) instanceof DecisionOperator);
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardConfigTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardConfigTest.java
deleted file mode 100644
index 2d929d544..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardConfigTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.Executor;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.models.decisions.concepts.DecisionRequest;
-
-@RunWith(MockitoJUnitRunner.class)
-public class GuardConfigTest {
- private static final String MY_CLIENT = "my-client";
- private static final String PATH = "my-path";
- private static final int TIMEOUT = 10;
- private static final String ONAP_NAME = "onap-nap";
- private static final String ONAP_COMP = "onap-component";
- private static final String ONAP_INST = "onap-instance";
- private static final String MY_ACTION = "my-action";
-
- @Mock
- private HttpClient client;
- @Mock
- private HttpClientFactory factory;
- @Mock
- private Executor executor;
-
- private GuardParams params;
- private GuardConfig config;
-
- /**
- * Sets up.
- */
- @Before
- public void setUp() {
- when(factory.get(MY_CLIENT)).thenReturn(client);
-
- params = GuardParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
- .action(MY_ACTION).clientName(MY_CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- config = new GuardConfig(executor, params, factory);
- }
-
- @Test
- public void test() {
- DecisionRequest expected = new DecisionRequest();
- expected.setOnapComponent(ONAP_COMP);
- expected.setOnapInstance(ONAP_INST);
- expected.setOnapName(ONAP_NAME);
- expected.setAction(MY_ACTION);
-
- DecisionRequest actual = config.makeRequest();
- assertEquals(expected, actual);
-
- // check value from superclass
- assertSame(executor, config.getBlockingExecutor());
- assertSame(client, config.getClient());
-
- // repeat, with minimal parameters
- params = GuardParams.builder().clientName(MY_CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- config = new GuardConfig(executor, params, factory);
- assertFalse(config.isDisabled());
-
- actual = config.makeRequest();
- assertEquals(new DecisionRequest(), actual);
-
- // try with disabled=true
- params = params.toBuilder().disabled(true).build();
- config = new GuardConfig(executor, params, factory);
- assertTrue(config.isDisabled());
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardParamsTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardParamsTest.java
deleted file mode 100644
index 102dcbb08..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardParamsTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2020 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.controlloop.actor.guard;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actor.guard.GuardParams.GuardParamsBuilder;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams.HttpParamsBuilder;
-
-public class GuardParamsTest {
- private static final String CONTAINER = "my-container";
- private static final String CLIENT = "my-client";
- private static final String PATH = "my-path";
- private static final int TIMEOUT = 10;
- private static final String ONAP_NAME = "onap-nap";
- private static final String ONAP_COMP = "onap-component";
- private static final String ONAP_INST = "onap-instance";
- private static final String MY_ACTION = "my-action";
-
- private GuardParams params;
-
- @Before
- public void setUp() {
- params = GuardParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
- .action(MY_ACTION).clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- }
-
- @Test
- public void testIsDisabled() {
- // disabled by default
- assertFalse(params.isDisabled());
- }
-
- @Test
- public void testValidate() {
- assertTrue(params.validate(CONTAINER).isValid());
-
- testValidateField("onapName", "null", bldr -> bldr.onapName(null));
- testValidateField("onapComponent", "null", bldr -> bldr.onapComponent(null));
- testValidateField("onapInstance", "null", bldr -> bldr.onapInstance(null));
- testValidateField("action", "null", bldr -> bldr.action(null));
-
- // validate one of the superclass fields
- testValidateField("clientName", "null", bldr -> bldr.clientName(null));
- }
-
- @Test
- public void testBuilder_testToBuilder() {
- assertEquals(CLIENT, params.getClientName());
-
- assertEquals(ONAP_NAME, params.getOnapName());
- assertEquals(ONAP_COMP, params.getOnapComponent());
- assertEquals(ONAP_INST, params.getOnapInstance());
- assertEquals(MY_ACTION, params.getAction());
-
- assertEquals(params, params.toBuilder().build());
- }
-
- private void testValidateField(String fieldName, String expected,
- @SuppressWarnings("rawtypes") Function<GuardParamsBuilder, HttpParamsBuilder> makeInvalid) {
-
- // original params should be valid
- ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
-
- // make invalid params
- result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
- assertThat(result.getResult()).contains(fieldName).contains(expected);
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json b/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json
deleted file mode 100644
index a08f13f43..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "ONAPName": "my-onap-name",
- "ONAPComponent": "my-onap-component",
- "ONAPInstance": "my-onap-instance",
- "requestId": "abcdefghi",
- "action": "guard",
- "resource": {
- "guard": {}
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqStd.json b/models-interactions/model-actors/actor.guard/src/test/resources/makeReqStd.json
deleted file mode 100644
index fd1f4c716..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqStd.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "ONAPName": "my-onap-name",
- "ONAPComponent": "my-onap-component",
- "ONAPInstance": "my-onap-instance",
- "requestId": "abcdefghi",
- "action": "guard",
- "resource": {
- "guard": {
- "abc": "123",
- "hello": "world"
- }
- }
-}
diff --git a/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml b/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml
deleted file mode 100644
index 998928d44..000000000
--- a/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# ============LICENSE_START======================================================
-# ONAP
-# ===============================================================================
-# Copyright (C) 2020 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.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END========================================================
-#
-httpClients:
-- clientName: my-client
- hostname: localhost
- port: 80
- basePath: base-url
- managed: true
-actors:
- GUARD:
- clientName: my-client
- onapName: my-onap-name
- onapComponent: my-onap-component
- onapInstance: my-onap-instance
- action: guard
- operations:
- Decision:
- path: decide \ No newline at end of file