Create A1P actor to talk to A1 PMS.
[policy/models.git] / models-interactions / model-actors / actor.a1p / src / test / java / org / onap / policy / controlloop / actor / a1p / A1pActorTest.java
1 /*-
2  * ONAP
3  * ================================================================================
4  * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.onap.policy.controlloop.actor.a1p;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertSame;
25
26 import java.util.stream.Collectors;
27 import java.util.stream.Stream;
28 import org.junit.Test;
29 import org.onap.policy.controlloop.actor.test.BasicActor;
30 import org.onap.policy.controlloop.actorserviceprovider.Operator;
31
32 public class A1pActorTest extends BasicActor {
33
34     @Test
35     public void testConstructor() {
36         A1pActor prov = new A1pActor();
37         assertEquals(0, prov.getSequenceNumber());
38
39         // verify that it has the operators we expect
40         var expected = Stream.of(A1pOperation.NAME).collect(Collectors.toList());
41         var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
42
43         assertEquals(expected.toString(), actual.toString());
44     }
45
46     @Test
47     public void testActorService() {
48         // verify that it all plugs into the ActorService
49         verifyActorService(A1pActor.NAME, "service.yaml");
50     }
51
52     @Test
53     public void testGetOperator() {
54         A1pActor sp = new A1pActor();
55
56         // should always return the same operator regardless of the name
57         Operator oper = sp.getOperator("unknown");
58         assertNotNull(oper);
59         assertSame(oper, sp.getOperator("another"));
60     }
61 }