2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 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.Assert.assertEquals;
25 import static org.junit.Assert.assertNotEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import java.time.Instant;
30 import org.junit.Test;
32 public class ControlLoopOperationTest {
36 ControlLoopOperation operation = new ControlLoopOperation();
39 * Disabling sonar to test equals().
41 assertEquals(operation, operation); // NOSONAR
42 assertNotEquals(operation, ""); // NOSONAR
43 assertNotEquals(operation, null);
45 assertNotEquals(0, operation.hashCode());
46 assertTrue(operation.toString().startsWith("ControlLoopOperation"));
48 assertNotNull(operation);
50 operation.setActor("actor");
51 assertEquals("actor", operation.getActor());
53 operation.setOperation("operation");
54 assertEquals("operation", operation.getOperation());
56 Instant now = Instant.now();
57 operation.setStart(now);
58 assertEquals(now, operation.getStart());
59 operation.setEnd(now);
60 assertEquals(now, operation.getEnd());
62 operation.setMessage("message");
63 assertEquals("message", operation.getMessage());
65 operation.setOutcome("outcome");
66 assertEquals("outcome", operation.getOutcome());
68 operation.setSubRequestId("1");
69 assertEquals("1", operation.getSubRequestId());
71 operation.setTarget("target");
72 assertEquals("target", operation.getTarget());
74 assertNotEquals(0, operation.hashCode());
76 ControlLoopOperation operation2 = new ControlLoopOperation(operation);
77 assertEquals(now, operation2.getEnd());
79 assertEquals(operation, operation2);
81 operation2.setActor("foo");
82 assertNotEquals(operation, operation2);
84 operation = new ControlLoopOperation(null);
85 assertNotNull(operation.getStart());
87 assertNotEquals(operation, operation2);
89 assertTrue(operation.toMessage().startsWith("actor="));
90 assertTrue(operation.toHistory().startsWith("actor="));