2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actor.test;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertSame;
26 import static org.junit.Assert.assertTrue;
28 import org.junit.Before;
29 import org.junit.Test;
31 public class BasicHttpOperationTest {
32 private static final String ACTOR = "my-actor";
33 private static final String OPERATION = "my-operation";
35 private BasicHttpOperation<String> oper;
39 public void setUp() throws Exception {
40 oper = new BasicHttpOperation<>(ACTOR, OPERATION);
45 public void testBasicHttpOperation() {
46 oper = new BasicHttpOperation<>();
47 assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
48 assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
52 public void testBasicHttpOperationStringString() {
53 assertEquals(ACTOR, oper.actorName);
54 assertEquals(OPERATION, oper.operationName);
58 public void testSetUp() {
59 assertNotNull(oper.client);
60 assertSame(oper.client, oper.factory.get(BasicHttpOperation.MY_CLIENT));
61 assertEquals(200, oper.rawResponse.getStatus());
62 assertNotNull(oper.future);
63 assertEquals(BasicHttpOperation.BASE_URI, oper.client.getBaseUrl());
64 assertNotNull(oper.context);
65 assertNotNull(oper.outcome);
66 assertTrue(oper.operator.isAlive());
70 public void testMakeContext() {
73 assertTrue(oper.enrichment.isEmpty());
75 assertSame(BasicHttpOperation.REQ_ID, oper.event.getRequestId());
76 assertSame(oper.enrichment, oper.event.getAai());
78 assertSame(oper.event, oper.context.getEvent());
80 assertSame(oper.context, oper.params.getContext());
81 assertSame(oper.service, oper.params.getActorService());
82 assertEquals(ACTOR, oper.params.getActor());
83 assertEquals(OPERATION, oper.params.getOperation());
84 assertEquals(BasicHttpOperation.TARGET_ENTITY, oper.params.getTargetEntity());
88 public void testInitOperator() throws Exception {
91 assertTrue(oper.operator.isAlive());
92 assertEquals(ACTOR + "." + OPERATION, oper.operator.getFullName());
93 assertEquals(ACTOR, oper.operator.getActorName());
94 assertEquals(OPERATION, oper.operator.getName());
95 assertSame(oper.client, oper.operator.getClient());
96 assertEquals(BasicHttpOperation.PATH, oper.operator.getPath());
100 public void testMakeEnrichment() {
101 assertTrue(oper.makeEnrichment().isEmpty());