2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
19 * Modifications copyright (c) 2019 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.be.servlets;
25 import static org.assertj.core.api.Assertions.assertThat;
26 import static org.junit.Assert.assertEquals;
27 import static org.mockito.ArgumentMatchers.any;
28 import static org.mockito.ArgumentMatchers.eq;
29 import static org.mockito.BDDMockito.given;
30 import static org.mockito.Mockito.when;
32 import com.google.gson.Gson;
33 import com.google.gson.GsonBuilder;
34 import fj.data.Either;
35 import java.io.IOException;
36 import java.util.Arrays;
37 import java.util.Collections;
38 import java.util.HashMap;
39 import java.util.List;
41 import javax.servlet.ServletContext;
42 import javax.servlet.http.HttpServletRequest;
43 import javax.servlet.http.HttpSession;
44 import javax.ws.rs.client.Entity;
45 import javax.ws.rs.core.Application;
46 import javax.ws.rs.core.MediaType;
47 import javax.ws.rs.core.Response;
48 import org.apache.commons.codec.binary.Base64;
49 import org.apache.commons.lang3.tuple.ImmutablePair;
50 import org.apache.commons.text.StrSubstitutor;
51 import org.apache.http.HttpStatus;
52 import org.glassfish.hk2.utilities.binding.AbstractBinder;
53 import org.glassfish.jersey.media.multipart.MultiPartFeature;
54 import org.glassfish.jersey.server.ResourceConfig;
55 import org.glassfish.jersey.test.JerseyTest;
56 import org.glassfish.jersey.test.TestProperties;
57 import org.json.JSONException;
58 import org.junit.jupiter.api.AfterEach;
59 import org.junit.jupiter.api.BeforeAll;
60 import org.junit.jupiter.api.BeforeEach;
61 import org.junit.jupiter.api.Test;
62 import org.mockito.Mockito;
63 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
64 import org.openecomp.sdc.be.components.impl.GroupBusinessLogic;
65 import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
66 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
67 import org.openecomp.sdc.be.config.ConfigurationManager;
68 import org.openecomp.sdc.be.config.SpringConfig;
69 import org.openecomp.sdc.be.dao.api.ActionStatus;
70 import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
71 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
72 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
73 import org.openecomp.sdc.be.impl.ComponentsUtils;
74 import org.openecomp.sdc.be.impl.ServletUtils;
75 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
76 import org.openecomp.sdc.be.model.Resource;
77 import org.openecomp.sdc.be.model.UploadResourceInfo;
78 import org.openecomp.sdc.be.model.User;
79 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
80 import org.openecomp.sdc.be.user.Role;
81 import org.openecomp.sdc.be.user.UserBusinessLogic;
82 import org.openecomp.sdc.common.api.ConfigurationSource;
83 import org.openecomp.sdc.common.api.Constants;
84 import org.openecomp.sdc.common.impl.ExternalConfiguration;
85 import org.openecomp.sdc.common.impl.FSConfigurationSource;
86 import org.openecomp.sdc.common.util.GeneralUtility;
87 import org.openecomp.sdc.exception.ResponseFormat;
88 import org.springframework.context.ApplicationContext;
89 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
90 import org.springframework.web.context.WebApplicationContext;
92 class ResourceServletTest extends JerseyTest {
94 private final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
95 private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
96 private final HttpSession session = Mockito.mock(HttpSession.class);
97 private final ServletContext servletContext = Mockito.mock(ServletContext.class);
98 private final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
99 private final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
100 private final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
101 private final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
102 private final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
103 private final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
104 private final GroupBusinessLogic groupBL = Mockito.mock(GroupBusinessLogic.class);
105 private final ComponentInstanceBusinessLogic componentInstanceBL = Mockito.mock(ComponentInstanceBusinessLogic.class);
106 private final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
107 private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
108 private static final ResponseFormat okResponseFormat = new ResponseFormat(HttpStatus.SC_OK);
109 private static final ResponseFormat conflictResponseFormat = new ResponseFormat(HttpStatus.SC_CONFLICT);
110 private static final ResponseFormat generalErrorResponseFormat = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
111 private static final ResponseFormat createdResponseFormat = new ResponseFormat(HttpStatus.SC_CREATED);
112 private static final ResponseFormat noContentResponseFormat = new ResponseFormat(HttpStatus.SC_NO_CONTENT);
113 private static final ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
114 private static final ResponseFormat badRequestResponseFormat = new ResponseFormat(HttpStatus.SC_BAD_REQUEST);
115 private static final ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
116 "src/test/resources/config/catalog-be");
117 private static final ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
118 private static final String RESOURCE_NAME = "resourceName";
119 private static final String VERSION = "version";
120 private static final String RESOURCE_ID = "resourceId";
121 private static final String RESOURCE_VERSION = "resourceVersion";
122 private static final String SUBTYPE = "subtype";
123 private static final String CSAR_UUID = "csaruuid";
124 private static final String EMPTY_JSON = "{}";
125 private static final String NON_UI_IMPORT_JSON = "{\n" +
126 " \"node1\": \"value1\",\n" +
128 " \"level21\": \"value21\",\n" +
129 " \"level22\": \"value22\"\n" +
132 private static User user;
135 public static void setup() {
136 ExternalConfiguration.setAppName("catalog-be");
140 void after() throws Exception {
145 public void beforeTest() throws Exception {
147 Mockito.reset(componentUtils);
148 Mockito.reset(resourceBusinessLogic);
150 when(request.getSession()).thenReturn(session);
151 when(session.getServletContext()).thenReturn(servletContext);
152 when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
153 when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
154 when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
155 when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
156 when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
157 when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
158 String userId = "jh0003";
160 user.setUserId(userId);
161 user.setRole(Role.ADMIN.name());
162 when(userAdmin.getUser(userId)).thenReturn(user);
163 when(request.getHeader(Constants.USER_ID_HEADER)).thenReturn(userId);
164 ImmutablePair<Resource, ActionStatus> pair = new ImmutablePair<>(new Resource(), ActionStatus.OK);
165 when(resourceImportManager
166 .importUserDefinedResource(Mockito.anyString(), Mockito.any(UploadResourceInfo.class), Mockito.any(User.class), Mockito.anyBoolean()))
168 when(webApplicationContext.getBean(ResourceBusinessLogic.class)).thenReturn(resourceBusinessLogic);
170 when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(okResponseFormat);
171 when(componentUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(createdResponseFormat);
172 when(componentUtils.getResponseFormat(ActionStatus.NO_CONTENT)).thenReturn(noContentResponseFormat);
173 when(componentUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(badRequestResponseFormat);
174 when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(generalErrorResponseFormat);
175 when(componentUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND)).thenReturn(notFoundResponseFormat);
179 void testHappyScenarioTest() {
180 when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(createdResponseFormat);
182 UploadResourceInfo validJson = buildValidJson();
183 setMD5OnRequest(true, validJson);
184 Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
185 .post(Entity.json(gson.toJson(validJson)), Response.class);
186 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(Mockito.any(ActionStatus.class));
187 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(ActionStatus.OK);
188 assertEquals(HttpStatus.SC_CREATED, response.getStatus());
193 void testNonValidMd5Fail() {
194 UploadResourceInfo validJson = buildValidJson();
196 setMD5OnRequest(false, validJson);
198 Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
199 .post(Entity.json(gson.toJson(validJson)), Response.class);
200 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(Mockito.any(ActionStatus.class));
201 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(ActionStatus.INVALID_RESOURCE_CHECKSUM);
202 assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
207 void testNonValidPayloadNameFail() {
208 UploadResourceInfo mdJson = buildValidJson();
209 mdJson.setPayloadName("myCompute.xml");
211 runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_TOSCA_FILE_EXTENSION);
216 void testNullPayloadFail() {
217 UploadResourceInfo mdJson = buildValidJson();
218 mdJson.setPayloadData(null);
219 runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_RESOURCE_PAYLOAD);
224 void testNonYmlPayloadFail() {
225 UploadResourceInfo mdJson = buildValidJson();
226 String payload = "{ json : { isNot : yaml } ";
227 encodeAndSetPayload(mdJson, payload);
228 runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_YAML_FILE);
233 void testNonToscaPayloadFail() {
234 UploadResourceInfo mdJson = buildValidJson();
236 String payload = "node_types: \r\n" + " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n"
237 + " description: update update";
238 encodeAndSetPayload(mdJson, payload);
239 runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_TOSCA_TEMPLATE);
244 void testServiceToscaPayloadFail() {
245 UploadResourceInfo mdJson = buildValidJson();
248 "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + " org.openecomp.resource.importResource4test:\r\n"
249 + " derived_from: tosca.nodes.Root\r\n" + " topology_template: thisIsService\r\n"
250 + " description: update update";
252 encodeAndSetPayload(mdJson, payload);
253 runAndVerifyActionStatusError(mdJson, ActionStatus.NOT_RESOURCE_TOSCA_TEMPLATE);
258 void testMultipleResourcesInPayloadFail() {
259 UploadResourceInfo mdJson = buildValidJson();
262 "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + " org.openecomp.resource.importResource4test2:\r\n"
263 + " derived_from: tosca.nodes.Root\r\n" + " org.openecomp.resource.importResource4test:\r\n"
264 + " derived_from: tosca.nodes.Root\r\n" + " description: update update";
266 encodeAndSetPayload(mdJson, payload);
267 runAndVerifyActionStatusError(mdJson, ActionStatus.NOT_SINGLE_RESOURCE);
272 void testNonValidNameSpaceInPayloadFail() {
273 UploadResourceInfo mdJson = buildValidJson();
275 String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n"
276 + " org.openecomp.resourceX.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n"
277 + " description: update update";
279 encodeAndSetPayload(mdJson, payload);
280 runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_RESOURCE_NAMESPACE);
284 void deleteResourceTryDeleteNonExistingResourceTest() {
285 String resourceId = "resourceId";
286 Map<String, String> parametersMap = new HashMap<>();
287 parametersMap.put("resourceId", resourceId);
289 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
290 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
292 when(resourceBusinessLogic.deleteResource(any(), any(User.class)))
293 .thenReturn(notFoundResponseFormat);
295 Response response = target()
298 .accept(MediaType.APPLICATION_JSON)
299 .header(Constants.USER_ID_HEADER, user.getUserId())
302 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
306 void deleteResourceExceptionDuringDeletingTest() {
307 String resourceId = RESOURCE_ID;
308 Map<String, String> parametersMap = new HashMap<>();
309 parametersMap.put(RESOURCE_ID, resourceId);
311 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
312 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
314 when(resourceBusinessLogic.deleteResource(any(), any(User.class)))
315 .thenThrow(new JSONException("Test exception: deleteResource"));
317 Response response = target()
320 .accept(MediaType.APPLICATION_JSON)
321 .header(Constants.USER_ID_HEADER, user.getUserId())
324 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
328 void deleteResourceCategoryTest() {
329 String resourceId = "resourceId";
330 Map<String, String> parametersMap = new HashMap<>();
331 parametersMap.put("resourceId", resourceId);
333 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
334 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
336 when(resourceBusinessLogic.deleteResource(eq(resourceId.toLowerCase()), any(User.class)))
337 .thenReturn(noContentResponseFormat);
339 Response response = target()
342 .accept(MediaType.APPLICATION_JSON)
343 .header(Constants.USER_ID_HEADER, user.getUserId())
346 assertThat(response.getStatus()).isEqualTo(org.apache.http.HttpStatus.SC_NO_CONTENT);
350 void deleteResourceByNameAndVersionTryDeleteNonExistingResourceTest() {
351 String resourceName = RESOURCE_NAME;
352 String version = VERSION;
353 Map<String, String> parametersMap = new HashMap<>();
354 parametersMap.put(RESOURCE_NAME, resourceName);
355 parametersMap.put(VERSION, version);
357 String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
358 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
360 when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
361 .thenReturn(notFoundResponseFormat);
363 Response response = target()
366 .accept(MediaType.APPLICATION_JSON)
367 .header(Constants.USER_ID_HEADER, user.getUserId())
370 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
374 void deleteResourceByNameAndVersionExceptionDuringDeletingTest() {
375 String resourceName = RESOURCE_NAME;
376 String version = VERSION;
377 Map<String, String> parametersMap = new HashMap<>();
378 parametersMap.put(RESOURCE_NAME, resourceName);
379 parametersMap.put(VERSION, version);
381 String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
382 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
384 when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
385 .thenThrow(new JSONException("Test exception: deleteResourceByNameAndVersion"));
387 Response response = target()
390 .accept(MediaType.APPLICATION_JSON)
391 .header(Constants.USER_ID_HEADER, user.getUserId())
394 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
398 void deleteResourceByNameAndVersionCategoryTest() {
399 String resourceName = RESOURCE_NAME;
400 String version = VERSION;
401 Map<String, String> parametersMap = new HashMap<>();
402 parametersMap.put(RESOURCE_NAME, resourceName);
403 parametersMap.put(VERSION, version);
405 String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
406 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
408 when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
409 .thenReturn(noContentResponseFormat);
411 Response response = target()
414 .accept(MediaType.APPLICATION_JSON)
415 .header(Constants.USER_ID_HEADER, user.getUserId())
418 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
422 void getResourceByIdTryGetNonExistingResourceTest() {
423 String resourceId = RESOURCE_ID;
424 Map<String, String> parametersMap = new HashMap<>();
425 parametersMap.put(RESOURCE_ID, resourceId);
427 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
428 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
430 Either<Resource, ResponseFormat> getResourceByIdEither = Either.right(notFoundResponseFormat);
431 when(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
432 .thenReturn(getResourceByIdEither);
434 Response response = target()
437 .accept(MediaType.APPLICATION_JSON)
438 .header(Constants.USER_ID_HEADER, user.getUserId())
441 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
445 void getResourceByIdExceptionDuringSearchingTest() {
446 String resourceId = RESOURCE_ID;
447 Map<String, String> parametersMap = new HashMap<>();
448 parametersMap.put(RESOURCE_ID, resourceId);
450 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
451 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
453 given(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
454 .willAnswer(invocation -> {
455 throw new IOException("Test exception: getResourceById");
458 Response response = target()
461 .accept(MediaType.APPLICATION_JSON)
462 .header(Constants.USER_ID_HEADER, user.getUserId())
465 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
469 void getResourceByIdTest() {
470 String resourceId = RESOURCE_ID;
471 Map<String, String> parametersMap = new HashMap<>();
472 parametersMap.put(RESOURCE_ID, resourceId);
474 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
475 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
477 Either<Resource, ResponseFormat> getResourceByIdEither = Either.left(new Resource());
478 when(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
479 .thenReturn(getResourceByIdEither);
481 Response response = target()
484 .accept(MediaType.APPLICATION_JSON)
485 .header(Constants.USER_ID_HEADER, user.getUserId())
488 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
492 void getResourceByNameAndVersionTryGetNonExistingResourceTest() {
493 String resourceName = RESOURCE_NAME;
494 String resourceVersion = RESOURCE_VERSION;
495 Map<String, String> parametersMap = new HashMap<>();
496 parametersMap.put(RESOURCE_NAME, resourceName);
497 parametersMap.put(RESOURCE_VERSION, resourceVersion);
499 String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
500 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
502 Either<Resource, ResponseFormat> getResourceByNameAndVersionEither = Either.right(notFoundResponseFormat);
503 when(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
504 .thenReturn(getResourceByNameAndVersionEither);
506 Response response = target()
509 .accept(MediaType.APPLICATION_JSON)
510 .header(Constants.USER_ID_HEADER, user.getUserId())
513 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
517 void getResourceByNameAndVersionExceptionDuringSearchingTest() {
518 String resourceName = RESOURCE_NAME;
519 String resourceVersion = RESOURCE_VERSION;
520 Map<String, String> parametersMap = new HashMap<>();
521 parametersMap.put(RESOURCE_NAME, resourceName);
522 parametersMap.put(RESOURCE_VERSION, resourceVersion);
524 String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
525 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
527 given(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
528 .willAnswer(invocation -> {
529 throw new IOException("Test exception: getResourceByNameAndVersion");
532 Response response = target()
535 .accept(MediaType.APPLICATION_JSON)
536 .header(Constants.USER_ID_HEADER, user.getUserId())
539 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
543 void getResourceByNameAndVersionTest() {
544 String resourceName = RESOURCE_NAME;
545 String resourceVersion = RESOURCE_VERSION;
546 Map<String, String> parametersMap = new HashMap<>();
547 parametersMap.put(RESOURCE_NAME, resourceName);
548 parametersMap.put(RESOURCE_VERSION, resourceVersion);
550 String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
551 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
553 Either<Resource, ResponseFormat> getResourceByNameAndVersionEither = Either.left(new Resource());
554 when(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
555 .thenReturn(getResourceByNameAndVersionEither);
557 Response response = target()
560 .accept(MediaType.APPLICATION_JSON)
561 .header(Constants.USER_ID_HEADER, user.getUserId())
564 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
568 void validateResourceNameTryValidateNonExistingResourceTest() {
569 String resourceName = RESOURCE_NAME;
570 String resourceType = "VFC";
571 Map<String, String> parametersMap = new HashMap<>();
572 parametersMap.put(RESOURCE_NAME, resourceName);
574 String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
575 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
577 Either<Map<String, Boolean>, ResponseFormat> validateResourceNameEither =
578 Either.right(notFoundResponseFormat);
579 ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.valueOf(resourceType);
580 when(resourceBusinessLogic.validateResourceNameExists(eq(resourceName), eq(resourceTypeEnum), eq(user.getUserId())))
581 .thenReturn(validateResourceNameEither);
583 Response response = target()
585 .queryParam(SUBTYPE, resourceType)
587 .accept(MediaType.APPLICATION_JSON)
588 .header(Constants.USER_ID_HEADER, user.getUserId())
591 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
595 void validateResourceNameInvalidContentTest() {
596 String resourceName = RESOURCE_NAME;
597 String resourceType = "ThisIsInvalid";
598 Map<String, String> parametersMap = new HashMap<>();
599 parametersMap.put(RESOURCE_NAME, resourceName);
601 String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
602 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
604 Response response = target()
606 .queryParam(SUBTYPE, resourceType)
608 .accept(MediaType.APPLICATION_JSON)
609 .header(Constants.USER_ID_HEADER, user.getUserId())
612 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
616 void validateResourceNameTest() {
617 String resourceName = RESOURCE_NAME;
618 String resourceType = "VFC";
619 Map<String, String> parametersMap = new HashMap<>();
620 parametersMap.put(RESOURCE_NAME, resourceName);
622 String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
623 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
625 Either<Map<String, Boolean>, ResponseFormat> validateResourceNameEither =
626 Either.left(new HashMap<>());
627 ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.valueOf(resourceType);
628 when(resourceBusinessLogic.validateResourceNameExists(eq(resourceName), eq(resourceTypeEnum), eq(user.getUserId())))
629 .thenReturn(validateResourceNameEither);
631 Response response = target()
633 .queryParam(SUBTYPE, resourceType)
635 .accept(MediaType.APPLICATION_JSON)
636 .header(Constants.USER_ID_HEADER, user.getUserId())
639 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
643 void getCertifiedAbstractResourcesExceptionDuringSearchingTest() {
644 String path = "/v1/catalog/resources/certified/abstract";
645 given(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.HIGHEST_ONLY),
646 eq(user.getUserId())))
647 .willAnswer(invocation -> {
648 throw new IOException("Test exception: getCertifiedAbstractResources");
651 Response response = target()
654 .accept(MediaType.APPLICATION_JSON)
655 .header(Constants.USER_ID_HEADER, user.getUserId())
658 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
662 void getCertifiedAbstractResourcesTest() {
663 String path = "/v1/catalog/resources/certified/abstract";
665 List<Resource> resources = Arrays.asList(new Resource(), new Resource());
666 when(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.HIGHEST_ONLY),
667 eq(user.getUserId())))
668 .thenReturn(resources);
670 Response response = target()
673 .accept(MediaType.APPLICATION_JSON)
674 .header(Constants.USER_ID_HEADER, user.getUserId())
677 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
681 void getCertifiedNotAbstractResourcesExceptionDuringSearchingTest() {
682 String path = "/v1/catalog/resources/certified/notabstract";
683 given(resourceBusinessLogic.getAllCertifiedResources(eq(false), eq(HighestFilterEnum.ALL),
684 eq(user.getUserId())))
685 .willAnswer(invocation -> {
686 throw new IOException("Test exception: getCertifiedNotAbstractResources");
689 Response response = target()
692 .accept(MediaType.APPLICATION_JSON)
693 .header(Constants.USER_ID_HEADER, user.getUserId())
696 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
700 void getCertifiedNotAbstractResourcesTest() {
701 String path = "/v1/catalog/resources/certified/notabstract";
703 List<Resource> resources = Arrays.asList(new Resource(), new Resource());
704 when(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.ALL),
705 eq(user.getUserId())))
706 .thenReturn(resources);
708 Response response = target()
711 .accept(MediaType.APPLICATION_JSON)
712 .header(Constants.USER_ID_HEADER, user.getUserId())
715 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
719 void updateResourceMetadataTryUpdateNonExistingResourceTest() {
720 String resourceId = RESOURCE_ID;
721 Map<String, String> parametersMap = new HashMap<>();
722 parametersMap.put(RESOURCE_ID, resourceId);
724 String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
725 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
727 Either<Resource, ResponseFormat> updateResourceMetadataEither = Either.right(badRequestResponseFormat);
729 when(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
730 eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
731 .thenReturn(updateResourceMetadataEither);
733 when(resourceBusinessLogic.updateResourceMetadata(eq(resourceId.toLowerCase()), any(), any(), any(User.class),
735 .thenReturn(new Resource());
737 Response response = target()
740 .accept(MediaType.APPLICATION_JSON)
741 .header(Constants.USER_ID_HEADER, user.getUserId())
742 .put(Entity.json(EMPTY_JSON));
744 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
748 void updateResourceMetadataExceptionDuringUpdateTest() {
749 String resourceId = RESOURCE_ID;
750 Map<String, String> parametersMap = new HashMap<>();
751 parametersMap.put(RESOURCE_ID, resourceId);
753 String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
754 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
756 given(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
757 eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
758 .willAnswer(invocation -> {
759 throw new IOException("Test exception: updateResourceMetadata");
762 Response response = target()
765 .accept(MediaType.APPLICATION_JSON)
766 .header(Constants.USER_ID_HEADER, user.getUserId())
767 .put(Entity.json(EMPTY_JSON));
769 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
773 void updateResourceMetadataCategoryTest() {
774 String resourceId = RESOURCE_ID;
775 Map<String, String> parametersMap = new HashMap<>();
776 parametersMap.put(RESOURCE_ID, resourceId);
778 String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
779 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
781 Resource initialResource = new Resource();
782 Either<Resource, ResponseFormat> updateResourceMetadataEither = Either.left(initialResource);
784 when(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
785 eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
786 .thenReturn(updateResourceMetadataEither);
788 when(resourceBusinessLogic.updateResourceMetadata(eq(resourceId.toLowerCase()), eq(initialResource), any(),
789 any(User.class), eq(false)))
790 .thenReturn(new Resource());
792 Response response = target()
795 .accept(MediaType.APPLICATION_JSON)
796 .header(Constants.USER_ID_HEADER, user.getUserId())
797 .put(Entity.json(EMPTY_JSON));
799 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
803 void updateResourceParsingUncussessfulTest() {
804 String resourceId = RESOURCE_ID;
805 Map<String, String> parametersMap = new HashMap<>();
806 parametersMap.put(RESOURCE_ID, resourceId);
808 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
809 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
811 Either<Resource, ResponseFormat> updateResourceEither = Either.right(badRequestResponseFormat);
813 when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
814 eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
815 .thenReturn(updateResourceEither);
817 Response response = target()
820 .accept(MediaType.APPLICATION_JSON)
821 .header(Constants.USER_ID_HEADER, user.getUserId())
822 .put(Entity.json(NON_UI_IMPORT_JSON));
824 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
828 void updateResourceExceptionDuringUpdateTest() {
829 String resourceId = RESOURCE_ID;
830 Map<String, String> parametersMap = new HashMap<>();
831 parametersMap.put(RESOURCE_ID, resourceId);
833 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
834 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
836 given(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
837 eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
838 .willAnswer(invocation -> {
839 throw new IOException("Test exception: updateResource");
842 Response response = target()
845 .accept(MediaType.APPLICATION_JSON)
846 .header(Constants.USER_ID_HEADER, user.getUserId())
847 .put(Entity.json(NON_UI_IMPORT_JSON));
849 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
853 void updateResourceNonUiImportTest() {
854 String resourceId = RESOURCE_ID;
855 Map<String, String> parametersMap = new HashMap<>();
856 parametersMap.put(RESOURCE_ID, resourceId);
858 String formatEndpoint = "/v1/catalog/resources/{resourceId}";
859 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
861 Either<Resource, ResponseFormat> updateResourceEither = Either.left(new Resource());
863 when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class), eq(Resource.class),
864 eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
865 .thenReturn(updateResourceEither);
867 when(resourceBusinessLogic.validateAndUpdateResourceFromCsar(any(), any(), any(), any(), eq(resourceId)))
868 .thenReturn(new Resource());
870 Response response = target()
873 .accept(MediaType.APPLICATION_JSON)
874 .header(Constants.USER_ID_HEADER, user.getUserId())
875 .put(Entity.json(NON_UI_IMPORT_JSON));
877 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
881 void getResourceFromCsarTryGetNonExistingResourceTest() {
882 String csarUuid = CSAR_UUID;
883 Map<String, String> parametersMap = new HashMap<>();
884 parametersMap.put(CSAR_UUID, csarUuid);
886 String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
887 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
889 Either<Resource, ResponseFormat> getResourceFromCsarEither = Either.right(notFoundResponseFormat);
890 when(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
891 .thenReturn(getResourceFromCsarEither);
893 Response response = target()
896 .accept(MediaType.APPLICATION_JSON)
897 .header(Constants.USER_ID_HEADER, user.getUserId())
900 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
904 void getResourceFromCsarExceptionDuringGettingTest() {
905 String csarUuid = CSAR_UUID;
906 Map<String, String> parametersMap = new HashMap<>();
907 parametersMap.put(CSAR_UUID, csarUuid);
909 String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
910 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
912 given(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
913 .willAnswer(invocation -> {
914 throw new IOException("Test exception: getResourceFromCsar");
917 Response response = target()
920 .accept(MediaType.APPLICATION_JSON)
921 .header(Constants.USER_ID_HEADER, user.getUserId())
924 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
928 void getResourceFromCsarTest() {
929 String csarUuid = CSAR_UUID;
930 Map<String, String> parametersMap = new HashMap<>();
931 parametersMap.put(CSAR_UUID, csarUuid);
933 String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
934 String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
936 Either<Resource, ResponseFormat> getResourceFromCsarEither = Either.left(new Resource());
937 when(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
938 .thenReturn(getResourceFromCsarEither);
940 Response response = target()
943 .accept(MediaType.APPLICATION_JSON)
944 .header(Constants.USER_ID_HEADER, user.getUserId())
947 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
951 void createResourceExceptionDuringCreateTest() {
952 String path = "/v1/catalog/resources";
954 given(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
955 eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
956 .willAnswer(invocation -> {
957 throw new IOException("Test exception: createResource");
960 Response response = target()
963 .accept(MediaType.APPLICATION_JSON)
964 .header(Constants.USER_ID_HEADER, user.getUserId())
965 .post(Entity.json(NON_UI_IMPORT_JSON));
967 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
971 void createResourceNonUiImportProcessingFailedTest() {
972 String path = "/v1/catalog/resources";
974 Either<Resource, ResponseFormat> createResourceEither = Either.right(badRequestResponseFormat);
976 when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
977 eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
978 .thenReturn(createResourceEither);
980 Response response = target()
983 .accept(MediaType.APPLICATION_JSON)
984 .header(Constants.USER_ID_HEADER, user.getUserId())
985 .post(Entity.json(NON_UI_IMPORT_JSON));
987 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
991 void createResourceNonUiImportTest() {
992 String path = "/v1/catalog/resources";
994 Either<Resource, ResponseFormat> createResourceEither = Either.left(new Resource());
996 when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
997 eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
998 .thenReturn(createResourceEither);
1000 when(resourceBusinessLogic.createResource(eq(createResourceEither.left().value()), eq(AuditingActionEnum.CREATE_RESOURCE),
1001 any(User.class), any(), any()))
1002 .thenReturn(new Resource());
1004 Response response = target()
1007 .accept(MediaType.APPLICATION_JSON)
1008 .header(Constants.USER_ID_HEADER, user.getUserId())
1009 .post(Entity.json(NON_UI_IMPORT_JSON));
1011 assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
1014 private void encodeAndSetPayload(UploadResourceInfo mdJson, String payload) {
1015 byte[] encodedBase64Payload = Base64.encodeBase64(payload.getBytes());
1016 mdJson.setPayloadData(new String(encodedBase64Payload));
1019 private void runAndVerifyActionStatusError(UploadResourceInfo mdJson, ActionStatus invalidResourcePayload) {
1020 setMD5OnRequest(true, mdJson);
1021 Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
1022 .post(Entity.json(gson.toJson(mdJson)), Response.class);
1023 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(Mockito.any(ActionStatus.class));
1024 Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(invalidResourcePayload);
1025 assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
1028 private void setMD5OnRequest(boolean isValid, UploadResourceInfo json) {
1029 String md5 = (isValid) ? GeneralUtility.calculateMD5Base64EncodedByString(gson.toJson(json)) : "stam=";
1030 when(request.getHeader(Constants.MD5_HEADER)).thenReturn(md5);
1034 private UploadResourceInfo buildValidJson() {
1035 UploadResourceInfo ret = new UploadResourceInfo();
1036 ret.setName("ciMyCompute");
1037 ret.setPayloadName("ciMyCompute.yml");
1038 ret.addSubCategory("Application Layer 4+", "Application Servers");
1039 ret.setDescription("ResourceDescription");
1040 ret.setVendorName("VendorName");
1041 ret.setVendorRelease("VendorRelease");
1042 ret.setContactId("AT1234");
1043 ret.setIcon("router");
1044 ret.setTags(Collections.singletonList("ciMyCompute"));
1046 "dG9zY2FfZGVmaW5pdGlvbnNfdmVyc2lvbjogdG9zY2Ffc2ltcGxlX3lhbWxfMV8wXzANCm5vZGVfdHlwZXM6IA0KICBvcmcub3BlbmVjb21wLnJlc291cmNlLk15Q29tcHV0ZToNCiAgICBkZXJpdmVkX2Zyb206IHRvc2NhLm5vZGVzLlJvb3QNCiAgICBhdHRyaWJ1dGVzOg0KICAgICAgcHJpdmF0ZV9hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIHB1YmxpY19hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIG5ldHdvcmtzOg0KICAgICAgICB0eXBlOiBtYXANCiAgICAgICAgZW50cnlfc2NoZW1hOg0KICAgICAgICAgIHR5cGU6IHRvc2NhLmRhdGF0eXBlcy5uZXR3b3JrLk5ldHdvcmtJbmZvDQogICAgICBwb3J0czoNCiAgICAgICAgdHlwZTogbWFwDQogICAgICAgIGVudHJ5X3NjaGVtYToNCiAgICAgICAgICB0eXBlOiB0b3NjYS5kYXRhdHlwZXMubmV0d29yay5Qb3J0SW5mbw0KICAgIHJlcXVpcmVtZW50czoNCiAgICAgIC0gbG9jYWxfc3RvcmFnZTogDQogICAgICAgICAgY2FwYWJpbGl0eTogdG9zY2EuY2FwYWJpbGl0aWVzLkF0dGFjaG1lbnQNCiAgICAgICAgICBub2RlOiB0b3NjYS5ub2Rlcy5CbG9ja1N0b3JhZ2UNCiAgICAgICAgICByZWxhdGlvbnNoaXA6IHRvc2NhLnJlbGF0aW9uc2hpcHMuQXR0YWNoZXNUbw0KICAgICAgICAgIG9jY3VycmVuY2VzOiBbMCwgVU5CT1VOREVEXSAgDQogICAgY2FwYWJpbGl0aWVzOg0KICAgICAgaG9zdDogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5Db250YWluZXINCiAgICAgICAgdmFsaWRfc291cmNlX3R5cGVzOiBbdG9zY2Eubm9kZXMuU29mdHdhcmVDb21wb25lbnRdIA0KICAgICAgZW5kcG9pbnQgOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuRW5kcG9pbnQuQWRtaW4gDQogICAgICBvczogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5PcGVyYXRpbmdTeXN0ZW0NCiAgICAgIHNjYWxhYmxlOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuU2NhbGFibGUNCiAgICAgIGJpbmRpbmc6DQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5uZXR3b3JrLkJpbmRhYmxl");
1051 protected Application configure() {
1052 ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
1053 forceSet(TestProperties.CONTAINER_PORT, "0");
1054 return new ResourceConfig(ResourcesServlet.class)
1055 .register(new AbstractBinder() {
1057 protected void configure() {
1058 bind(request).to(HttpServletRequest.class);
1059 bind(servletUtils).to(ServletUtils.class);
1060 bind(componentUtils).to(ComponentsUtils.class);
1061 bind(userBusinessLogic).to(UserBusinessLogic.class);
1062 bind(resourceBusinessLogic).to(ResourceBusinessLogic.class);
1063 bind(groupBL).to(GroupBusinessLogic.class);
1064 bind(componentInstanceBL).to(ComponentInstanceBusinessLogic.class);
1065 bind(resourceImportManager).to(ResourceImportManager.class);
1068 .register(MultiPartFeature.class)
1069 .property("contextConfig", context);