aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java')
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java94
1 files changed, 0 insertions, 94 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java
deleted file mode 100644
index b9028d462..000000000
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicOperator.java
+++ /dev/null
@@ -1,94 +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.sdnc;
-
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.UUID;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-
-/**
- * Superclass for various operator tests.
- */
-public abstract class BasicOperator {
- protected static final UUID REQ_ID = UUID.randomUUID();
- protected static final String ACTOR = "my-actor";
-
- protected Map<String, String> enrichment;
- protected VirtualControlLoopEvent event;
- protected ControlLoopEventContext context;
-
- /**
- * Pretty-prints a request and verifies that the result matches the expected JSON.
- *
- * @param <T> request type
- * @param expectedJsonFile name of the file containing the expected JSON
- * @param request request to verify
- * @throws CoderException if the request cannot be pretty-printed
- */
- protected <T> void verifyRequest(String expectedJsonFile, T request) throws CoderException {
- String json = new StandardCoder().encode(request, true);
- String expected = ResourceUtils.getResourceAsString(expectedJsonFile);
-
- // strip request id, because it changes each time
- final String stripper = "svc-request-id[^,]*";
- json = json.replaceFirst(stripper, "").trim();
- expected = expected.replaceFirst(stripper, "").trim();
-
- assertEquals(expected, json);
- }
-
- /**
- * Verifies that an exception is thrown if a field is missing from the enrichment
- * data.
- *
- * @param oper operator to construct the request
- * @param fieldName name of the field to be removed from the enrichment data
- * @param expectedText text expected in the exception message
- */
- protected void verifyMissing(SdncOperator oper, String fieldName, String expectedText) {
- makeContext();
- enrichment.remove(fieldName);
-
- assertThatIllegalArgumentException().isThrownBy(() -> oper.constructRequest(context))
- .withMessageContaining("missing").withMessageContaining(expectedText);
- }
-
- protected void makeContext() {
- // need a mutable map, so make a copy
- enrichment = new TreeMap<>(makeEnrichment());
-
- event = new VirtualControlLoopEvent();
- event.setRequestId(REQ_ID);
- event.setAai(enrichment);
-
- context = new ControlLoopEventContext(event);
- }
-
- protected abstract Map<String, String> makeEnrichment();
-}