Fix locally failing TCs in catalog-be
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / impl / ServletUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.impl;
22
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
26
27 import com.google.gson.Gson;
28 import com.google.gson.GsonBuilder;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.openecomp.sdc.be.user.UserBusinessLogic;
32 import org.springframework.test.context.ContextConfiguration;
33
34 @ContextConfiguration(locations = {"classpath:application-context-test.xml"})
35 public class ServletUtilsTest {
36
37     private ServletUtils servletUtils;
38     private ComponentsUtils componentsUtils;
39     private UserBusinessLogic userBusinessLogic;
40     private Gson gson;
41
42     @BeforeEach
43     public void setup() {
44         servletUtils = mock(ServletUtils.class);
45         userBusinessLogic = mock(UserBusinessLogic.class);
46         componentsUtils = mock(ComponentsUtils.class);
47         gson = new GsonBuilder().setPrettyPrinting().create();
48         when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
49         when(servletUtils.getGson()).thenReturn(gson);
50         when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
51     }
52
53     @Test
54     public void testCtrServletUtils() {
55         assertThat(servletUtils)
56             .isNotNull()
57             .isInstanceOf(ServletUtils.class);
58         assertThat(gson)
59             .isNotNull()
60             .isInstanceOf(Gson.class)
61             .isEqualTo(servletUtils.getGson());
62         assertThat(componentsUtils)
63             .isNotNull()
64             .isInstanceOf(ComponentsUtils.class)
65             .isEqualTo(servletUtils.getComponentsUtils());
66         assertThat(userBusinessLogic)
67             .isNotNull()
68             .isInstanceOf(UserBusinessLogic.class)
69             .isEqualTo(servletUtils.getUserAdmin());
70     }
71 }