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.m2.base;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
27 import org.junit.Test;
28 import org.onap.policy.controlloop.ControlLoopEvent;
29 import org.onap.policy.controlloop.ControlLoopException;
30 import org.onap.policy.controlloop.policy.Policy;
31 import org.onap.policy.controlloop.policy.PolicyResult;
33 public class ActorOperationTest {
35 public static final String ACTOR_NAME = "test";
36 public static final String STATE = "COMPLETE";
38 public static class TestOperation implements Operation {
39 private static final long serialVersionUID = 1L;
42 public Object getRequest() throws ControlLoopException {
47 public Policy getPolicy() {
52 public String getState() {
57 public int getAttempt() {
62 public PolicyResult getResult() {
63 return PolicyResult.SUCCESS;
67 public String getMessage() {
72 public void incomingMessage(Object object) {
77 public void timeout() {
83 public static class TestActor implements Actor {
86 public String getName() {
91 public Operation createOperation(Transaction transaction, Policy policy, ControlLoopEvent onset, int attempt) {
92 return new TestOperation();
98 public void getNameTest() {
99 Actor actor = new TestActor();
100 assertEquals(ACTOR_NAME, actor.getName());
104 public void testOperation() throws ControlLoopException {
105 Actor actor = new TestActor();
106 Operation operation = actor.createOperation(null, null, null, 0);
107 assertNotNull(operation);
108 assertEquals("request", operation.getRequest());
109 assertNull(operation.getPolicy());
110 assertEquals(STATE, operation.getState());
111 assertEquals(0, operation.getAttempt());
112 assertEquals(PolicyResult.SUCCESS, operation.getResult());
113 assertEquals("success", operation.getMessage());