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 javax.servlet.ServletContext;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.ws.rs.core.Response;
29 import org.junit.Test;
30 import org.openecomp.sdc.be.components.impl.*;
31 import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
32 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
33 import org.openecomp.sdc.be.impl.ComponentsUtils;
34 import org.openecomp.sdc.be.impl.ServletUtils;
35 import org.openecomp.sdc.be.model.User;
36 import org.openecomp.sdc.be.user.UserBusinessLogic;
37 import org.openecomp.sdc.exception.ResponseFormat;
39 import com.google.common.base.Equivalence.Wrapper;
40 import com.google.common.util.concurrent.Service;
42 import fj.data.Either;
44 public class ServiceServletTest {
46 private ServiceServlet createTestSubject() {
47 UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
48 ComponentInstanceBusinessLogic componentInstanceBL = mock(ComponentInstanceBusinessLogic.class);
49 ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
50 ServletUtils servletUtils = mock(ServletUtils.class);
51 ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
52 ServiceBusinessLogic serviceBusinessLogic = mock(ServiceBusinessLogic.class);
53 ResourceBusinessLogic resourceBusinessLogic = mock(ResourceBusinessLogic.class);
55 return new ServiceServlet(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils,
56 resourceImportManager, serviceBusinessLogic, resourceBusinessLogic);
61 public void testCreateService() throws Exception {
62 ServiceServlet testSubject;
64 HttpServletRequest request = null;
69 testSubject = createTestSubject();
75 public void testParseToService() throws Exception {
76 ServiceServlet testSubject;
77 String serviceJson = "";
79 Either<Service, ResponseFormat> result;
82 testSubject = createTestSubject();
87 public void testValidateServiceName() throws Exception {
88 ServiceServlet testSubject;
89 String serviceName = "";
90 HttpServletRequest request = null;
95 testSubject = createTestSubject();
101 public void testGetComponentAuditRecords() throws Exception {
102 ServiceServlet testSubject;
103 String componentType = "";
104 String componentUniqueId = "";
105 HttpServletRequest request = null;
110 testSubject = createTestSubject();
116 public void testFillUUIDAndVersion() throws Exception {
117 ServiceServlet testSubject;Wrapper<Response> responseWrapper = null;
118 Wrapper<String> uuidWrapper = null;
119 Wrapper<String> versionWrapper = null;
121 ComponentTypeEnum componentTypeEnum = null;
122 String componentUniqueId = "";
123 ServletContext context = null;
131 public void testDeleteService() throws Exception {
132 ServiceServlet testSubject;
133 String serviceId = "";
134 HttpServletRequest request = null;
138 testSubject = createTestSubject();
144 public void testDeleteServiceByNameAndVersion() throws Exception {
145 ServiceServlet testSubject;
146 String serviceName = "";
148 HttpServletRequest request = null;
152 testSubject = createTestSubject();
158 public void testUpdateServiceMetadata() throws Exception {
159 ServiceServlet testSubject;
160 String serviceId = "";
162 HttpServletRequest request = null;
167 testSubject = createTestSubject();
173 public void testUpdateGroupInstancePropertyValues() throws Exception {
174 ServiceServlet testSubject;
175 String serviceId = "";
176 String componentInstanceId = "";
177 String groupInstanceId = "";
179 HttpServletRequest request = null;
184 testSubject = createTestSubject();
190 public void testGetServiceById() throws Exception {
191 ServiceServlet testSubject;
192 String serviceId = "";
193 HttpServletRequest request = null;
198 testSubject = createTestSubject();
204 public void testGetServiceByNameAndVersion() throws Exception {
205 ServiceServlet testSubject;
206 String serviceName = "";
207 String serviceVersion = "";
208 HttpServletRequest request = null;
213 testSubject = createTestSubject();
219 public void testUpdateServiceDistributionState() throws Exception {
220 ServiceServlet testSubject;
221 LifecycleChangeInfoWithAction jsonChangeInfo = null;
222 String serviceId = "";
224 HttpServletRequest request = null;
229 testSubject = createTestSubject();
235 public void testActivateDistribution() throws Exception {
236 ServiceServlet testSubject;
237 String serviceId = "";
239 HttpServletRequest request = null;
244 testSubject = createTestSubject();
250 public void testMarkDistributionAsDeployed() throws Exception {
251 ServiceServlet testSubject;
252 String serviceId = "";
254 HttpServletRequest request = null;
259 testSubject = createTestSubject();
265 public void testTempUrlToBeDeleted() throws Exception {
266 ServiceServlet testSubject;
267 String serviceId = "";
268 HttpServletRequest request = null;
273 testSubject = createTestSubject();
279 public void testDownloadServiceArtifact() throws Exception {
280 ServiceServlet testSubject;
281 String artifactName = "";
282 HttpServletRequest request = null;
286 testSubject = createTestSubject();
292 public void testExecuteCommand() throws Exception {
293 ServiceServlet testSubject;
294 String artifactName = "";
295 Either<byte[], ResponseFormat> result;
298 testSubject = createTestSubject();