2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2023 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.actor.sdnc;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
28 import java.util.Collections;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.junit.MockitoJUnitRunner;
33 import org.onap.policy.sdnc.SdncHealRequest;
34 import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
35 import org.onap.policy.sdnc.SdncRequest;
37 @RunWith(MockitoJUnitRunner.class)
38 public class SdncOperationTest extends BasicSdncOperation {
40 private static final String MY_URI = "my-uri";
42 private SdncRequest request;
43 private SdncOperation oper;
50 public void setUp() throws Exception {
53 request = new SdncRequest();
54 request.setUrl(MY_URI);
56 SdncHealRequest healRequest = new SdncHealRequest();
57 request.setHealRequest(healRequest);
59 SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
60 healRequest.setRequestHeaderInfo(headerInfo);
61 headerInfo.setSvcRequestId(SUB_REQ_ID);
63 oper = new SdncOperation(params, config, Collections.emptyList()) {
65 protected SdncRequest makeRequest(int attempt) {
72 public void testSdncOperator() {
73 assertEquals(DEFAULT_ACTOR, oper.getActorName());
74 assertEquals(DEFAULT_OPERATION, oper.getName());
78 public void testStartOperationAsync_testStartRequestAsync() throws Exception {
79 verifyOperation(oper);
83 public void testIsSuccess() {
85 response.getResponseOutput().setResponseCode("200");
86 assertTrue(oper.isSuccess(null, response));
89 response.getResponseOutput().setResponseCode("555");
90 assertFalse(oper.isSuccess(null, response));
93 response.getResponseOutput().setResponseCode(null);
94 assertFalse(oper.isSuccess(null, response));
97 response.setResponseOutput(null);
98 assertFalse(oper.isSuccess(null, response));