2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 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.drools.apps.controller.usecases.step;
23 import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertSame;
27 import static org.junit.Assert.assertTrue;
28 import static org.mockito.Mockito.when;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.onap.policy.controlloop.VirtualControlLoopEvent;
36 import org.onap.policy.controlloop.actorserviceprovider.Operation;
37 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
38 import org.onap.policy.controlloop.eventmanager.StepContext;
39 import org.onap.policy.drools.apps.controller.usecases.GetTargetEntityOperation2;
40 import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
42 @RunWith(MockitoJUnitRunner.class)
43 public class GetTargetEntityStep2Test {
45 private ControlLoopOperationParams params;
47 private StepContext stepContext;
49 private VirtualControlLoopEvent event;
52 private GetTargetEntityStep2 step;
59 when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder());
61 master = new Step2(stepContext, params, event);
62 step = new GetTargetEntityStep2(master);
66 public void testConstructor() {
67 assertEquals(UsecasesConstants.GET_TARGET_ENTITY_ACTOR, step.getActorName());
68 assertEquals(UsecasesConstants.GET_TARGET_ENTITY_OPERATION, step.getOperationName());
69 assertSame(stepContext, step.stepContext);
70 assertSame(event, step.event);
74 public void testBuildOperation() {
75 Operation oper = step.buildOperation();
76 assertTrue(oper instanceof GetTargetEntityOperation2);
80 public void testStart() {
81 assertThatIllegalStateException().isThrownBy(() -> step.start(200))
82 .withMessage("step has not been initialized");
85 assertFalse(step.start(100));