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.servlets;
23 import com.google.common.base.Equivalence.Wrapper;
24 import fj.data.Either;
25 import org.junit.Test;
26 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
27 import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
28 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
29 import org.openecomp.sdc.be.impl.ComponentsUtils;
30 import org.openecomp.sdc.be.impl.ServletUtils;
31 import org.openecomp.sdc.be.model.PropertyDefinition;
32 import org.openecomp.sdc.be.model.Resource;
33 import org.openecomp.sdc.be.model.User;
34 import org.openecomp.sdc.be.user.UserBusinessLogic;
35 import org.openecomp.sdc.exception.ResponseFormat;
37 import javax.servlet.http.HttpServletRequest;
38 import javax.ws.rs.core.Response;
39 import java.util.List;
42 import static org.mockito.Mockito.mock;
44 public class ResourcesServletTest {
46 private ResourcesServlet createTestSubject() {
47 UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
48 ComponentInstanceBusinessLogic componentInstanceBL = mock(ComponentInstanceBusinessLogic.class);
49 ResourceBusinessLogic resourceBusinessLogic = mock(ResourceBusinessLogic.class);
50 ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
51 ServletUtils servletUtils = mock(ServletUtils.class);
52 ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
54 return new ResourcesServlet(userBusinessLogic, componentInstanceBL, resourceBusinessLogic, componentsUtils, servletUtils,
55 resourceImportManager);
60 public void testCreateResource() throws Exception {
61 ResourcesServlet testSubject;
63 HttpServletRequest request = null;
68 testSubject = createTestSubject();
74 public void testIsUIImport() throws Exception {
75 ResourcesServlet testSubject;
80 testSubject = createTestSubject();
85 public void testPerformUIImport() throws Exception {
86 ResourcesServlet testSubject;Wrapper<Response> responseWrapper = null;
88 HttpServletRequest request = null;
90 String resourceUniqueId = "";
98 public void testParseToResource() throws Exception {
99 ResourcesServlet testSubject;
100 String resourceJson = "";
102 Either<Resource, ResponseFormat> result;
105 testSubject = createTestSubject();
111 public void testParseToLightResource() throws Exception {
112 ResourcesServlet testSubject;
113 String resourceJson = "";
115 Either<Resource, ResponseFormat> result;
118 testSubject = createTestSubject();
124 public void testDeleteResource() throws Exception {
125 ResourcesServlet testSubject;
126 String resourceId = "";
127 HttpServletRequest request = null;
131 testSubject = createTestSubject();
137 public void testDeleteResourceByNameAndVersion() throws Exception {
138 ResourcesServlet testSubject;
139 String resourceName = "";
141 HttpServletRequest request = null;
145 testSubject = createTestSubject();
151 public void testGetResourceById() throws Exception {
152 ResourcesServlet testSubject;
153 String resourceId = "";
154 HttpServletRequest request = null;
159 testSubject = createTestSubject();
165 public void testGetResourceByNameAndVersion() throws Exception {
166 ResourcesServlet testSubject;
167 String resourceName = "";
168 String resourceVersion = "";
169 HttpServletRequest request = null;
174 testSubject = createTestSubject();
180 public void testValidateResourceName() throws Exception {
181 ResourcesServlet testSubject;
182 String resourceName = "";
183 String resourceType = "";
184 HttpServletRequest request = null;
189 testSubject = createTestSubject();
195 public void testGetCertifiedAbstractResources() throws Exception {
196 ResourcesServlet testSubject;
197 HttpServletRequest request = null;
202 testSubject = createTestSubject();
208 public void testGetCertifiedNotAbstractResources() throws Exception {
209 ResourcesServlet testSubject;
210 HttpServletRequest request = null;
215 testSubject = createTestSubject();
221 public void testUpdateResourceMetadata() throws Exception {
222 ResourcesServlet testSubject;
223 String resourceId = "";
225 HttpServletRequest request = null;
230 testSubject = createTestSubject();
236 public void testUpdateResource() throws Exception {
237 ResourcesServlet testSubject;
239 HttpServletRequest request = null;
241 String resourceId = "";
245 testSubject = createTestSubject();
251 public void testConvertMapToList() throws Exception {
252 Map<String, PropertyDefinition> properties = null;
253 List<PropertyDefinition> result;
262 public void testGetResourceFromCsar() throws Exception {
263 ResourcesServlet testSubject;
264 HttpServletRequest request = null;
266 String csarUUID = "";
270 testSubject = createTestSubject();