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.actor.vfc;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertSame;
27 import static org.junit.Assert.assertTrue;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mockito;
32 import org.onap.policy.vfc.VfcResponse;
33 import org.onap.policy.vfc.VfcResponseDescriptor;
35 public class VfcOperationTest extends BasicVfcOperation {
37 private VfcOperation oper;
44 public void setUp() throws Exception {
49 oper = new VfcOperation(params, config) {};
53 public void testConstructor() {
54 assertEquals(DEFAULT_ACTOR, oper.getActorName());
55 assertEquals(DEFAULT_OPERATION, oper.getName());
56 assertSame(config, oper.getConfig());
57 assertTrue(oper.isUsePolling());
61 public void testResetPollCount() {
62 oper.resetPollCount();
63 assertEquals(0, oper.getPollCount());
67 public void testGetRequestState() {
68 VfcResponse mockResponse = Mockito.mock(VfcResponse.class);
69 Mockito.when(mockResponse.getResponseDescriptor()).thenReturn(null);
70 assertNull(oper.getRequestState(mockResponse));
72 VfcResponseDescriptor mockDescriptor = Mockito.mock(VfcResponseDescriptor.class);
73 Mockito.when(mockResponse.getResponseDescriptor()).thenReturn(mockDescriptor);
75 // TODO use actual request state value
76 Mockito.when(mockDescriptor.getStatus()).thenReturn("COMPLETE");
77 assertNotNull(oper.getRequestState(mockResponse));
81 public void testIsSuccess() {
82 assertTrue(oper.isSuccess(rawResponse, response));