2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.vid.mso;
23 import org.hamcrest.MatcherAssert;
24 import org.testng.annotations.BeforeClass;
25 import org.testng.annotations.Test;
27 import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
28 import static org.assertj.core.api.Assertions.assertThat;
30 public class RestObjectTest {
32 private RestObject<Object> restObject;
35 private void setUp() {
36 restObject = new RestObject<>();
40 public void shouldHaveValidGettersAndSetters(){
41 MatcherAssert.assertThat(RestObject.class, hasValidGettersAndSettersExcluding("t"));
45 public void shouldHaveValidGetterAndSetterForTObject() {
47 String testString = "set/get_testString";
50 restObject.set(testString);
53 assertThat(testString).isSameAs(restObject.get());
57 public void shouldProperlyCopyFromOneRestObjectToAnotherWithProperParameters() {
59 MsoResponseWrapper testResponseWraper = new MsoResponseWrapper();
60 String rawTestString = "rawTestString";
63 RestObject<Object> restObjectToCopyFrom = new RestObject<>();
64 restObjectToCopyFrom.set(testResponseWraper);
65 restObjectToCopyFrom.setRaw(rawTestString);
66 restObjectToCopyFrom.setStatusCode(statusCode);
69 restObject.copyFrom(restObjectToCopyFrom);
72 assertThat(restObject).isEqualToComparingFieldByField(restObjectToCopyFrom);
76 public void shouldProperlyConvertRestObjectToString() {
78 String testString = "testString";
79 String rawTestString = "rawTestString";
82 restObject.set(testString);
83 restObject.setRaw(rawTestString);
84 restObject.setStatusCode(statusCode);
86 String properString = "RestObject{t=testString, rawT=rawTestString, statusCode=202}";
89 String toStringResponse = restObject.toString();
92 assertThat(toStringResponse).isEqualTo(properString);