2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nokia. All rights reserved.
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.vid.mso;
24 import static org.mockito.Mockito.when;
26 import io.joshworks.restclient.http.HttpResponse;
27 import org.mockito.Mock;
28 import org.testng.annotations.BeforeClass;
29 import org.testng.annotations.Test;
31 import static org.assertj.core.api.Assertions.assertThat;
32 import static org.mockito.MockitoAnnotations.initMocks;
34 public class MsoResponseWrapper2Test {
37 private RestObject<String> msoResponse;
40 private HttpResponse<String> httpResponse;
42 private MsoResponseWrapper2<String> responseWrapper;
44 private int status = 202;
45 private String entity = "testEntity";
46 private String rawString = "testRawString";
54 public void shouldProperlyCreateInstanceFromRestObject() {
56 when(msoResponse.getStatusCode()).thenReturn(status);
57 when(msoResponse.get()).thenReturn(entity);
58 when(msoResponse.getRaw()).thenReturn(rawString);
61 responseWrapper = new MsoResponseWrapper2<>(msoResponse);
64 assertThat(responseWrapper.getStatus()).isEqualTo(status);
65 assertThat(responseWrapper.getEntity()).isEqualTo(entity);
66 assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
70 public void shouldProperlyCreateInstanceFromHttpResponse() {
72 when(httpResponse.getStatus()).thenReturn(status);
73 when(httpResponse.getBody()).thenReturn(entity);
76 responseWrapper = new MsoResponseWrapper2<>(httpResponse);
79 assertThat(responseWrapper.getStatus()).isEqualTo(status);
80 assertThat(responseWrapper.getEntity()).isEqualTo(entity);
81 assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
85 public void shouldProperlyCreateInstanceFromStatusAndEntity() {
87 responseWrapper = new MsoResponseWrapper2<>(status,entity);
90 assertThat(responseWrapper.getStatus()).isEqualTo(status);
91 assertThat(responseWrapper.getEntity()).isEqualTo(entity);
92 assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");