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.actorserviceprovider;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertTrue;
29 import java.time.Instant;
30 import org.junit.Before;
31 import org.junit.Test;
33 public class CallbackManagerTest {
35 private CallbackManager mgr;
39 mgr = new CallbackManager();
43 public void testCanStart_testGetStartTime() {
44 // null until canXxx() is called
45 assertNull(mgr.getStartTime());
47 assertTrue(mgr.canStart());
49 Instant time = mgr.getStartTime();
51 assertNull(mgr.getEndTime());
54 assertFalse(mgr.canStart());
55 assertFalse(mgr.canStart());
57 assertEquals(time, mgr.getStartTime());
61 public void testCanEnd_testGetEndTime() {
62 // null until canXxx() is called
63 assertNull(mgr.getEndTime());
64 assertNull(mgr.getEndTime());
66 assertTrue(mgr.canEnd());
68 Instant time = mgr.getEndTime();
70 assertNull(mgr.getStartTime());
73 assertFalse(mgr.canEnd());
74 assertFalse(mgr.canEnd());
76 assertEquals(time, mgr.getEndTime());
80 public void testRun() {
83 assertNotNull(mgr.getStartTime());
84 assertNotNull(mgr.getEndTime());
86 assertFalse(mgr.canStart());
87 assertFalse(mgr.canEnd());