2 * ============LICENSE_START=======================================================
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
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.openecomp.sdc.be.impl;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
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;
34 @ContextConfiguration(locations = {"classpath:application-context-test.xml"})
35 public class ServletUtilsTest {
37 private ServletUtils servletUtils;
38 private ComponentsUtils componentsUtils;
39 private UserBusinessLogic userBusinessLogic;
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);
54 public void testCtrServletUtils() {
55 assertThat(servletUtils)
57 .isInstanceOf(ServletUtils.class);
60 .isInstanceOf(Gson.class)
61 .isEqualTo(servletUtils.getGson());
62 assertThat(componentsUtils)
64 .isInstanceOf(ComponentsUtils.class)
65 .isEqualTo(servletUtils.getComponentsUtils());
66 assertThat(userBusinessLogic)
68 .isInstanceOf(UserBusinessLogic.class)
69 .isEqualTo(servletUtils.getUserAdmin());