2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop;
24 import static org.junit.jupiter.api.Assertions.assertEquals;
25 import static org.junit.jupiter.api.Assertions.assertNotEquals;
26 import static org.junit.jupiter.api.Assertions.assertNotNull;
27 import static org.junit.jupiter.api.Assertions.assertTrue;
29 import java.time.Instant;
30 import org.junit.jupiter.api.Test;
32 class ControlLoopOperationTest {
36 ControlLoopOperation operation = new ControlLoopOperation();
38 assertEquals(operation, (Object) operation);
39 assertNotEquals(operation, (Object) "");
40 assertNotNull(operation);
42 assertNotEquals(0, operation.hashCode());
43 assertTrue(operation.toString().startsWith("ControlLoopOperation"));
45 assertNotNull(operation);
47 operation.setActor("actor");
48 assertEquals("actor", operation.getActor());
50 operation.setOperation("operation");
51 assertEquals("operation", operation.getOperation());
53 Instant now = Instant.now();
54 operation.setStart(now);
55 assertEquals(now, operation.getStart());
56 operation.setEnd(now);
57 assertEquals(now, operation.getEnd());
59 operation.setMessage("message");
60 assertEquals("message", operation.getMessage());
62 operation.setOutcome("outcome");
63 assertEquals("outcome", operation.getOutcome());
65 operation.setSubRequestId("1");
66 assertEquals("1", operation.getSubRequestId());
68 operation.setTarget("target");
69 assertEquals("target", operation.getTarget());
71 assertNotEquals(0, operation.hashCode());
73 ControlLoopOperation operation2 = new ControlLoopOperation(operation);
74 assertEquals(now, operation2.getEnd());
76 assertEquals(operation, operation2);
78 operation2.setActor("foo");
79 assertNotEquals(operation, operation2);
81 operation = new ControlLoopOperation(null);
82 assertNotNull(operation.getStart());
84 assertNotEquals(operation, operation2);
86 assertTrue(operation.toMessage().startsWith("actor="));
87 assertTrue(operation.toHistory().startsWith("actor="));