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 static org.mockito.Mockito.mock;
25 import java.util.List;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.ws.rs.core.Response;
31 import org.junit.Test;
32 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
33 import org.openecomp.sdc.be.components.impl.GroupBusinessLogic;
34 import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
35 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
36 import org.openecomp.sdc.be.impl.ComponentsUtils;
37 import org.openecomp.sdc.be.impl.ServletUtils;
38 import org.openecomp.sdc.be.model.PropertyDefinition;
39 import org.openecomp.sdc.be.model.Resource;
40 import org.openecomp.sdc.be.model.User;
41 import org.openecomp.sdc.be.user.UserBusinessLogic;
42 import org.openecomp.sdc.exception.ResponseFormat;
44 import com.google.common.base.Equivalence.Wrapper;
46 import fj.data.Either;
48 public class ResourcesServletTest {
50 private ResourcesServlet createTestSubject() {
51 UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
52 ComponentInstanceBusinessLogic componentInstanceBL = mock(ComponentInstanceBusinessLogic.class);
53 ResourceBusinessLogic resourceBusinessLogic = mock(ResourceBusinessLogic.class);
54 ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
55 ServletUtils servletUtils = mock(ServletUtils.class);
56 ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
58 return new ResourcesServlet(userBusinessLogic, componentInstanceBL, resourceBusinessLogic, componentsUtils, servletUtils,
59 resourceImportManager);
64 public void testCreateResource() throws Exception {
65 ResourcesServlet testSubject;
67 HttpServletRequest request = null;
72 testSubject = createTestSubject();
78 public void testIsUIImport() throws Exception {
79 ResourcesServlet testSubject;
84 testSubject = createTestSubject();
89 public void testPerformUIImport() throws Exception {
90 ResourcesServlet testSubject;Wrapper<Response> responseWrapper = null;
92 HttpServletRequest request = null;
94 String resourceUniqueId = "";
102 public void testParseToResource() throws Exception {
103 ResourcesServlet testSubject;
104 String resourceJson = "";
106 Either<Resource, ResponseFormat> result;
109 testSubject = createTestSubject();
115 public void testParseToLightResource() throws Exception {
116 ResourcesServlet testSubject;
117 String resourceJson = "";
119 Either<Resource, ResponseFormat> result;
122 testSubject = createTestSubject();
128 public void testDeleteResource() throws Exception {
129 ResourcesServlet testSubject;
130 String resourceId = "";
131 HttpServletRequest request = null;
135 testSubject = createTestSubject();
141 public void testDeleteResourceByNameAndVersion() throws Exception {
142 ResourcesServlet testSubject;
143 String resourceName = "";
145 HttpServletRequest request = null;
149 testSubject = createTestSubject();
155 public void testGetResourceById() throws Exception {
156 ResourcesServlet testSubject;
157 String resourceId = "";
158 HttpServletRequest request = null;
163 testSubject = createTestSubject();
169 public void testGetResourceByNameAndVersion() throws Exception {
170 ResourcesServlet testSubject;
171 String resourceName = "";
172 String resourceVersion = "";
173 HttpServletRequest request = null;
178 testSubject = createTestSubject();
184 public void testValidateResourceName() throws Exception {
185 ResourcesServlet testSubject;
186 String resourceName = "";
187 String resourceType = "";
188 HttpServletRequest request = null;
193 testSubject = createTestSubject();
199 public void testGetCertifiedAbstractResources() throws Exception {
200 ResourcesServlet testSubject;
201 HttpServletRequest request = null;
206 testSubject = createTestSubject();
212 public void testGetCertifiedNotAbstractResources() throws Exception {
213 ResourcesServlet testSubject;
214 HttpServletRequest request = null;
219 testSubject = createTestSubject();
225 public void testUpdateResourceMetadata() throws Exception {
226 ResourcesServlet testSubject;
227 String resourceId = "";
229 HttpServletRequest request = null;
234 testSubject = createTestSubject();
240 public void testUpdateResource() throws Exception {
241 ResourcesServlet testSubject;
243 HttpServletRequest request = null;
245 String resourceId = "";
249 testSubject = createTestSubject();
255 public void testConvertMapToList() throws Exception {
256 Map<String, PropertyDefinition> properties = null;
257 List<PropertyDefinition> result;
266 public void testGetResourceFromCsar() throws Exception {
267 ResourcesServlet testSubject;
268 HttpServletRequest request = null;
270 String csarUUID = "";
274 testSubject = createTestSubject();