summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ConsumerServlet.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java62
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java171
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java340
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java72
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java309
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java144
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java84
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java85
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java63
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java244
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java44
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java167
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java93
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java119
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java54
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java242
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java266
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java39
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java107
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java164
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java71
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java36
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java56
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java91
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java47
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java54
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java183
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java65
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java28
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java57
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java112
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java229
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java169
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java83
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java251
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java64
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java1003
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java69
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java189
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java77
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java65
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java51
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java81
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java68
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java56
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java50
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java93
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java83
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java40
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java78
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java133
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java2
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ConfigurationChangeNotifier.java80
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java8
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java10
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java12
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java18
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java12
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java10
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java8
-rw-r--r--docs/offeredapis.rst19
-rw-r--r--onboarding/pom.xml10
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java13
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java29
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java60
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java171
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java34
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java77
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java73
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java12
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileUtilsTest.java48
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/resources/org/openecomp/core/utilities/file/test-resource.txt1
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java37
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java42
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java81
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java30
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java76
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java21
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh2
-rwxr-xr-xsdc-os-chef/scripts/docker_run.sh4
98 files changed, 3987 insertions, 3931 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ConsumerServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ConsumerServlet.java
index ecbd667623..c207497a22 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ConsumerServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ConsumerServlet.java
@@ -70,7 +70,7 @@ public class ConsumerServlet extends BeGenericServlet {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Consumer credentials", httpMethod = "POST", notes = "Returns created ECOMP consumer credentials", response = Response.class)
+ @ApiOperation(value = "Consumer credentials", httpMethod = "POST", notes = "Returns created ONAP consumer credentials", response = Response.class)
@ApiResponses(value = { @ApiResponse(code = 201, message = "Consumer credentials created"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") })
public Response createConsumer(@ApiParam(value = "Consumer Object to be created", required = true) String data, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
index 4b2ff89ef8..da9b867041 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
@@ -613,8 +613,8 @@ public class ElementServlet extends BeGenericServlet {
@Path("/ecompPortalMenu")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Retrieve ecomp portal menu - MOC", httpMethod = "GET", notes = "Retrieve ecomp portal menu", response = User.class)
- @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieve ecomp portal menu") })
+ @ApiOperation(value = "Retrieve ONAP portal menu - MOC", httpMethod = "GET", notes = "Retrieve ONAP portal menu", response = User.class)
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieve ONAP portal menu") })
public Response getListOfCsars(@Context final HttpServletRequest request) {
return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK),
"[{\"menuId\":1,\"column\":2,\"text\":\"Design\",\"parentMenuId\":null,\"url\":\"\",\"appid\":null,\"roles\":null,\"children\":[{\"menuId\":11,\"column\":1,\"text\":\"ProductDesign\",\"parentMenuId\":1,\"url\":\"\",\"appid\":null,\"roles\":null},{\"menuId\":12,\"column\":2,\"text\":\"Service\",\"parentMenuId\":1,\"url\":\"\",\"appid\":null,\"roles\":null,\"children\":[{\"menuId\":21,\"column\":1,\"text\":\"ViewPolicies\",\"parentMenuId\":12,\"url\":\"\",\"appid\":null,\"roles\":null,\"children\":[{\"menuId\":90,\"column\":1,\"text\":\"4thLevelApp1aR16\",\"parentMenuId\":21,\"url\":\"http://google.com\",\"appid\":null,\"roles\":null}]},{\"menuId\":22,\"column\":2,\"text\":\"UpdatePolicies\",\"parentMenuId\":12,\"url\":\"\",\"appid\":null,\"roles\":null,\"children\":[{\"menuId\":91,\"column\":1,\"text\":\"4thLevelApp1bR16\",\"parentMenuId\":22,\"url\":\"http://jsonlint.com/\",\"appid\":null,\"roles\":null}]},{\"menuId\":23,\"column\":3,\"text\":\"UpdateRules\",\"parentMenuId\":12,\"url\":\"\",\"appid\":null,\"roles\":null},{\"menuId\":24,\"column\":4,\"text\":\"CreateSignatures?\",\"parentMenuId\":12,\"url\":\"\",\"appid\":null,\"roles\":null},{\"menuId\":25,\"column\":5,\"text\":\"Definedata\",\"parentMenuId\":12,\"url\":\"\",\"appid\":null,\"roles\":null}]}]}]");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
index 2b33fbd704..27963fa8cb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java
@@ -20,31 +20,51 @@
package org.openecomp.sdc.be.servlets;
-import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.sdc.be.model.UploadResourceInfo;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.common.datastructure.Wrapper;
-import org.openecomp.sdc.exception.ResponseFormat;
-import org.slf4j.Logger;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
-import javax.ws.rs.core.Response;
+import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.glassfish.grizzly.servlet.ServletUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.servlets.ResourceUploadServlet.ResourceAuthorityTypeEnum;
+import org.openecomp.sdc.common.datastructure.Wrapper;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.slf4j.Logger;
+
+import com.google.common.base.Supplier;
+import com.google.gson.Gson;
+
+import aj.org.objectweb.asm.Type;
+import fj.data.Either;
public class AbstractValidationsServletTest {
- private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() {};
+ private static AbstractValidationsServlet servlet = new AbstractValidationsServlet() {
+ };
private static final String BASIC_TOSCA_TEMPLATE = "tosca_definitions_version: tosca_simple_yaml_%s";
@@ -53,6 +73,7 @@ public class AbstractValidationsServletTest {
servlet.initLog(mock(Logger.class));
}
+
@SuppressWarnings("unchecked")
@Test
public void testGetScarFromPayload() {
@@ -71,10 +92,12 @@ public class AbstractValidationsServletTest {
resourceInfo.setPayloadName(payloadName);
resourceInfo.setPayloadData(payloadData);
Method privateMethod = null;
- privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getScarFromPayload", UploadResourceInfo.class);
+ privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getScarFromPayload",
+ UploadResourceInfo.class);
privateMethod.setAccessible(true);
returnValue = (Either<Map<String, byte[]>, ResponseFormat>) privateMethod.invoke(servlet, resourceInfo);
- } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
assertTrue(returnValue.isLeft());
@@ -87,13 +110,12 @@ public class AbstractValidationsServletTest {
Stream.of("1_0", "1_0_0", "1_1", "1_1_0").forEach(this::testValidToscaVersion);
}
-
- private void testValidToscaVersion(String version) {
+ private void testValidToscaVersion(String version) {
Wrapper<Response> responseWrapper = new Wrapper<>();
- servlet.validatePayloadIsTosca(responseWrapper, new UploadResourceInfo(), new User(), String.format(BASIC_TOSCA_TEMPLATE, version));
+ servlet.validatePayloadIsTosca(responseWrapper, new UploadResourceInfo(), new User(),
+ String.format(BASIC_TOSCA_TEMPLATE, version));
assertTrue(responseWrapper.isEmpty());
}
-
-
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java
new file mode 100644
index 0000000000..0cb9906dc4
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AdditionalInformationServletTest.java
@@ -0,0 +1,171 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.AdditionalInformationBusinessLogic;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+
+
+public class AdditionalInformationServletTest {
+
+ private AdditionalInformationServlet createTestSubject() {
+ return new AdditionalInformationServlet();
+ }
+
+
+ @Test
+ public void testCreateResourceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userUserId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateServiceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String serviceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userUserId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String resourceId = "";
+ String labelId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateServiceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String serviceId = "";
+ String labelId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceAdditionalInformationLabel_1() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String resourceId = "";
+ String labelId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteServiceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String serviceId = "";
+ String labelId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetResourceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String resourceId = "";
+ String labelId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetServiceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String serviceId = "";
+ String labelId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetAllResourceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String resourceId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetAllServiceAdditionalInformationLabel() throws Exception {
+ AdditionalInformationServlet testSubject;
+ String serviceId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java
new file mode 100644
index 0000000000..b4d04f92a9
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArtifactServletTest.java
@@ -0,0 +1,340 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+
+
+public class ArtifactServletTest {
+
+ private ArtifactServlet createTestSubject() {
+ return new ArtifactServlet();
+ }
+
+
+ @Test
+ public void testLoadArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testLoadInformationArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateInformationArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateApiArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String origMd5 = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteApiArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String origMd5 = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteInformationalArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDownloadServiceArtifactBase64() throws Exception {
+ ArtifactServlet testSubject;
+ String serviceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDownloadResourceArtifactBase64() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDownloadResourceInstanceArtifactBase64() throws Exception {
+ ArtifactServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testLoadArtifactToInterface() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String interfaceType = "";
+ String operation = "";
+ String userId = "";
+ String origMd5 = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteArtifactToInterface() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String interfaceType = "";
+ String operation = "";
+ String artifactId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateArtifactToInterface() throws Exception {
+ ArtifactServlet testSubject;
+ String resourceId = "";
+ String interfaceType = "";
+ String operation = "";
+ String artifactId = "";
+ String userId = "";
+ String origMd5 = "";
+ HttpServletRequest request = null;
+ String data = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateRIArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateComponentInstanceArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String userId = "";
+ String origMd5 = "";
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testLoadComponentInstanceArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String userId = "";
+ String origMd5 = "";
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteComponentInstanceArtifact() throws Exception {
+ ArtifactServlet testSubject;
+ String userId = "";
+ String origMd5 = "";
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String artifactId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetComponentArtifacts() throws Exception {
+ ArtifactServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String artifactGroupType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetComponentInstanceArtifacts() throws Exception {
+ ArtifactServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String artifactGroupType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java
new file mode 100644
index 0000000000..34a475882a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AttributeServletTest.java
@@ -0,0 +1,72 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import com.google.common.base.Equivalence.Wrapper;
+
+public class AttributeServletTest {
+
+ private AttributeServlet createTestSubject() {
+ return new AttributeServlet();
+ }
+
+
+ @Test
+ public void testCreateAttribute() throws Exception {
+ AttributeServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUpdateAttribute() throws Exception {
+ AttributeServlet testSubject;
+ String resourceId = "";
+ String attributeId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testDeleteAttribute() throws Exception {
+ AttributeServlet testSubject;
+ String resourceId = "";
+ String attributeId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testBuildAttributeFromString() throws Exception {
+ AttributeServlet testSubject;String data = "";
+ Wrapper<PropertyDefinition> attributesWrapper = null;
+ Wrapper<ResponseFormat> errorWrapper = null;
+
+
+ // default test
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
new file mode 100644
index 0000000000..52ee33fd74
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
@@ -0,0 +1,309 @@
+package org.openecomp.sdc.be.servlets;
+
+import java.util.List;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.junit.Test;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class ComponentInstanceServletTest {
+
+ private ComponentInstanceServlet createTestSubject() {
+ return new ComponentInstanceServlet();
+ }
+
+
+ @Test
+ public void testCreateComponentInstance() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String data = "";
+ String containerComponentId = "";
+ String containerComponentType = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateComponentInstanceMetadata() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String componentInstanceId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateMultipleComponentInstance() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ String componentInstanceJsonArray = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteResourceInstance() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String resourceInstanceId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testAssociateRIToRI() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String userId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDissociateRIFromRI() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String userId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateAndAssociateRIToRI() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceInstanceProperty() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String componentInstanceId = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceInstanceInput() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String componentInstanceId = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceInstanceAttribute() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String componentInstanceId = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteResourceInstanceProperty() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String componentInstanceId = "";
+ String propertyId = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testChangeResourceInstanceVersion() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String componentInstanceId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateGroupInstanceProperty() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String componentId = "";
+ String containerComponentType = "";
+ String componentInstanceId = "";
+ String groupInstanceId = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetGroupArtifactById() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String componentInstanceId = "";
+ String groupInstId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetInstancePropertiesById() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String containerComponentType = "";
+ String containerComponentId = "";
+ String componentInstanceUniqueId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateServiceProxy() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String data = "";
+ String containerComponentId = "";
+ String containerComponentType = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteServiceProxy() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String containerComponentId = "";
+ String serviceProxyId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testChangeServiceProxyVersion() throws Exception {
+ ComponentInstanceServlet testSubject;
+ String containerComponentId = "";
+ String serviceProxyId = "";
+ String containerComponentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
new file mode 100644
index 0000000000..3e97aa4cb0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
@@ -0,0 +1,144 @@
+package org.openecomp.sdc.be.servlets;
+
+import java.util.List;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+public class ComponentServletTest {
+
+ private ComponentServlet createTestSubject() {
+ return new ComponentServlet();
+ }
+
+
+ @Test
+ public void testConformanceLevelValidation() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ String componentUuid = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetRequirementAndCapabilities() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetLatestVersionNotAbstractCheckoutComponents() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ HttpServletRequest request = null;
+ String internalComponentType = "";
+ List<String> componentUids = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetLatestVersionNotAbstractCheckoutComponentsByBody() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ HttpServletRequest request = null;
+ String internalComponentType = "";
+ String userId = "";
+ List<String> data = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetLatestVersionNotAbstractCheckoutComponentsIdesOnly() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ HttpServletRequest request = null;
+ String internalComponentType = "";
+ String userId = "";
+ String data = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ HttpServletRequest request = null;
+ String searchText = "";
+ String userId = "";
+ String data = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetComponentDataFilteredByParams() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ List<String> dataParamsToReturn = null;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetFilteredComponentInstanceProperties() throws Exception {
+ ComponentServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String propertyNameFragment = "";
+ List<String> resourceTypes = null;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java
new file mode 100644
index 0000000000..4f2ca19986
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigMgrServletTest.java
@@ -0,0 +1,84 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.datastax.driver.core.Configuration;
+
+public class ConfigMgrServletTest {
+
+ private ConfigMgrServlet createTestSubject() {
+ return new ConfigMgrServlet();
+ }
+
+
+ @Test
+ public void testGetConfig() throws Exception {
+ ConfigMgrServlet testSubject;
+ HttpServletRequest request = null;
+ String type = "";
+ String result;
+
+ // test 1
+ testSubject = createTestSubject();
+ type = null;
+
+
+ // test 2
+ testSubject = createTestSubject();
+ type = "";
+
+ // test 3
+ testSubject = createTestSubject();
+ type = "configuration";
+ }
+
+
+ @Test
+ public void testSetConfig1() throws Exception {
+ ConfigMgrServlet testSubject;
+ HttpServletRequest request = null;
+ Configuration configuration = null;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testSetConfig2() throws Exception {
+ ConfigMgrServlet testSubject;
+ HttpServletRequest request = null;
+ Configuration configuration = null;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testSetConfig3() throws Exception {
+ ConfigMgrServlet testSubject;
+ HttpServletRequest request = null;
+ Configuration configuration = null;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testSetConfig4() throws Exception {
+ ConfigMgrServlet testSubject;
+ HttpServletRequest request = null;
+ Configuration configuration = null;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java
new file mode 100644
index 0000000000..adc996eb4c
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConfigServletTest.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+
+public class ConfigServletTest {
+
+ private ConfigServlet createTestSubject() {
+ return new ConfigServlet();
+ }
+
+
+ @Test
+ public void testGetConfig() throws Exception {
+ ConfigServlet testSubject;
+ HttpServletRequest request = null;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java
new file mode 100644
index 0000000000..6360c5a76e
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ConsumerServletTest.java
@@ -0,0 +1,85 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.ConsumerBusinessLogic;
+import org.openecomp.sdc.be.model.ConsumerDefinition;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class ConsumerServletTest {
+
+ private ConsumerServlet createTestSubject() {
+ return new ConsumerServlet();
+ }
+
+
+ @Test
+ public void testCreateConsumer() throws Exception {
+ ConsumerServlet testSubject;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetConsumer() throws Exception {
+ ConsumerServlet testSubject;
+ String consumerId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testDeleteConsumer() throws Exception {
+ ConsumerServlet testSubject;
+ String consumerId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetConsumerBL() throws Exception {
+ ConsumerServlet testSubject;
+ ServletContext context = null;
+ ConsumerBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testConvertJsonToObject() throws Exception {
+ ConsumerServlet testSubject;
+ String data = "";
+ User user = null;
+ AuditingActionEnum actionEnum = null;
+ Either<ConsumerDefinition, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
index daacb79de5..e80016a678 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/CsarBuildServletTest.java
@@ -8,6 +8,8 @@ import org.junit.Test;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
import ch.qos.logback.classic.Logger;
+import java.util.*;
+import org.junit.Assert;
public class CsarBuildServletTest {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java
new file mode 100644
index 0000000000..2233b4ebac
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DistributionServiceServletTest.java
@@ -0,0 +1,63 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.DistributionMonitoringBusinessLogic;
+
+public class DistributionServiceServletTest {
+
+ private DistributionServiceServlet createTestSubject() {
+ return new DistributionServiceServlet();
+ }
+
+
+ @Test
+ public void testGetServiceById() throws Exception {
+ DistributionServiceServlet testSubject;
+ String serviceUUID = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetListOfDistributionStatuses() throws Exception {
+ DistributionServiceServlet testSubject;
+ String did = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testInit() throws Exception {
+ DistributionServiceServlet testSubject;
+ HttpServletRequest request = null;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetDistributionBL() throws Exception {
+ DistributionServiceServlet testSubject;
+ ServletContext context = null;
+ DistributionMonitoringBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
new file mode 100644
index 0000000000..2fe68d3a90
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
@@ -0,0 +1,244 @@
+package org.openecomp.sdc.be.servlets;
+
+import java.util.List;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
+
+public class ElementServletTest {
+
+ private ElementServlet createTestSubject() {
+ return new ElementServlet();
+ }
+
+
+ @Test
+ public void testGetComponentCategories() throws Exception {
+ ElementServlet testSubject;
+ String componentType = "";
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetAllCategories() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateComponentCategory() throws Exception {
+ ElementServlet testSubject;
+ String componentType = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteComponentCategory() throws Exception {
+ ElementServlet testSubject;
+ String categoryUniqueId = "";
+ String componentType = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateComponentSubCategory() throws Exception {
+ ElementServlet testSubject;
+ String componentType = "";
+ String categoryId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteComponentSubCategory() throws Exception {
+ ElementServlet testSubject;
+ String categoryUniqueId = "";
+ String subCategoryUniqueId = "";
+ String componentType = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testCreateComponentGrouping() throws Exception {
+ ElementServlet testSubject;
+ String componentType = "";
+ String grandParentCategoryId = "";
+ String parentSubCategoryId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteComponentGrouping() throws Exception {
+ ElementServlet testSubject;
+ String grandParentCategoryUniqueId = "";
+ String parentSubCategoryUniqueId = "";
+ String groupingUniqueId = "";
+ String componentType = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetTags() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetPropertyScopes() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetArtifactTypes() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetConfiguration() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetFollowedResourcesServices() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetCatalogComponents() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ List<OriginTypeEnum> excludeTypes = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteMarkedResources() throws Exception {
+ ElementServlet testSubject;
+ String componentType = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetListOfCsars() throws Exception {
+ ElementServlet testSubject;
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java
new file mode 100644
index 0000000000..85b835076b
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupServletTest.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+public class GroupServletTest {
+
+ private GroupServlet createTestSubject() {
+ return new GroupServlet();
+ }
+
+
+ @Test
+ public void testGetGroupArtifactById() throws Exception {
+ GroupServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String groupId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testUpdateGroupMetadata() throws Exception {
+ GroupServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String groupUniqueId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
new file mode 100644
index 0000000000..9cc13d32de
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
@@ -0,0 +1,167 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.InputsBusinessLogic;
+import org.openecomp.sdc.be.model.ComponentInstInputsMap;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import fj.data.Either;
+
+public class InputsServletTest {
+
+ private InputsServlet createTestSubject() {
+ return new InputsServlet();
+ }
+
+
+ @Test
+ public void testGetComponentInputs() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ HttpServletRequest request = null;
+ String fromName = "";
+ int amount = 0;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUpdateComponentInputs() throws Exception {
+ InputsServlet testSubject;
+ String containerComponentType = "";
+ String componentId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetComponentInstanceInputs() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String instanceId = "";
+ String originComonentUid = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetInputPropertiesForComponentInstance() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String instanceId = "";
+ String inputId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetInputsForComponentInput() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String inputId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetInputsAndPropertiesForComponentInput() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String inputId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testParseToComponentInstanceMap() throws Exception {
+ InputsServlet testSubject;
+ String serviceJson = "";
+ User user = null;
+ Either<ComponentInstInputsMap, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testCreateMultipleInputs() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String componentInstInputsMapObj = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testDeleteInput() throws Exception {
+ InputsServlet testSubject;
+ String componentType = "";
+ String componentId = "";
+ String inputId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String componentInstInputsMapObj = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetInputBL() throws Exception {
+ InputsServlet testSubject;
+ ServletContext context = null;
+ InputsBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java
new file mode 100644
index 0000000000..f92e439c9a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/LifecycleServletTest.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
+import org.openecomp.sdc.be.model.User;
+
+import fj.data.Either;
+
+public class LifecycleServletTest {
+
+ private LifecycleServlet createTestSubject() {
+ return new LifecycleServlet();
+ }
+
+
+ @Test
+ public void testChangeResourceState() throws Exception {
+ LifecycleServlet testSubject;
+ String jsonChangeInfo = "";
+ String componentCollection = "";
+ String lifecycleTransition = "";
+ String componentId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testValidateTransitionEnum() throws Exception {
+ LifecycleServlet testSubject;
+ String lifecycleTransition = "";
+ User user = null;
+ Either<LifeCycleTransitionEnum, Response> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java
new file mode 100644
index 0000000000..2376ceea32
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ProductServletTest.java
@@ -0,0 +1,93 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+public class ProductServletTest {
+
+ private ProductServlet createTestSubject() {
+ return new ProductServlet();
+ }
+
+
+ @Test
+ public void testCreateProduct() throws Exception {
+ ProductServlet testSubject;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetProductById() throws Exception {
+ ProductServlet testSubject;
+ String productId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetServiceByNameAndVersion() throws Exception {
+ ProductServlet testSubject;
+ String productName = "";
+ String productVersion = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testDeleteProduct() throws Exception {
+ ProductServlet testSubject;
+ String productId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUpdateProductMetadata() throws Exception {
+ ProductServlet testSubject;
+ String productId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testValidateServiceName() throws Exception {
+ ProductServlet testSubject;
+ String productName = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java
new file mode 100644
index 0000000000..dd31364868
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PropertyServletTest.java
@@ -0,0 +1,119 @@
+package org.openecomp.sdc.be.servlets;
+
+import java.util.Map;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+
+import com.google.common.collect.Multiset.Entry;
+
+import fj.data.Either;
+
+public class PropertyServletTest {
+
+ private PropertyServlet createTestSubject() {
+ return new PropertyServlet();
+ }
+
+
+ @Test
+ public void testCreateProperty() throws Exception {
+ PropertyServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetProperty() throws Exception {
+ PropertyServlet testSubject;
+ String resourceId = "";
+ String propertyId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testDeleteProperty() throws Exception {
+ PropertyServlet testSubject;
+ String resourceId = "";
+ String propertyId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUpdateProperty() throws Exception {
+ PropertyServlet testSubject;
+ String resourceId = "";
+ String propertyId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetPropertyModel() throws Exception {
+ PropertyServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ Either<Map<String, PropertyDefinition>, ActionStatus> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+
+
+
+ @Test
+ public void testGetPropertyDefinitionJSONObject() throws Exception {
+ PropertyServlet testSubject;
+ PropertyDefinition propertyDefinition = null;
+ JSONObject result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetPropertyBL() throws Exception {
+ PropertyServlet testSubject;
+ ServletContext context = null;
+ PropertyBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java
new file mode 100644
index 0000000000..4407ec6577
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/RequirementsServletTest.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+public class RequirementsServletTest {
+
+ private RequirementsServlet createTestSubject() {
+ return new RequirementsServlet();
+ }
+
+
+ @Test
+ public void testUpdateRequirement() throws Exception {
+ RequirementsServlet testSubject;
+ String resourceId = "";
+ String requirementId = "";
+ String requirementData = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java
new file mode 100644
index 0000000000..b88a097412
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceArtifactDownloadServletTest.java
@@ -0,0 +1,54 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+import ch.qos.logback.classic.Logger;
+
+public class ResourceArtifactDownloadServletTest {
+
+ private ResourceArtifactDownloadServlet createTestSubject() {
+ return new ResourceArtifactDownloadServlet();
+ }
+
+
+ @Test
+ public void testGetResourceArtifactByName() throws Exception {
+ ResourceArtifactDownloadServlet testSubject;
+ String resourceName = "";
+ String resourceVersion = "";
+ String artifactName = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetResourceArtifactMetadata() throws Exception {
+ ResourceArtifactDownloadServlet testSubject;
+ String resourceName = "";
+ String resourceVersion = "";
+ String artifactName = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetLogger() throws Exception {
+ ResourceArtifactDownloadServlet testSubject;
+ Logger result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java
new file mode 100644
index 0000000000..1844cfe188
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourcesServletTest.java
@@ -0,0 +1,242 @@
+package org.openecomp.sdc.be.servlets;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Generated;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import com.google.common.base.Equivalence.Wrapper;
+
+import fj.data.Either;
+
+public class ResourcesServletTest {
+
+ private ResourcesServlet createTestSubject() {
+ return new ResourcesServlet();
+ }
+
+
+ @Test
+ public void testCreateResource() throws Exception {
+ ResourcesServlet testSubject;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testIsUIImport() throws Exception {
+ ResourcesServlet testSubject;
+ String data = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testPerformUIImport() throws Exception {
+ ResourcesServlet testSubject;Wrapper<Response> responseWrapper = null;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String resourceUniqueId = "";
+
+
+ // default test
+ }
+
+
+ @Test
+ public void testParseToResource() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceJson = "";
+ User user = null;
+ Either<Resource, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testParseToLightResource() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceJson = "";
+ User user = null;
+ Either<Resource, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteResource() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteResourceByNameAndVersion() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceName = "";
+ String version = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetResourceById() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetResourceByNameAndVersion() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceName = "";
+ String resourceVersion = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testValidateResourceName() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceName = "";
+ String resourceType = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetCertifiedAbstractResources() throws Exception {
+ ResourcesServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetCertifiedNotAbstractResources() throws Exception {
+ ResourcesServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResourceMetadata() throws Exception {
+ ResourcesServlet testSubject;
+ String resourceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateResource() throws Exception {
+ ResourcesServlet testSubject;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ String resourceId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testConvertMapToList() throws Exception {
+ Map<String, PropertyDefinition> properties = null;
+ List<PropertyDefinition> result;
+
+ // test 1
+ properties = null;
+
+ }
+
+
+ @Test
+ public void testGetResourceFromCsar() throws Exception {
+ ResourcesServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ String csarUUID = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java
new file mode 100644
index 0000000000..7a21a231d8
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ServiceServletTest.java
@@ -0,0 +1,266 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import com.google.common.base.Equivalence.Wrapper;
+import com.google.common.util.concurrent.Service;
+
+import fj.data.Either;
+
+public class ServiceServletTest {
+
+ private ServiceServlet createTestSubject() {
+ return new ServiceServlet();
+ }
+
+
+ @Test
+ public void testCreateService() throws Exception {
+ ServiceServlet testSubject;
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testParseToService() throws Exception {
+ ServiceServlet testSubject;
+ String serviceJson = "";
+ User user = null;
+ Either<Service, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testValidateServiceName() throws Exception {
+ ServiceServlet testSubject;
+ String serviceName = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetComponentAuditRecords() throws Exception {
+ ServiceServlet testSubject;
+ String componentType = "";
+ String componentUniqueId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testFillUUIDAndVersion() throws Exception {
+ ServiceServlet testSubject;Wrapper<Response> responseWrapper = null;
+ Wrapper<String> uuidWrapper = null;
+ Wrapper<String> versionWrapper = null;
+ User user = null;
+ ComponentTypeEnum componentTypeEnum = null;
+ String componentUniqueId = "";
+ ServletContext context = null;
+
+
+ // default test
+ }
+
+
+ @Test
+ public void testDeleteService() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDeleteServiceByNameAndVersion() throws Exception {
+ ServiceServlet testSubject;
+ String serviceName = "";
+ String version = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateServiceMetadata() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateGroupInstancePropertyValues() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ String componentInstanceId = "";
+ String groupInstanceId = "";
+ String data = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetServiceById() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testGetServiceByNameAndVersion() throws Exception {
+ ServiceServlet testSubject;
+ String serviceName = "";
+ String serviceVersion = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testUpdateServiceDistributionState() throws Exception {
+ ServiceServlet testSubject;
+ LifecycleChangeInfoWithAction jsonChangeInfo = null;
+ String serviceId = "";
+ String state = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testActivateDistribution() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ String env = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testMarkDistributionAsDeployed() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ String did = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testTempUrlToBeDeleted() throws Exception {
+ ServiceServlet testSubject;
+ String serviceId = "";
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testDownloadServiceArtifact() throws Exception {
+ ServiceServlet testSubject;
+ String artifactName = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+
+ }
+
+
+ @Test
+ public void testExecuteCommand() throws Exception {
+ ServiceServlet testSubject;
+ String artifactName = "";
+ Either<byte[], ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java
new file mode 100644
index 0000000000..94aaee2afc
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesFetchServletTest.java
@@ -0,0 +1,39 @@
+package org.openecomp.sdc.be.servlets;
+
+import javax.annotation.Generated;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
+
+public class TypesFetchServletTest {
+
+ private TypesFetchServlet createTestSubject() {
+ return new TypesFetchServlet();
+ }
+
+
+ @Test
+ public void testGetAllDataTypesServlet() throws Exception {
+ TypesFetchServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetPropertyBL() throws Exception {
+ TypesFetchServlet testSubject;
+ ServletContext context = null;
+ PropertyBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
index 420cbcca6b..8f4f57e836 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
@@ -35,6 +35,8 @@ import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.structure.T;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.client.ClientConfig;
@@ -55,16 +57,19 @@ import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.servlets.TypesUploadServlet;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.ConsumerTwoParam;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.web.context.WebApplicationContext;
+import com.google.common.base.Equivalence.Wrapper;
+import com.google.common.base.Supplier;
+
import fj.data.Either;
public class TypesUploadServletTest extends JerseyTest {
@@ -83,7 +88,8 @@ public class TypesUploadServletTest extends JerseyTest {
@BeforeClass
public static void setup() {
ExternalConfiguration.setAppName("catalog-be");
- when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+ .thenReturn(webAppContextWrapper);
when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
when(webApplicationContext.getBean(CapabilityTypeImportManager.class)).thenReturn(importManager);
when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
@@ -106,11 +112,13 @@ public class TypesUploadServletTest extends JerseyTest {
List<CapabilityTypeDefinition> emptyList = new ArrayList<CapabilityTypeDefinition>();
Either<List<CapabilityTypeDefinition>, ResponseFormat> either = Either.left(emptyList);
when(importManager.createCapabilityTypes(Mockito.anyString())).thenReturn(either);
- FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip"));
+ FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip",
+ new File("src/test/resources/types/capabilityTypes.zip"));
MultiPart multipartEntity = new FormDataMultiPart();
multipartEntity.bodyPart(filePart);
- Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON).post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
+ Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON)
+ .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
assertTrue(response.getStatus() == HttpStatus.CREATED_201.getStatusCode());
@@ -137,7 +145,8 @@ public class TypesUploadServletTest extends JerseyTest {
when(request.getSession()).thenReturn(session);
when(session.getServletContext()).thenReturn(servletContext);
String appConfigDir = "src/test/resources/config/catalog-be";
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationSource configurationSource = new FSConfigurationSource(
+ ExternalConfiguration.getChangeListener(), appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
for (String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) {
@@ -145,10 +154,96 @@ public class TypesUploadServletTest extends JerseyTest {
}
- when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
+ when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+ .thenReturn(configurationManager);
}
});
return resourceConfig;
}
+
+ private TypesUploadServlet createTestSubject() {
+ return new TypesUploadServlet();
+ }
+
+
+ @Test
+ public void testUploadCapabilityType() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUploadInterfaceLifecycleType() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUploadCategories() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUploadDataTypes() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUploadGroupTypes() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUploadPolicyTypes() throws Exception {
+ TypesUploadServlet testSubject;
+ File file = null;
+ HttpServletRequest request = null;
+ String creator = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
index ed69f104d2..6fd930c684 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java
@@ -30,19 +30,21 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Response;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.servlets.UserAdminServlet;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.UserRoleEnum;
@@ -75,7 +77,8 @@ public class UserAdminServletTest extends JerseyTest {
ExternalConfiguration.setAppName("catalog-be");
when(session.getServletContext()).thenReturn(servletContext);
- when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+ .thenReturn(webAppContextWrapper);
when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
when(webApplicationContext.getBean(UserBusinessLogic.class)).thenReturn(userAdminManager);
@@ -97,26 +100,52 @@ public class UserAdminServletTest extends JerseyTest {
}
/*
- * @Test public void deactivateUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID); Either<User, ActionStatus> eitherActiveUser = buildEitherUser(userToDeleteUserId, true);
- * User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId);
+ * @Test public void deactivateUserSuccessfullyTest(){ String
+ * userToDeleteUserId = "admin1"; User adminUser = new User();
+ * adminUser.setUserId(ADMIN_ATT_UID); Either<User, ActionStatus>
+ * eitherActiveUser = buildEitherUser(userToDeleteUserId, true); User
+ * userToDelete = eitherActiveUser.left().value();
+ * doReturn(eitherActiveUser).when(userAdminManager).getUser(
+ * userToDeleteUserId);
*
- * Either<User, ActionStatus> eitherInactiveUser = buildEitherUser(userToDeleteUserId, false); doReturn(eitherInactiveUser).when(userAdminManager).deActivateUser( adminUser, userToDelete.getUserId());
+ * Either<User, ActionStatus> eitherInactiveUser =
+ * buildEitherUser(userToDeleteUserId, false);
+ * doReturn(eitherInactiveUser).when(userAdminManager).deActivateUser(
+ * adminUser, userToDelete.getUserId());
*
*
- * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(1)).deActivateUser(adminUser, userToDelete.getUserId()); }
+ * Response response =
+ * target().path("/v1/user/"+userToDeleteUserId).request().delete();
+ * assertTrue(response.getStatus() == HttpStatus.OK.value());
+ * verify(userAdminManager, times(1)).deActivateUser(adminUser,
+ * userToDelete.getUserId()); }
*
*
- * @Test public void forceDeleteUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; when(request.getHeader(User.FORCE_DELETE_HEADER_FLAG)).thenReturn(User. FORCE_DELETE_HEADER_FLAG);
+ * @Test public void forceDeleteUserSuccessfullyTest(){ String
+ * userToDeleteUserId = "admin1";
+ * when(request.getHeader(User.FORCE_DELETE_HEADER_FLAG)).thenReturn(User.
+ * FORCE_DELETE_HEADER_FLAG);
*
* User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID);
*
- * Either<User, ActionStatus> eitherActiveUser = buildEitherUser(userToDeleteUserId, true); User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId);
+ * Either<User, ActionStatus> eitherActiveUser =
+ * buildEitherUser(userToDeleteUserId, true); User userToDelete =
+ * eitherActiveUser.left().value();
+ * doReturn(eitherActiveUser).when(userAdminManager).getUser(
+ * userToDeleteUserId);
*
- * Either<User, ActionStatus> eitherUser = buildEitherUser(userToDeleteUserId, true); doReturn(eitherUser).when(userAdminManager).deleteUser(userToDelete. getUserId());
+ * Either<User, ActionStatus> eitherUser =
+ * buildEitherUser(userToDeleteUserId, true);
+ * doReturn(eitherUser).when(userAdminManager).deleteUser(userToDelete.
+ * getUserId());
*
*
- * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(0)).deActivateUser(adminUser, userToDelete.getUserId());
- * verify(userAdminManager, times(1)).deleteUser(userToDelete.getUserId()); }
+ * Response response =
+ * target().path("/v1/user/"+userToDeleteUserId).request().delete();
+ * assertTrue(response.getStatus() == HttpStatus.OK.value());
+ * verify(userAdminManager, times(0)).deActivateUser(adminUser,
+ * userToDelete.getUserId()); verify(userAdminManager,
+ * times(1)).deleteUser(userToDelete.getUserId()); }
*/
@Override
@@ -145,4 +174,117 @@ public class UserAdminServletTest extends JerseyTest {
return Either.left(user);
}
+ private UserAdminServlet createTestSubject() {
+ return new UserAdminServlet();
+ }
+
+
+ @Test
+ public void testGet() throws Exception {
+ UserAdminServlet testSubject;
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetRole() throws Exception {
+ UserAdminServlet testSubject;
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testUpdateUserRole() throws Exception {
+ UserAdminServlet testSubject;
+ String userIdUpdateUser = "";
+ HttpServletRequest request = null;
+ String data = "";
+ String modifierUserId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testCreateUser() throws Exception {
+ UserAdminServlet testSubject;
+ HttpServletRequest request = null;
+ String newUserData = "";
+ String modifierAttId = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testAuthorize() throws Exception {
+ UserAdminServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ String firstName = "";
+ String lastName = "";
+ String email = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetAdminsUser() throws Exception {
+ UserAdminServlet testSubject;
+ String userId = "";
+ HttpServletRequest request = null;
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetUsersList() throws Exception {
+ UserAdminServlet testSubject;
+ HttpServletRequest request = null;
+ String userId = "";
+ String roles = "";
+ Response result;
+
+ // test 1
+ testSubject = createTestSubject();
+ roles = null;
+
+ // test 2
+ testSubject = createTestSubject();
+ roles = "";
+ }
+
+
+ @Test
+ public void testDeActivateUser() throws Exception {
+ UserAdminServlet testSubject;
+ String userId = "";
+ HttpServletRequest request = null;
+ String userIdHeader = "";
+ Response result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
new file mode 100644
index 0000000000..e6f1ac82fb
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PropertyConvertorTest.java
@@ -0,0 +1,71 @@
+package org.openecomp.sdc.be.tosca;
+
+import java.util.Map;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
+import org.openecomp.sdc.be.tosca.model.ToscaProperty;
+
+import fj.data.Either;
+
+public class PropertyConvertorTest {
+
+ private PropertyConvertor createTestSubject() {
+ return new PropertyConvertor();
+ }
+
+
+ @Test
+ public void testGetInstance() throws Exception {
+ PropertyConvertor result;
+
+ // default test
+ result = PropertyConvertor.getInstance();
+ }
+
+
+ @Test
+ public void testConvertProperties() throws Exception {
+ PropertyConvertor testSubject;
+ Component component = null;
+ ToscaNodeType toscaNodeType = null;
+ Map<String, DataTypeDefinition> dataTypes = null;
+ Either<ToscaNodeType, ToscaError> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertProperties(component, toscaNodeType, dataTypes);
+ }
+
+
+ @Test
+ public void testConvertProperty() throws Exception {
+ PropertyConvertor testSubject;
+ Map<String, DataTypeDefinition> dataTypes = null;
+ PropertyDefinition property = null;
+ boolean isCapabiltyProperty = false;
+ ToscaProperty result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testConvertToToscaObject() throws Exception {
+ PropertyConvertor testSubject;
+ String propertyType = "";
+ String value = "";
+ String innerType = "";
+ Map<String, DataTypeDefinition> dataTypes = null;
+ Object result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
new file mode 100644
index 0000000000..7cb2ef7cf8
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -0,0 +1,36 @@
+package org.openecomp.sdc.be.tosca;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
+
+import fj.data.Either;
+
+public class ToscaExportHandlerTest {
+
+ private ToscaExportHandler createTestSubject() {
+ return new ToscaExportHandler();
+ }
+
+
+ @Test
+ public void testGetDependencies() throws Exception {
+ ToscaExportHandler testSubject;
+ Component component = null;
+ Either<ToscaTemplate, ToscaError> result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetInterfaceFilename() throws Exception {
+ String artifactName = "";
+ String result;
+
+ // default test
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java
new file mode 100644
index 0000000000..c3a993596c
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaUtilsTest.java
@@ -0,0 +1,56 @@
+package org.openecomp.sdc.be.tosca;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.Component;
+
+import com.datastax.driver.core.UserType.Field;
+
+public class ToscaUtilsTest {
+
+ private ToscaUtils createTestSubject() {
+ return new ToscaUtils();
+ }
+
+
+ @Test
+ public void testIsAtomicType() throws Exception {
+ Component component = null;
+ boolean result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testIsComplexVfc() throws Exception {
+ Component component = null;
+ boolean result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testObjectToMap() throws Exception {
+ Object objectToConvert = null;
+ Class clazz = null;
+ Map<String, Object> result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testGetAllFields() throws Exception {
+ List<Field> fields = null;
+ Class<?> type = null;
+ List<Field> result;
+
+ // default test
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java
deleted file mode 100644
index 4b01b4fd61..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.user;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.mockito.Mockito;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IUsersDAO;
-import org.openecomp.sdc.be.dao.impl.Neo4jUsersDAO;
-import org.openecomp.sdc.be.resources.data.UserData;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-import fj.data.Either;
-
-public class UserAdminManagerTest {
-
- final IUsersDAO usersDao = Mockito.mock(Neo4jUsersDAO.class);
- Gson gson;
-
- @Before
- public void setup() {
- Either<UserData, ActionStatus> eitherOk = Either.right(ActionStatus.OK);
- gson = new GsonBuilder().setPrettyPrinting().create();
- when(usersDao.getUserData(anyString())).thenReturn(eitherOk);
- when(usersDao.saveUserData((UserData) anyObject())).thenReturn(ActionStatus.OK);
- when(usersDao.updateUserData((UserData) anyObject())).thenReturn(ActionStatus.OK);
- when(usersDao.deleteUserData(anyString())).thenReturn(ActionStatus.OK);
- }
-
- // @Test
- // public void testCreateUser() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\":
- // \"jb1234u@sdc.com\",\"role\": \"ADMIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.OK, either.right().value());
- // }
- //
- //
- // @Test
- // public void testCreateUserInvalidEmail() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\": \"@sdc.com\",\"role\":
- // \"ADMIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value());
- // }
- //
- // @Test
- // public void testCreateUserInvalidRole() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\":
- // \"jb1234u@sdc.com\",\"role\": \"MIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value());
- // }
-
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java
new file mode 100644
index 0000000000..6558b140c7
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/RollbackManagerTest.java
@@ -0,0 +1,47 @@
+package org.openecomp.sdc.common.transaction.mngr;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.transaction.api.RollbackHandler;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBTypeEnum;
+import org.openecomp.sdc.common.util.MethodActivationStatusEnum;
+
+import fj.data.Either;
+
+public class RollbackManagerTest {
+
+ private RollbackManager createTestSubject() {
+ return new RollbackManager(null, "", "", null);
+ }
+
+
+ @Test
+ public void testTransactionRollback() throws Exception {
+ RollbackManager testSubject;
+ DBActionCodeEnum result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testAddRollbackHandler() throws Exception {
+ RollbackManager testSubject;
+ RollbackHandler rollbackHandler = null;
+ Either<RollbackHandler, MethodActivationStatusEnum> result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testGetRollbackHandler() throws Exception {
+ RollbackManager testSubject;
+ DBTypeEnum dbType = null;
+ Either<RollbackHandler, MethodActivationStatusEnum> result;
+
+ // default test
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java
new file mode 100644
index 0000000000..aca9db39c0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/TransactionManagerTest.java
@@ -0,0 +1,54 @@
+package org.openecomp.sdc.common.transaction.mngr;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.transaction.api.ITransactionSdnc;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.ActionTypeEnum;
+
+public class TransactionManagerTest {
+
+ private TransactionManager createTestSubject() {
+ return new TransactionManager();
+ }
+
+
+ @Test
+ public void testGetTransaction() throws Exception {
+ TransactionManager testSubject;
+ String userId = "";
+ ActionTypeEnum actionType = null;
+ ITransactionSdnc result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGenerateTransactionID() throws Exception {
+ TransactionManager testSubject;
+ Integer result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testResetTransactionId() throws Exception {
+ TransactionManager testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testInit() throws Exception {
+ TransactionManager testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+} \ No newline at end of file
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java
deleted file mode 100644
index 3e6e7706cb..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.impl.Neo4jResourceDAO;
-import org.openecomp.sdc.be.dao.neo4j.BatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public abstract class BasicDao implements IBasicDAO {
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName());
-
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable,
- Class<T> clazz, NodeTypeEnum nodeType) {
-
- if (graphNeighbourTable != null) {
-
- Either<BatchBuilder, Neo4jOperationStatus> bbResult = graphBatchBuilder
- .buildBatchBuilderFromTable(graphNeighbourTable);
-
- if (bbResult.isLeft()) {
-
- BatchBuilder batchBuilder = bbResult.left().value();
- // Neo4jOperationStatus neo4jOperationStatus =
- // neo4jClient.execute(batchBuilder);
- Either<List<List<GraphElement>>, Neo4jOperationStatus> executeResult = neo4jClient
- .execute(batchBuilder);
-
- if (executeResult.isRight()) {
- return Either.right(executeResult.right().value());
- }
-
- T result = null;
- List<List<GraphElement>> listOfResults = executeResult.left().value();
- if (listOfResults != null) {
- for (List<GraphElement> listOfElements : listOfResults) {
- if (listOfElements != null && false == listOfElements.isEmpty()) {
- for (GraphElement element : listOfElements) {
- logger.debug("element {} was returned after running batch operation {}",
- element, batchBuilder);
- if (element instanceof GraphNode) {
- GraphNode neo4jNode = (GraphNode) element;
- if (NodeTypeEnum.getByName(neo4jNode.getLabel()) == nodeType) {
- result = clazz.cast(neo4jNode);
- }
- }
- }
- }
- }
- }
-
- return Either.left(result);
-
- } else {
- return Either.right(bbResult.right().value());
- }
-
- } else {
- logger.error("The table sent in order to create resource is empty.");
- return Either.right(Neo4jOperationStatus.BAD_REQUEST);
- }
-
- }
-
- @Override
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String uniqueid, Class<T> clazz,
- NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), uniqueid);
-
- return getNodeData(filter, clazz, nodeTypeEnum);
-
- }
-
- @Override
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String uniqueid,
- Class<T> clazz, NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(keyName, uniqueid);
-
- return getNodeData(filter, clazz, nodeTypeEnum);
-
- }
-
- private <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(MatchFilter filter, Class<T> clazz,
- NodeTypeEnum nodeTypeEnum) {
-
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- nodeTypeEnum.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left(clazz.cast(value.get(0)));
- }
- }
- }
-
- @Override
- public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData(
- Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- if (propertiesToMatch != null) {
- for (Entry<String, Object> property : propertiesToMatch.entrySet()) {
- filter.addToMatch(property.getKey(), property.getValue());
- }
- }
-
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- nodeTypeEnum.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- List<T> list = new ArrayList<T>();
- for (GraphElement element : value) {
- list.add(clazz.cast(element));
- }
- return Either.left(list);
- }
- }
- }
-
- public Neo4jClient getNeo4jClient() {
- return neo4jClient;
- }
-
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java
deleted file mode 100644
index 3a2bfb34e8..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-import fj.data.Either;
-
-public interface IBasicDAO {
-
- /**
- * add the content of the graph neighbour table to the graph.
- *
- * @param graphNeighbourTable
- * @param clazz
- * - the type of the object to be returned
- * @param nodeType
- * - label of the node
- * @return Neo4jNode implementation
- */
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable,
- Class<T> clazz, NodeTypeEnum nodeType);
-
- /**
- * return the node data by unique id.
- *
- * @param id
- * - unique id of the node
- * @param clazz
- * @param nodeType
- * @return
- */
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String id, Class<T> clazz,
- NodeTypeEnum nodeType);
-
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String id, Class<T> clazz,
- NodeTypeEnum nodeType);
-
- public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData(
- Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java
deleted file mode 100644
index 17bded535c..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-public interface IPropertyDAO extends IBasicDAO {
-
- // Either<PropertyData, Neo4jOperationStatus>
- // createPropertyData(GraphNeighbourTable graphNeighbourTable);
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java
deleted file mode 100644
index 47bbcbcb11..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-
-import fj.data.Either;
-
-public interface IResourceDAO extends IBasicDAO {
-
- Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id);
-
- // Either<ResourceData, Neo4jOperationStatus>
- // createResourceData(GraphNeighbourTable graphNeighbourTable);
-
- /**
- * the method retrieves all the resources according to the supplied
- * properties, if none or null is supplied all the resources will be
- * returned.
- *
- * @param propertiesToMatch
- * a map of properties to match.
- * @return
- */
- Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData(Map<String, Object> propertiesToMatch);
-
- // ActionStatus updateUserData(UserData userData);
- //
- // ActionStatus deleteUserData(String id);
-
- void setNeo4jClient(Neo4jClient client);
-
- Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java
deleted file mode 100644
index d6b8d2eed8..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IElementDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("elements-dao")
-public class Neo4jElementDAO implements IElementDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jElementDAO.class.getName());
-
- @Override
- public Either<List<GraphElement>, ActionStatus> getAllCategories() {
- MatchFilter filter = new MatchFilter();
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.ResourceCategory.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value);
- }
- }
- }
-
- @Override
- public Either<List<GraphElement>, ActionStatus> getAllTags() {
- MatchFilter filter = new MatchFilter();
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Tag.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value);
- }
- }
- }
-
- @Override
- public Either<GraphElement, ActionStatus> getCategory(String name) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.ResourceCategory.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value.get(0));
- }
- }
-
- }
-
- /**
- * FOR TEST ONLY
- *
- * @param neo4jClient
- */
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java
deleted file mode 100644
index c9fcbab0de..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.dao.api.BasicDao;
-import org.openecomp.sdc.be.dao.api.IPropertyDAO;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-//@Component("neo4j-property-dao")
-public class Neo4jPropertyDAO extends BasicDao implements IPropertyDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jPropertyDAO.class.getName());
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- public Neo4jPropertyDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- setNeo4jClient(neo4jClient);
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java
deleted file mode 100644
index 8d961b10ec..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-
-import org.openecomp.sdc.be.dao.api.BasicDao;
-import org.openecomp.sdc.be.dao.api.IResourceDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-//@Component("neo4j-resource-dao")
-public class Neo4jResourceDAO extends BasicDao implements IResourceDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName());
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- public Neo4jResourceDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- super.setNeo4jClient(neo4jClient);
- }
-
- private String findResourceDataIdFromNodes(List<GraphNode> nodes) {
-
- if (nodes != null) {
-
- for (GraphNode neo4jNode : nodes) {
- String label = neo4jNode.getLabel();
- if (label.equals(NodeTypeEnum.Resource.getName())) {
- return neo4jNode.getUniqueId().toString();
- }
- }
- }
-
- return null;
- }
-
- private GraphRelation addStateRelation(RelationEndPoint from, RelationEndPoint to, GraphEdgeLabels edgeLabel,
- String value) {
-
- GraphRelation relationState = new GraphRelation();
- relationState.setFrom(from);
- relationState.setTo(to);
- relationState.setType(edgeLabel.name());
- relationState.setAction(ActionEnum.Create);
- return relationState;
- }
-
- // private ActionStatus convertNeo4jOperationStatusToActionStatus(
- // Neo4jOperationStatus value) {
- //
- // if (value == null) {
- // return ActionStatus.GENERAL_ERROR;
- // }
- //
- // switch (value) {
- // case NOT_FOUND:
- // return ActionStatus.RESOURCE_NOT_FOUND;
- // case ERROR:
- // return ActionStatus.GENERAL_ERROR;
- // case NOT_SUPPORTED:
- // return ActionStatus.INVALID_CONTENT;
- // case WRONG_INPUT:
- // return ActionStatus.INVALID_CONTENT;
- // case OK:
- // return ActionStatus.OK;
- // default:
- // return ActionStatus.GENERAL_ERROR;
- // }
- //
- // }
-
- @Override
- public Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), id);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Resource.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left((ResourceMetadataData) value.get(0));
- }
- }
- }
-
- @Override
- public Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Resource.getName(), filter);
-
- if (status.isRight() || (status.left().value() == null)) {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- return Either.left(value.size());
- }
- }
-
- @Override
- public void setNeo4jClient(Neo4jClient client) {
- this.neo4jClient = client;
- super.setNeo4jClient(client);
- }
-
- @Override
- public Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData(
- Map<String, Object> propertiesToMatch) {
-
- RecursiveFilter filter = new RecursiveFilter(NodeTypeEnum.Resource);
- // filter.addRelationType("typeof").addRelationType("belong").setProperties(propertiesToMatch);
-
- Either<List<List<GraphElement>>, Neo4jOperationStatus> ret = neo4jClient.executeGet(filter);
- if (ret.isRight()) {
- return Either.right(ret.right().value());
- }
- List<List<GraphElement>> listOfListOfNeo4jElement = ret.left().value();
-
- for (List<GraphElement> row : listOfListOfNeo4jElement) {
-
- for (GraphElement elem : row) {
-
- }
- }
- return Either.right(null);
-
- /*
- * MatchFilter filter = new MatchFilter(); if(propertiesToMatch !=
- * null){ for (Entry<String,Object> propertie :
- * propertiesToMatch.entrySet()){ filter.addToMatch(propertie.getKey(),
- * propertie.getValue()); } } Either<List<GraphElement>,
- * Neo4jOperationStatus> status =
- * neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- * NodeTypeEnum.Resource.getName(), filter); if (status.isRight()) {
- * return Either.right(status.right().value()); } else {
- * List<GraphElement> value = status.left().value(); if (value == null
- * || value.isEmpty()) { return
- * Either.right(Neo4jOperationStatus.NOT_FOUND); } else {
- * List<ResourceData> result=new ArrayList<>(); for(GraphElement element
- * : value ){ result.add((ResourceData)element); } return
- * Either.left(result); } }
- */
- }
-
- // @Override
- // public ActionStatus updateUserData(UserData userData) {
- // UpdateFilter filter = new UpdateFilter();
- // filter.addToMatch("userId", userData.getUserId());
- // filter.setToUpdate(userData.toMap());
- // Neo4jOperationStatus status =
- // neo4jClient.updateElement(Neo4JElementTypeEnum.Node,
- // NodeTypeEnum.User.getName(), filter);
- // if (status.equals(Neo4jOperationStatus.OK)) {
- // return ActionStatus.OK;
- // } else {
- // return ActionStatus.GENERAL_ERROR;
- // }
- // }
- //
- // @Override
- // public ActionStatus deleteUserData(String id) {
- // MatchFilter filter = new MatchFilter();
- // filter.addToMatch("userId", id);
- // Neo4jOperationStatus status =
- // neo4jClient.deleteElement(Neo4JElementTypeEnum.Node,
- // NodeTypeEnum.User.getName(), filter);
- // if (status.equals(Neo4jOperationStatus.OK)) {
- // return ActionStatus.OK;
- // } else {
- // return ActionStatus.GENERAL_ERROR;
- // }
- // }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java
deleted file mode 100644
index 14489ef04b..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IUsersDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.UserData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("users-dao")
-public class Neo4jUsersDAO implements IUsersDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jUsersDAO.class.getName());
-
- public Neo4jUsersDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- }
-
- private void createIndexesAndConstraints() {
- Either<Map<String, List<String>>, Neo4jOperationStatus> statusInd = neo4jClient
- .getIndexes(NodeTypeEnum.User.getName());
- if (statusInd.isRight()) {
- logger.error("Failed to get indexes from Neo4j graph");
- throw new RuntimeException("Failed to initialize Neo4jUsersDAO - Failed to get indexes from Neo4j graph");
- }
- Map<String, List<String>> indexes = statusInd.left().value();
- if (indexes == null || indexes.isEmpty()) {
- logger.info("Define users indexes in Neo4j");
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("firstName");
- propertyNames.add("lastName");
- propertyNames.add("email");
- propertyNames.add("role");
- logger.info("Start create Users indexes in Neo4jGraph");
- Neo4jOperationStatus createIndexStatus = neo4jClient.createIndex(NodeTypeEnum.User.getName(),
- propertyNames);
- if (createIndexStatus.equals(Neo4jOperationStatus.OK)) {
- logger.info("Users indexes created in Neo4j");
- List<String> propertyUnique = new ArrayList<String>();
- propertyUnique.add("userId");
-
- logger.info("Start create Users constraints in Neo4jGraph");
- Neo4jOperationStatus createUniquenessStatus = neo4jClient
- .createUniquenessConstraints(NodeTypeEnum.User.getName(), propertyUnique);
- if (createUniquenessStatus.equals(Neo4jOperationStatus.OK)) {
- logger.info("Users constraints creatyed in Neo4j");
- } else {
- logger.error("Failed to create constraints in Neo4j graph [{}]", createUniquenessStatus);
- throw new RuntimeException(
- "Failed to initialize Neo4jUsersDAO - Failed to create constraints in Neo4j graph");
- }
- } else {
- logger.error("Failed to create indexes in Neo4j graph [{}]", createIndexStatus);
- throw new RuntimeException(
- "Failed to initialize Neo4jUsersDAO - Failed to create indexes in Neo4j graph");
- }
- } else {
- logger.info("Users indexes already defined in Neo4j");
- }
- }
-
- @Override
- public Either<UserData, ActionStatus> getUserData(String id) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch("userId", id);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.User.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(ActionStatus.USER_NOT_FOUND);
- } else {
- return Either.left((UserData) value.get(0));
- }
- }
- }
-
- @Override
- public ActionStatus saveUserData(UserData userData) {
- Neo4jOperationStatus status = neo4jClient.createElement(userData);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- @Override
- public ActionStatus updateUserData(UserData userData) {
- UpdateFilter filter = new UpdateFilter();
- filter.addToMatch("userId", userData.getUserId());
- filter.setToUpdate(userData.toGraphMap());
- Neo4jOperationStatus status = neo4jClient.updateElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(),
- filter);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- @Override
- public ActionStatus deleteUserData(String id) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch("userId", id);
- Neo4jOperationStatus status = neo4jClient.deleteElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(),
- filter);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- public Neo4jClient getNeo4jClient() {
- return neo4jClient;
- }
-
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java
deleted file mode 100644
index 0177d0bd70..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-
-public class BatchBuilder {
- // private Map<String, List<Neo4jNode>> nodes;
- // private List<Neo4jRelation> relations;
- //
- private List<GraphElement> elements;
-
- // TODO add filter
-
- protected BatchBuilder() {
- // nodes = new HashMap<String, List<Neo4jNode>>();
- // relations = new ArrayList<Neo4jRelation>();
- elements = new ArrayList<GraphElement>();
- }
-
- public static BatchBuilder getBuilder() {
- return new BatchBuilder();
- }
-
- public BatchBuilder add(GraphElement element) {
- elements.add(element);
- return this;
- }
-
- public List<GraphElement> getElements() {
- return elements;
- }
-
- // public BatchBuilder add( Neo4jNode element ){
- // String label = element.getLabel();
- // List<Neo4jNode> list = nodes.get(label);
- // if ( list == null ){
- // list = new ArrayList<Neo4jNode>();
- // }
- // list.add(element);
- // nodes.put(label, list);
-
- // return this;
- // }
- // public BatchBuilder add( Neo4jRelation relation ){
- // relations.add(relation);
- // return this;
- // }
- //
- // public Map<String, List<Neo4jNode>> getNodes() {
- // return nodes;
- // }
- //
- // public List<Neo4jRelation> getRelations() {
- // return relations;
- // }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java
deleted file mode 100644
index b0b2cc20bb..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public interface CypherTemplates {
-
- public static final String CypherUrlTemplate = "http://$host$:$port$/db/data/transaction/commit";
- public static final String batchTemplate = "http://$host$:$port$/db/data/batch";
- public static final String getAllIndexsTemplate = "http://$host$:$port$/db/data/schema/index";
-
- public static final String CypherCreateNodeTemplate = "{\n\"statements\" : [ {\n \"statement\" : \"CREATE (n:$label$ { props } ) RETURN n\",\n \"parameters\" : { \n \"props\" : $props$ \n } } ] }";
-
- public static final String CypherMatchTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) RETURN ($type$) \" }]}";
-
- public static final String CypherUpdateTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) SET n += {props} RETURN ($type$) \",\"parameters\" : {\"props\" : {$props$}}}]}";
- public static final String CypherDeleteNodeTemplate = "{\"statements\": [{\"statement\": \"MATCH ( n:$label$ {$filter$} ) DELETE n \" }]}";
-
- public static final String BatchTemplate = "{ \"statements\" : [ $statementList$ ] }";
-
- public static final String RegularStatementTemplate = "{ \"statement\" : $statement$ }";
-
- public static final String CreateSingleNodeTemplate = " \"CREATE (n:$label$ { props } ) RETURN n, labels(n)\", \"parameters\" : { \"props\" : $props$ }";
-
- public static final String CreateRelationTemplate = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ { props } ]->(b) RETURN a, labels(a), b, labels(b), r, type(r)\", \"parameters\": {\"props\": $props$ } ";
-
- public static final String CreateRelationTemplateNoProps = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ ]->(b) RETURN a,labels(a), b, labels(b), r, type(r)\"";
-
- public static final String UpdateNodeStatementTemplate = "\"MATCH (n:$label$ {$filter$}) SET n += {props} \",\"parameters\" : {\"props\" : $props$}";
-
- public static final String GetNodeRecursiveTemplate = "\"MATCH (m:$label$ {$filter$} )-[f$typesList$]->l RETURN m, labels(m), l, labels(l),f, type(f)\"";
-
- public static final String GetByRelationNodeRecursiveTemplate = "\"MATCH (n:$labelNode$ ($propsNode$} )-[r:$type$ {$propsRel$}]->(m:$labelSrc$)-[f$typesList$]->l RETURN n, labels(n), r, type(r), m, labels(m), l, labels(l),f, type(f)\"";
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java
deleted file mode 100644
index e1409b3bb1..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveByRelationFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.dao.utils.DaoUtils;
-
-public class CypherTranslator {
-
- public String translate(BatchBuilder builder) {
- String json = null;
- StringBuilder statementList = new StringBuilder();
-
- List<GraphElement> elements = builder.getElements();
- int statementCounter = 0;
- for (GraphElement element : elements) {
- String singleStatementBody = null;
- switch (element.getElementType()) {
- case Node:
- singleStatementBody = prepareNodeStatement(element);
- break;
- case Relationship:
- singleStatementBody = prepareRelationStatement(element);
- break;
- }
- if (singleStatementBody != null && !singleStatementBody.isEmpty()) {
-
- String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$",
- singleStatementBody);
-
- statementList.append(singleStatement);
- }
- ++statementCounter;
- if (statementCounter < elements.size() && singleStatementBody != null) {
- statementList.append(",");
- }
-
- }
- json = CypherTemplates.BatchTemplate.replace("$statementList$", statementList.toString());
- return json;
- }
-
- private String prepareNodeStatement(GraphElement element) {
- if (element instanceof GraphNode) {
- GraphNode node = (GraphNode) element;
-
- switch (node.getAction()) {
- case Create:
- return createNodeStatement(node);
- case Update:
- return updateNodeStatement(node);
- case Delete:
- // TODO
- break;
- default:
- break;
- }
- }
- return null;
- }
-
- private String updateNodeStatement(GraphNode node) {
- String singleStatement = CypherTemplates.UpdateNodeStatementTemplate.replace("$label$", node.getLabel());
- String filter = prepareKeyValueFilter(node);
-
- singleStatement = singleStatement.replace("$filter$", filter);
-
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
-
- return singleStatement;
- }
-
- private String createNodeStatement(GraphNode node) {
- String singleStatement = CypherTemplates.CreateSingleNodeTemplate.replace("$label$", node.getLabel());
-
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
- return singleStatement;
- }
-
- private String prepareRelationStatement(GraphElement element) {
- if (element instanceof GraphRelation) {
-
- GraphRelation relation = (GraphRelation) element;
-
- switch (relation.getAction()) {
- case Create:
- return createRelationStatement(relation);
- case Update:
- return updateRelationStatement(relation);
- case Delete:
- // TODO
- break;
- default:
- break;
- }
- }
- return null;
- }
-
- private String createRelationStatement(GraphRelation relation) {
- RelationEndPoint from = relation.getFrom();
- String singleStatement;
-
- Map<String, Object> props = relation.toGraphMap();
- if (props == null || props.isEmpty()) {
- singleStatement = CypherTemplates.CreateRelationTemplateNoProps.replace("$labelFrom$",
- from.getLabel().getName());
- } else {
- singleStatement = CypherTemplates.CreateRelationTemplate.replace("$labelFrom$", from.getLabel().getName());
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(props));
- }
-
- singleStatement = singleStatement.replace("$idNameFrom$", from.getIdName());
- singleStatement = singleStatement.replace("$idValueFrom$", from.getIdValue().toString());
-
- RelationEndPoint to = relation.getTo();
- singleStatement = singleStatement.replace("$labelTo$", to.getLabel().getName());
- singleStatement = singleStatement.replace("$idNameTo$", to.getIdName());
- singleStatement = singleStatement.replace("$idvalueTo$", to.getIdValue().toString());
-
- singleStatement = singleStatement.replace("$type$", relation.getType());
- return singleStatement;
- }
-
- private String updateRelationStatement(GraphRelation relation) {
- // TODO
- return null;
- }
-
- private String prepareKeyValueFilter(GraphNode node) {
- StringBuilder sb = new StringBuilder();
-
- ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
-
- sb.append(keyValueId.getKey()).append(":");
- if (keyValueId.getValue() instanceof String) {
- sb.append("'");
- }
- sb.append(keyValueId.getValue());
-
- if (keyValueId.getValue() instanceof String) {
- sb.append("'");
- }
-
- return sb.toString();
- }
-
- public String translateGet(RecursiveFilter filter) {
- String requestJson = null;
- String statement;
-
- if (filter instanceof RecursiveByRelationFilter) {
- RecursiveByRelationFilter byRelationFilter = (RecursiveByRelationFilter) filter;
-
- statement = CypherTemplates.GetByRelationNodeRecursiveTemplate.replace("$labelNode$",
- byRelationFilter.getNode().getLabel());
- String keyValueId = prepareKeyValueFilter(byRelationFilter.getNode());
-
- statement = statement.replace("$propsNode$", keyValueId);
-
- statement = statement.replace("$type$", byRelationFilter.getRelationType());
-
- String relationProps = prepareFilterBody(filter);
- statement = statement.replace("$propsRel$", relationProps);
- statement = statement.replace("$labelSrc$", filter.getNodeType().getName());
-
- } else {
-
- statement = CypherTemplates.GetNodeRecursiveTemplate.replace("$label$", filter.getNodeType().getName());
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- statement = statement.replace("{$filter$}", "");
- } else {
- String filterStr = prepareFilterBody(filter);
- statement = statement.replace("$filter$", filterStr);
- }
- }
-
- if (filter.getChildRelationTypes() == null || filter.getChildRelationTypes().isEmpty()) {
- statement = statement.replace("$typesList$", "");
-
- } else {
- StringBuilder typesList = new StringBuilder();
- int count = 0;
- for (String type : filter.getChildRelationTypes()) {
- typesList.append(":").append(type);
- ++count;
- if (count < filter.getChildRelationTypes().size()) {
- typesList.append("|");
- }
- }
- statement = statement.replace("$typesList$", typesList.toString());
- }
- String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$", statement);
- requestJson = CypherTemplates.BatchTemplate.replace("$statementList$", singleStatement);
-
- return requestJson;
- }
-
- public static String prepareFilterBody(MatchFilter filter) {
- StringBuilder sb = new StringBuilder();
- int count = 0;
- int size = filter.getProperties().entrySet().size();
- for (Map.Entry<String, Object> entry : filter.getProperties().entrySet()) {
- sb.append(entry.getKey()).append(":");
- if (entry.getValue() instanceof String) {
- sb.append("'");
- }
- sb.append(entry.getValue());
- if (entry.getValue() instanceof String) {
- sb.append("'");
- }
- ++count;
- if (count < size) {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java
deleted file mode 100644
index ccfb57b145..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-
-public class GraphNeighbourTable {
-
- List<GraphNode> nodes = new ArrayList<GraphNode>();
-
- List<NodeRelation> directedEdges = new ArrayList<NodeRelation>();
-
- public List<GraphNode> getNodes() {
- return nodes;
- }
-
- public void setNodes(List<GraphNode> nodes) {
- this.nodes = nodes;
- }
-
- public List<NodeRelation> getDirectedEdges() {
- return directedEdges;
- }
-
- public void setDirectedEdges(List<NodeRelation> directedEdges) {
- this.directedEdges = directedEdges;
- }
-
- public int addNode(GraphNode node) {
- this.nodes.add(node);
- return this.nodes.size() - 1;
- }
-
- public void addEdge(NodeRelation directedEdge) {
- this.directedEdges.add(directedEdge);
- }
-
- @Override
- public String toString() {
- return "GraphNeighbourTable [nodes=" + nodes + ", directedEdges=" + directedEdges + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java
deleted file mode 100644
index eb279cda3d..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java
+++ /dev/null
@@ -1,1003 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.BasicResponseHandler;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter;
-import org.openecomp.sdc.be.dao.utils.DaoUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("neo4j-client")
-public class Neo4jClient {
- private CloseableHttpClient httpClient;
- private JSONParser jsonParser;
-
- private CypherTranslator cypherTranslator;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jClient.class.getName());
-
- private static final String getServiceRoot = "http://$host$:$port$/db/data/";
- // Error's Classification templates
- private static final String ClientError = "ClientError";
- private static final String DatabaseError = "DatabaseError";
- private static final String TransientError = "TransientError";
-
- // Error's Category templates
- private static final String General = "General";
- private static final String LegacyIndex = "LegacyIndex";
- private static final String Request = "Request";
- private static final String Schema = "Schema";
- private static final String Security = "Security";
- private static final String Statement = "Statement";
- private static final String Transaction = "Transaction";
-
- // Error's Title templates
- private static final String EntityNotFound = "EntityNotFound";
- private static final String ConstraintViolation = "ConstraintViolation";
-
- @PostConstruct
- public void init() {
-
- PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
- connectionManager.setMaxTotal(100);
- connectionManager.setDefaultMaxPerRoute(20);
- connectionManager.setValidateAfterInactivity(15000);
- this.httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();
- jsonParser = new JSONParser();
- cypherTranslator = new CypherTranslator();
-
- }
-
- @PreDestroy
- public void shutdown() {
- try {
- httpClient.close();
- logger.debug("Http client to Neo4j Graph closed");
- } catch (Exception e) {
- logger.info("Failed to close http client", e);
- }
- }
-
- /**
- *
- * @param builder
- * @return
- */
- public Either<List<List<GraphElement>>, Neo4jOperationStatus> execute(BatchBuilder builder) {
-
- String json = cypherTranslator.translate(builder);
- logger.debug("Try to execute cypher request [{}]", json);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(json);
- if (result.isRight()) {
- return Either.right(result.right().value());
- }
- List<List<GraphElement>> batchResult;
- try {
- batchResult = parseResult(result.left().value(), false);
- } catch (ParseException e) {
- logger.error("Failed to parse batchresponse", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(batchResult);
- }
-
- public Either<List<List<GraphElement>>, Neo4jOperationStatus> executeGet(RecursiveFilter filter) {
- String json = cypherTranslator.translateGet(filter);
- logger.debug("Try to execute cypher request [{}]", json);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(json);
- if (result.isRight()) {
- return Either.right(result.right().value());
- }
- List<List<GraphElement>> batchResult;
- try {
- batchResult = parseResult(result.left().value(), true);
- } catch (ParseException e) {
- logger.error("Failed to parse batchresponse", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(batchResult);
-
- }
-
- /**
- *
- * @param element
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Neo4jOperationStatus createElement(GraphElement element) {
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- switch (element.getElementType()) {
- case Node:
- Either<String, Neo4jOperationStatus> status = createNode(element);
- if (status.isRight()) {
- result = status.right().value();
- }
- break;
- case Relationship:
- // TODO
- break;
-
- default:
- break;
- }
-
- return result;
- }
-
- public Either<GraphElement, Neo4jOperationStatus> createSingleElement(GraphElement element) {
- switch (element.getElementType()) {
- case Node:
- Either<String, Neo4jOperationStatus> status = createNode(element);
- if (status.isRight()) {
- return Either.right(status.right().value());
- }
- // parse response
- String response = status.left().value();
- try {
- List<GraphElement> listElements = parseGetResponse(element.getElementType(),
- ((GraphNode) element).getLabel(), response);
- if (listElements == null || listElements.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left(listElements.get(0));
- }
- } catch (Exception e) {
- logger.error("Failed to parse fetched data from graph", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- case Relationship:
- // TODO
- break;
-
- default:
- break;
- }
-
- return Either.right(Neo4jOperationStatus.NOT_SUPPORTED);
- }
-
- /**
- *
- * @param type
- * @param label
- * @param filter
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Either<List<GraphElement>, Neo4jOperationStatus> getByFilter(GraphElementTypeEnum type, String label,
- MatchFilter filter) {
-
- List<GraphElement> result = null;
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "n");
- } else {
- requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "r");
- }
- // replace label
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(filter);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- logger.debug("Try to perform request []", requestJson);
-
- Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson);
- if (status.isRight()) {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- // parse response
- String response = status.left().value();
- try {
- result = parseGetResponse(type, label, response);
- } catch (Exception e) {
- logger.error("Failed to parse fetched data from graph", e);
- Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(result);
- }
-
- /**
- *
- * @param type
- * @param label
- * @param toMatch
- * @param toUpdate
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Neo4jOperationStatus updateElement(GraphElementTypeEnum type, String label, UpdateFilter toUpdate) {
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "n");
- } else {
- requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "r");
- }
- // replace label
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (toUpdate.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(toUpdate);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- String props = preparePropertiesInStatement(toUpdate.getToUpdate());
- requestJson = requestJson.replace("$props$", props);
-
- logger.debug("Try to perform request [{}]", requestJson);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(requestJson);
- if (result.isRight()) {
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- return Neo4jOperationStatus.OK;
- }
-
- /**
- *
- * @param type
- * @param label
- * @param response
- * @return
- * @throws ParseException
- */
-
- private List<GraphElement> parseGetResponse(GraphElementTypeEnum type, String label, String response)
- throws ParseException {
- List<GraphElement> result = new ArrayList<GraphElement>();
- JSONObject responseData = (JSONObject) jsonParser.parse(response);
- JSONArray results = (JSONArray) responseData.get("results");
- Iterator<JSONObject> iteratorResults = results.iterator();
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- // JSONArray data = (JSONArray) elementResult.get("row");
- JSONArray data = (JSONArray) elementResult.get("data");
-
- Iterator<JSONObject> iterator = data.iterator();
- JSONObject element;
- while (iterator.hasNext()) {
- element = (JSONObject) iterator.next();
- JSONArray row = (JSONArray) element.get("row");
-
- Iterator<JSONObject> iteratorRow = row.iterator();
- while (iteratorRow.hasNext()) {
- JSONObject rowElement = iteratorRow.next();
-
- Map<String, Object> props = new HashMap<String, Object>();
-
- for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) rowElement.entrySet()) {
- // props.put(entry.getKey(),
- // rowElement.get(entry.getValue()));
- props.put(entry.getKey(), entry.getValue());
- }
- GraphElement newElement = GraphElementFactory.createElement(label, type, props);
- result.add(newElement);
- }
- }
- }
- return result;
- }
-
- private List<List<GraphElement>> parseResult(String response, boolean storeRelationNode) throws ParseException {
-
- List<List<GraphElement>> batchList = new ArrayList<List<GraphElement>>();
-
- JSONObject responseData = (JSONObject) jsonParser.parse(response);
- JSONArray results = (JSONArray) responseData.get("results");
- Iterator<JSONObject> iteratorResults = results.iterator();
-
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- JSONArray data = (JSONArray) elementResult.get("data");
- JSONArray columns = (JSONArray) elementResult.get("columns");
- Iterator<JSONObject> iteratorData = data.iterator();
- List<GraphElement> singleDataList = new ArrayList<GraphElement>();
- while (iteratorData.hasNext()) {
-
- JSONObject singleData = iteratorData.next();
- JSONArray row = (JSONArray) singleData.get("row");
- if (columns.size() == 2) {
- // node
- JSONArray labelArray = (JSONArray) row.get(1);
- JSONObject node = (JSONObject) row.get(0);
-
- Map<String, Object> props = jsonObjectToMap(node);
- // get only first label on node. Now single label supported
- GraphElement newElement = GraphElementFactory.createElement((String) labelArray.get(0),
- GraphElementTypeEnum.Node, props);
- singleDataList.add(newElement);
- }
- if (columns.size() == 10) {
- // relation
- JSONObject startNode = (JSONObject) row.get(0);
- JSONArray startNodeArray = (JSONArray) row.get(1);
-
- JSONObject relationFromStart = (JSONObject) row.get(2);
- String relationFromStartType = (String) row.get(3);
-
- JSONObject nodeFrom = (JSONObject) row.get(4);
- JSONArray labelFromArray = (JSONArray) row.get(5);
-
- JSONObject nodeTo = (JSONObject) row.get(6);
- JSONArray labelToArray = (JSONArray) row.get(7);
-
- JSONObject relation = (JSONObject) row.get(8);
- String type = (String) row.get(9);
-
- Map<String, Object> propsStartNode = jsonObjectToMap(startNode);
- Map<String, Object> propsRelationStartNode = jsonObjectToMap(relationFromStart);
-
- Map<String, Object> propsFrom = jsonObjectToMap(nodeFrom);
- Map<String, Object> propsTo = jsonObjectToMap(nodeTo);
- Map<String, Object> propsRelation = jsonObjectToMap(relation);
-
- GraphNode startN = (GraphNode) GraphElementFactory.createElement((String) startNodeArray.get(0),
- GraphElementTypeEnum.Node, propsStartNode);
-
- GraphNode from = (GraphNode) GraphElementFactory.createElement((String) labelFromArray.get(0),
- GraphElementTypeEnum.Node, propsFrom);
- GraphNode to = (GraphNode) GraphElementFactory.createElement((String) labelToArray.get(0),
- GraphElementTypeEnum.Node, propsTo);
-
- singleDataList.add(startN);
-
- GraphElement relationFromStartNode = GraphElementFactory.createRelation(type,
- propsRelationStartNode, startN, from);
- singleDataList.add(relationFromStartNode);
-
- singleDataList.add(from);
- singleDataList.add(to);
- // get only first type on relationship. Now single type
- // supported
- GraphElement newElement = GraphElementFactory.createRelation(type, propsRelation, from, to);
- singleDataList.add(newElement);
- }
- if (columns.size() == 8) {
-
- }
- }
- batchList.add(singleDataList);
- }
- return batchList;
- }
-
- private Map<String, Object> jsonObjectToMap(JSONObject node) {
- Map<String, Object> props = new HashMap<String, Object>();
-
- for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) node.entrySet()) {
- props.put(entry.getKey(), entry.getValue());
- }
- return props;
- }
-
- private String preparePropertiesInStatement(Map<String, Object> properties) {
- StringBuilder sb = new StringBuilder();
- int count = 0;
- int size = properties.entrySet().size();
- for (Map.Entry<String, Object> entry : properties.entrySet()) {
- sb.append("\"").append(entry.getKey()).append("\"").append(":");
- if (entry.getValue() instanceof String) {
- sb.append("\"");
- }
- sb.append(entry.getValue());
- if (entry.getValue() instanceof String) {
- sb.append("\"");
- }
- ++count;
- if (count < size) {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
- private Either<String, Neo4jOperationStatus> createNode(GraphElement element) {
- Either<String, Neo4jOperationStatus> status;
- if (element instanceof GraphNode) {
- GraphNode node = (GraphNode) element;
- String json = prepareCreateNodeBody(node);
-
- logger.debug("Try to save Node [{}] on graph", json);
-
- status = sendPostCypher(json);
-
- return status;
-
- } else {
- return Either.right(Neo4jOperationStatus.WRONG_INPUT);
- }
- }
-
- private Either<String, Neo4jOperationStatus> sendPostCypher(String json) {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.CypherUrlTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
-
- response = httpClient.execute(post, context);
-
- int status = response.getStatusLine().getStatusCode();
- String responseString;
- responseString = new BasicResponseHandler().handleResponse(response);
- logger.debug("response [{}]", responseString);
-
- if (status == 200 || status == 201) {
- logger.debug("cypher request [{}] was succeeded", json);
- Neo4jOperationStatus responseStatus = checkResponse(responseString);
- if (Neo4jOperationStatus.OK.equals(responseStatus)) {
- return Either.left(responseString);
- } else {
- return Either.right(responseStatus);
- }
- } else {
- logger.debug("cypher request [{}] was failed : [{}]", json, responseString);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- } catch (HttpResponseException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- if (e.getStatusCode() == 401) {
- return Either.right(Neo4jOperationStatus.NOT_AUTHORIZED);
- } else {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- } catch (ClientProtocolException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- return Either.right(Neo4jOperationStatus.HTTP_PROTOCOL_ERROR);
- } catch (IOException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- return Either.right(Neo4jOperationStatus.NOT_CONNECTED);
- } finally {
- releaseResource(response);
- }
- }
-
- private Neo4jOperationStatus checkResponse(String responseString) {
- try {
- JSONObject response = (JSONObject) jsonParser.parse(responseString);
- JSONArray errors = (JSONArray) response.get("errors");
- if (errors.size() == 0) {
- return Neo4jOperationStatus.OK;
- } else {
- Iterator<JSONObject> iterator = errors.iterator();
- JSONObject error;
- while (iterator.hasNext()) {
- error = (JSONObject) iterator.next();
- String code = (String) error.get("code");
- String message = (String) error.get("message");
-
- Neo4jOperationStatus neoError = mapToNeoError(code, message);
- return neoError;
- }
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- } catch (ParseException e) {
- logger.error("Failed to parse response", e);
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- }
-
- private Neo4jOperationStatus mapToNeoError(String code, String message) {
- Neo4jOperationStatus error;
-
- String[] errorCode = code.split("\\.");
- if (errorCode.length < 4) {
- error = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- // by Classification
- switch (errorCode[1]) {
- case ClientError:
- // by Category
- switch (errorCode[2]) {
- case General:
- error = Neo4jOperationStatus.DB_READ_ONLY;
- break;
- case LegacyIndex:
- error = Neo4jOperationStatus.LEGACY_INDEX_ERROR;
- break;
- case Request:
- error = Neo4jOperationStatus.BAD_REQUEST;
- break;
- case Schema:
- if (errorCode[3].equals(ConstraintViolation)) {
- error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST;
- } else {
- error = Neo4jOperationStatus.SCHEMA_ERROR;
- }
- break;
- case Security:
- error = Neo4jOperationStatus.NOT_AUTHORIZED;
- break;
- case Statement:
- // by Title
- if (errorCode[3].equals(EntityNotFound)) {
- error = Neo4jOperationStatus.NOT_FOUND;
- } else {
- if (errorCode[3].equals(ConstraintViolation)) {
- error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST;
- } else {
- error = Neo4jOperationStatus.BAD_REQUEST;
- }
- }
- break;
- case Transaction:
- error = Neo4jOperationStatus.TRANSACTION_ERROR;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- break;
- case DatabaseError:
- // by Category
- switch (errorCode[2]) {
- case General:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- case Schema:
- error = Neo4jOperationStatus.SCHEMA_ERROR;
- break;
- case Statement:
- error = Neo4jOperationStatus.EXECUTION_FAILED;
- break;
- case Transaction:
- error = Neo4jOperationStatus.TRANSACTION_ERROR;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- break;
- case TransientError:
- error = Neo4jOperationStatus.DB_NOT_AVAILABLE;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- error.setOriginError(code).setMessage(message);
- String errorFromCfg = code.replace(".", "_");
- String helpMessage = ConfigurationManager.getConfigurationManager().getNeo4jErrorsConfiguration()
- .getErrorMessage(errorFromCfg);
- if (helpMessage != null && !helpMessage.isEmpty()) {
- error.setHelpErrorMsg(helpMessage);
- }
- }
- return error;
- }
-
- private String prepareCreateNodeBody(GraphNode node) {
-
- String body = CypherTemplates.CypherCreateNodeTemplate.replace("$label$", node.getLabel());
-
- body = body.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
-
- return body;
- }
-
- /**
- * the method returns all the indexes for the given label if no label is
- * supplied ( null or "") all indexes will be returned
- *
- * @param label
- * the name of the label
- * @param ip
- * @param user
- * @param password
- * @return a map of labels and there properties
- */
- public Either<Map<String, List<String>>, Neo4jOperationStatus> getIndexes(String label) {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = null;
- if (label == null || "".equals(label)) {
- uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host);
- } else {
- uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host) + "/" + label;
- }
- uri = uri.replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
-
- HttpGet get = new HttpGet(uri);
- get.setHeader("Content-Type", "application/json");
- get.setHeader("Accept", "application/json; charset=UTF-8");
-
- try {
-
- response = httpClient.execute(get, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to get indexes requeste returned {}", statusCode);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } else {
- Map<String, List<String>> labels = getLeablesFromJson(response);
- return Either.left(labels);
- }
- } catch (Exception e) {
- logger.debug("failed to get indexes ", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } finally {
- releaseResource(response);
-
- }
-
- }
-
- private Map<String, List<String>> getLeablesFromJson(CloseableHttpResponse response)
- throws HttpResponseException, IOException, ParseException {
- Map<String, List<String>> labels = new HashMap<>();
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONArray results = (JSONArray) jsonParser.parse(responseString);
- Iterator<JSONObject> iteratorResults = results.iterator();
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- String label = (String) elementResult.get("label");
- List<String> props = labels.get(label);
- if (props == null) {
- props = new ArrayList<>();
- labels.put(label, props);
- }
- JSONArray properties = (JSONArray) elementResult.get("property_keys");
- Iterator<String> iterator = properties.iterator();
- while (iterator.hasNext()) {
- props.add(iterator.next());
- }
- }
- return labels;
- }
-
- public Neo4jOperationStatus createIndex(String label, List<String> propertyNames) {
-
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- if (propertyNames != null && !propertyNames.isEmpty()) {
-
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.batchTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- String opertionUri = "/schema/index/" + label;
-
- HttpClientContext context = creatClientContext(host, user, password);
-
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
-
- String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames);
-
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
- response = httpClient.execute(post, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to create index for label [{}] with properties:{} requeste returned {}",label,propertyNames,statusCode);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- logger.debug("index for label [{}] with properties: {} created", label, propertyNames);
- }
- } catch (Exception e) {
- logger.debug("failed to create index for label [{}] with properties: {}", label, propertyNames);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } finally {
-
- releaseResource(response);
-
- }
-
- }
-
- else {
- logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames);
- return Neo4jOperationStatus.WRONG_INPUT;
- }
-
- return result;
- }
-
- public Neo4jOperationStatus createUniquenessConstraints(String label, List<String> propertyNames) {
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- if (propertyNames != null && !propertyNames.isEmpty()) {
-
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.batchTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- String opertionUri = "/schema/constraint/" + label + "/uniqueness/";
-
- HttpClientContext context = creatClientContext(host, user, password);
-
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
-
- String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames);
-
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
- response = httpClient.execute(post, context);
-
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to create uniqueness constraint for label [{}] on properties:{}. request returned ",
- label,propertyNames,statusCode);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- logger.debug("uniqueness constraint for label [{}] on properties:{} created",label,propertyNames);
- }
- } catch (Exception e) {
- logger.error("failed to create uniqueness constraint [{}] with properties:{}",label,propertyNames,e);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } finally {
- releaseResource(response);
- }
-
- }
-
- else {
- logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames);
- return Neo4jOperationStatus.WRONG_INPUT;
- }
-
- return result;
- }
-
- public Neo4jOperationStatus deleteElement(GraphElementTypeEnum type, String label, MatchFilter filter) {
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- logger.debug("removing node label: {}", label);
- requestJson = createDeleteNodeStatment(label, filter);
-
- } else {
- logger.error(" delete on type {} is not yet supported", type);
- throw new RuntimeException(" delete on type " + type + " is not yet supported");
- }
-
- logger.debug("Try to perform request [{}]", requestJson);
-
- Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson);
- if (status.isRight()) {
- logger.error(" delete request failed with: {}", status.right());
- return Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- return Neo4jOperationStatus.OK;
- }
- }
-
- public String getNeo4jVersion() throws Exception {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = getServiceRoot.replace("$host$", host).replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
- String result = null;
-
- HttpGet get = new HttpGet(uri);
- get.setHeader("Content-Type", "application/json");
- get.setHeader("Accept", "application/json; charset=UTF-8");
-
- try {
- response = httpClient.execute(get, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- throw new Exception("Couldn't get Neo4j service root, HTTP status " + statusCode);
- } else {
- // Parse response
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseData = (JSONObject) jsonParser.parse(responseString);
- Object obj = responseData.get("neo4j_version");
- if (obj != null) {
- result = (String) obj;
- }
- return result;
- }
- } finally {
- releaseResource(response);
- }
- }
-
- private String createDeleteNodeStatment(String label, MatchFilter filter) {
- String requestJson;
- requestJson = CypherTemplates.CypherDeleteNodeTemplate;
-
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(filter);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- return requestJson;
- }
-
- /*
- * removed do to fortify scan CredentialsProvider cp = new
- * BasicCredentialsProvider(); cp.setCredentials(AuthScope.ANY, new
- * UsernamePasswordCredentials(user, password)); AuthCache authCache = new
- * BasicAuthCache(); BasicScheme basicAuth = new BasicScheme();
- * authCache.put(new HttpHost(ip, 7474, "http"), basicAuth);
- * context.setAuthCache(authCache); context.setCredentialsProvider(cp);
- *
- */
- private HttpClientContext creatClientContext(String ip, String user, String password) {
- HttpClientContext context = HttpClientContext.create();
-
- return context;
- }
-
- private void releaseResource(CloseableHttpResponse response) {
- if (response != null) {
- try {
- HttpEntity entity = response.getEntity();
- EntityUtils.consume(entity);
- response.close();
- } catch (Exception e) {
- logger.error("failed to close connection exception", e);
- }
- }
- }
-
- private String createBatchJson(HttpMethod method, String opertionUri, List<String> propertyNames) {
- StringBuilder sb = new StringBuilder();
- sb.append("[ ");
- for (int i = 0; i < propertyNames.size(); i++) {
- sb.append("{ \"method\" : \"" + method + "\" , \"to\" : \"" + opertionUri
- + "\" , \"body\" : { \"property_keys\" : [ \"" + propertyNames.get(i) + "\" ] } }");
- if (i + 1 < propertyNames.size()) {
- sb.append(",");
- }
- }
- sb.append(" ]");
- String json = sb.toString();
- return json;
- }
-
- enum HttpMethod {
- GET, PUT, POST, DELETE
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java
deleted file mode 100644
index e8278a9a3e..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-
-public class Neo4jEdge {
-
- private GraphEdgeLabels edgeType;
- private Map<String, Object> properties;
- private ActionEnum action;
-
- public Neo4jEdge(GraphEdgeLabels edgeType, Map<String, Object> properties, ActionEnum actionEnum) {
- super();
- this.edgeType = edgeType;
- this.properties = properties;
- this.action = actionEnum;
- }
-
- public GraphEdgeLabels getEdgeType() {
- return edgeType;
- }
-
- public void setEdgeType(GraphEdgeLabels edgeType) {
- this.edgeType = edgeType;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public ActionEnum getAction() {
- return action;
- }
-
- public void setAction(ActionEnum action) {
- this.action = action;
- }
-
- @Override
- public String toString() {
- return "Neo4jEdge [edgeType=" + edgeType + ", properties=" + properties + ", action=" + action + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java
deleted file mode 100644
index 5a6a8fdade..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public class Neo4jGraphBatchBuilder {
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jGraphBatchBuilder.class.getName());
-
- public Either<BatchBuilder, Neo4jOperationStatus> buildBatchBuilderFromTable(
- GraphNeighbourTable graphNeighbourTable) {
-
- logger.debug("The table sent in order to build BatchBuilder is {}", graphNeighbourTable);
-
- List<GraphNode> nodes = graphNeighbourTable.getNodes();
- if (nodes != null && nodes.size() > 0) {
- List<NodeRelation> directedEdges = graphNeighbourTable.getDirectedEdges();
-
- List<RelationEndPoint> relationEndPoints = new ArrayList<RelationEndPoint>(nodes.size());
- Set<Integer> nodesInRelations = findDistinctNodesIndex(directedEdges);
-
- buildRelationEndPoints(nodes, nodesInRelations, relationEndPoints);
-
- BatchBuilder batchBuilder = BatchBuilder.getBuilder();
-
- for (GraphElement neo4jElement : nodes) {
- if (neo4jElement.getAction() != ActionEnum.Delete) {
- logger.debug("Goint to add node {} to batch builder.", neo4jElement);
- batchBuilder.add(neo4jElement);
- }
- }
-
- if (directedEdges != null) {
- for (NodeRelation nodeRelation : directedEdges) {
- GraphRelation relation = buildNeo4jRelation(relationEndPoints, nodeRelation);
- logger.debug("Goint to add relation {} to batch builder.", relation);
- batchBuilder.add(relation);
- }
- }
-
- for (GraphElement neo4jElement : nodes) {
- if (neo4jElement.getAction() == ActionEnum.Delete) {
- logger.debug("Goint to add node {} to batch builder.", neo4jElement);
- batchBuilder.add(neo4jElement);
- }
- }
-
- return Either.left(batchBuilder);
-
- } else {
- logger.error("No node was sent in order to create the resource.");
- return Either.right(Neo4jOperationStatus.BAD_REQUEST);
- }
- }
-
- private Pair<String, String> getUniqueIdKeyValue(GraphNode neo4jNode) {
-
- // String label = neo4jNode.getLabel();
- // NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getByName(label);
- //
- return Pair.createPair(neo4jNode.getUniqueIdKey(), neo4jNode.getUniqueId().toString());
- }
-
- private Set<Integer> findDistinctNodesIndex(List<NodeRelation> directedEdges) {
-
- HashSet<Integer> nodesIndex = new HashSet<Integer>();
-
- if (directedEdges != null) {
- for (NodeRelation nodeRelation : directedEdges) {
- nodesIndex.add(nodeRelation.getFromIndex());
- nodesIndex.add(nodeRelation.getToIndex());
- }
- }
-
- return nodesIndex;
- }
-
- private String findResourceDataIdFromNodes(List<GraphNode> nodes) {
-
- if (nodes != null) {
-
- for (GraphNode neo4jNode : nodes) {
- String label = neo4jNode.getLabel();
- if (label.equals(NodeTypeEnum.Resource.getName())) {
- return neo4jNode.getUniqueId().toString();
- }
- }
- }
-
- return null;
- }
-
- private GraphRelation buildNeo4jRelation(List<RelationEndPoint> relationEndPoints, NodeRelation nodeRelation) {
- GraphRelation relation = new GraphRelation();
- int fromIndex = nodeRelation.getFromIndex();
- int toIndex = nodeRelation.getToIndex();
- Neo4jEdge neo4jEdge = nodeRelation.getEdge();
- relation.setFrom(relationEndPoints.get(fromIndex));
- relation.setTo(relationEndPoints.get(toIndex));
- relation.setType(neo4jEdge.getEdgeType().getProperty());
-
- // TODO: fix it after change
- Map<String, Object> edgeProps = neo4jEdge.getProperties();
- if (edgeProps != null && false == edgeProps.isEmpty()) {
- relation.addPropertis(edgeProps);
- }
-
- relation.setAction(neo4jEdge.getAction());
- return relation;
- }
-
- private void buildRelationEndPoints(List<GraphNode> nodes, Set<Integer> nodesInRelations,
- List<RelationEndPoint> relationEndPoints) {
-
- if (nodesInRelations != null) {
- for (Integer nodeIndex : nodesInRelations) {
-
- GraphElement neo4jElement = nodes.get(nodeIndex);
- GraphNode neo4jNode = (GraphNode) neo4jElement;
- String label = neo4jNode.getLabel();
- Pair<String, String> uniqueKeyValue = getUniqueIdKeyValue(neo4jNode);
-
- RelationEndPoint endPoint = new RelationEndPoint(NodeTypeEnum.getByName(label), uniqueKeyValue.getKey(),
- uniqueKeyValue.getValue());
- relationEndPoints.add(nodeIndex, endPoint);
-
- }
- }
-
- }
-
- public static class Pair<K, V> {
-
- private final K key;
- private final V value;
-
- public static <K, V> Pair<K, V> createPair(K key, V value) {
- return new Pair<K, V>(key, value);
- }
-
- public Pair(K key, V value) {
- this.key = key;
- this.value = value;
- }
-
- public K getKey() {
- return key;
- }
-
- public V getValue() {
- return value;
- }
-
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java
deleted file mode 100644
index 154449b521..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public enum Neo4jOperationStatus {
-
- OK, NOT_CONNECTED, NOT_AUTHORIZED, HTTP_PROTOCOL_ERROR, DB_NOT_AVAILABLE, DB_READ_ONLY, BAD_REQUEST, LEGACY_INDEX_ERROR, SCHEMA_ERROR, TRANSACTION_ERROR, EXECUTION_FAILED, ENTITY_ALREADY_EXIST,
-
- WRONG_INPUT, GENERAL_ERROR, NOT_SUPPORTED, NOT_FOUND;
-
- private String originError;
- private String message;
- private String helpErrorMsg;
-
- private static final String NA = "NA";
-
- Neo4jOperationStatus() {
- originError = NA;
- message = NA;
- helpErrorMsg = NA;
- }
-
- public Neo4jOperationStatus setOriginError(String originError) {
- this.originError = originError;
- return this;
- }
-
- public Neo4jOperationStatus setMessage(String message) {
- if (message != null && !message.isEmpty()) {
- this.message = message;
- }
- return this;
- }
-
- public Neo4jOperationStatus setHelpErrorMsg(String helpErrorMsg) {
- this.helpErrorMsg = helpErrorMsg;
- return this;
- }
-
- public String getOriginError() {
- return originError;
- }
-
- public String getMessage() {
- return message;
- }
-
- public String getHelpErrorMsg() {
- return helpErrorMsg;
- }
-
- public String printError() {
- StringBuilder sb = new StringBuilder();
- sb.append("[").append(toString()).append("-").append(originError).append("-").append(helpErrorMsg).append("-")
- .append(message).append("]");
- return sb.toString();
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java
deleted file mode 100644
index c1402f402f..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public class NodeRelation {
-
- private int fromIndex;
- private int toIndex;
- private Neo4jEdge edge;
-
- public NodeRelation(int fromIndex, int toIndex, Neo4jEdge edge) {
- super();
- this.fromIndex = fromIndex;
- this.toIndex = toIndex;
- this.edge = edge;
- }
-
- public int getFromIndex() {
- return fromIndex;
- }
-
- public void setFromIndex(int fromIndex) {
- this.fromIndex = fromIndex;
- }
-
- public int getToIndex() {
- return toIndex;
- }
-
- public void setToIndex(int toIndex) {
- this.toIndex = toIndex;
- }
-
- public Neo4jEdge getEdge() {
- return edge;
- }
-
- public void setEdge(Neo4jEdge edge) {
- this.edge = edge;
- }
-
- @Override
- public String toString() {
- return "NodeRelation [fromIndex=" + fromIndex + ", toIndex=" + toIndex + ", edge=" + edge + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java
deleted file mode 100644
index 10e93c1f56..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MatchFilter {
- private Map<String, Object> toMatchProperties;
-
- public MatchFilter() {
- toMatchProperties = new HashMap<String, Object>();
- }
-
- public MatchFilter(Map<String, Object> toMatchProperties) {
- super();
- this.toMatchProperties = toMatchProperties;
- }
-
- public Map<String, Object> getProperties() {
- return toMatchProperties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.toMatchProperties = properties;
- }
-
- public MatchFilter addToMatch(String propName, Object value) {
- toMatchProperties.put(propName, value);
- return this;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java
deleted file mode 100644
index 698077d45b..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-public class RecursiveByRelationFilter extends RecursiveFilter {
-
- private GraphNode node;
- private String relationType;
-
- public RecursiveByRelationFilter() {
- super();
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node) {
- super(nodeType);
- this.node = node;
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType) {
- super(nodeType);
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node, String relationType) {
- super(nodeType);
- this.node = node;
- this.relationType = relationType;
- }
-
- public RecursiveByRelationFilter addNode(GraphNode node) {
- this.node = node;
- return this;
- }
-
- public RecursiveByRelationFilter addRelation(String relationType) {
- this.relationType = relationType;
- return this;
- }
-
- public GraphNode getNode() {
- return node;
- }
-
- public void setNode(GraphNode node) {
- this.node = node;
- }
-
- public String getRelationType() {
- return relationType;
- }
-
- public void setRelationType(String relationType) {
- this.relationType = relationType;
- }
-
- @Override
- public String toString() {
- return "RecursiveByRelationFilter [node=" + node + ", relationType=" + relationType + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java
deleted file mode 100644
index fa78539f8f..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-public class RecursiveFilter extends MatchFilter {
-
- private List<String> childRelationTypes;
- NodeTypeEnum nodeType;
-
- public RecursiveFilter() {
- childRelationTypes = new ArrayList<String>();
- }
-
- public RecursiveFilter(NodeTypeEnum nodeType) {
- childRelationTypes = new ArrayList<String>();
- this.nodeType = nodeType;
- }
-
- public RecursiveFilter addChildRelationType(String type) {
- childRelationTypes.add(type);
- return this;
- }
-
- public List<String> getChildRelationTypes() {
- return childRelationTypes;
- }
-
- public void setChildRelationTypes(List<String> childRelationTypes) {
- this.childRelationTypes = childRelationTypes;
- }
-
- public NodeTypeEnum getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(NodeTypeEnum nodeType) {
- this.nodeType = nodeType;
- }
-
- @Override
- public String toString() {
- return "RecursiveFilter [childRelationTypes=" + childRelationTypes + ", nodeType=" + nodeType + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java
deleted file mode 100644
index 3abfdeb70e..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class UpdateFilter extends MatchFilter {
-
- private Map<String, Object> toUpdate;
-
- public UpdateFilter(Map<String, Object> toUpdate) {
- super();
- this.toUpdate = toUpdate;
- }
-
- public UpdateFilter() {
- super();
- toUpdate = new HashMap<String, Object>();
- }
-
- public UpdateFilter(Map<String, Object> toMatch, Map<String, Object> toUpdate) {
- super(toMatch);
- this.toUpdate = toUpdate;
- }
-
- public Map<String, Object> getToUpdate() {
- return toUpdate;
- }
-
- public void setToUpdate(Map<String, Object> toUpdate) {
- this.toUpdate = toUpdate;
- }
-
- public void addToUpdate(String property, Object value) {
- toUpdate.put(property, value);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java
deleted file mode 100644
index 529f642fb2..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.Map;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-
-
-public class MatchFilterTest {
-
- private MatchFilter createTestSubject() {
- return new MatchFilter();
- }
-
-
- @Test
- public void testGetProperties() throws Exception {
- MatchFilter testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
-
- @Test
- public void testSetProperties() throws Exception {
- MatchFilter testSubject;
- Map<String, Object> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
-
- @Test
- public void testAddToMatch() throws Exception {
- MatchFilter testSubject;
- String propName = "";
- Object value = null;
- MatchFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addToMatch(propName, value);
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java
deleted file mode 100644
index 76b36d2a97..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-
-
-public class RecursiveByRelationFilterTest {
-
- private RecursiveByRelationFilter createTestSubject() {
- return new RecursiveByRelationFilter();
- }
-
-
- @Test
- public void testAddNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode node = null;
- RecursiveByRelationFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addNode(node);
- }
-
-
- @Test
- public void testAddRelation() throws Exception {
- RecursiveByRelationFilter testSubject;
- String relationType = "";
- RecursiveByRelationFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addRelation(relationType);
- }
-
-
- @Test
- public void testGetNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNode();
- }
-
-
- @Test
- public void testSetNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode node = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNode(node);
- }
-
-
- @Test
- public void testGetRelationType() throws Exception {
- RecursiveByRelationFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRelationType();
- }
-
-
- @Test
- public void testSetRelationType() throws Exception {
- RecursiveByRelationFilter testSubject;
- String relationType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRelationType(relationType);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RecursiveByRelationFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java
deleted file mode 100644
index 990a2b4972..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.List;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-
-public class RecursiveFilterTest {
-
- private RecursiveFilter createTestSubject() {
- return new RecursiveFilter();
- }
-
-
- @Test
- public void testAddChildRelationType() throws Exception {
- RecursiveFilter testSubject;
- String type = "";
- RecursiveFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addChildRelationType(type);
- }
-
-
- @Test
- public void testGetChildRelationTypes() throws Exception {
- RecursiveFilter testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getChildRelationTypes();
- }
-
-
- @Test
- public void testSetChildRelationTypes() throws Exception {
- RecursiveFilter testSubject;
- List<String> childRelationTypes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setChildRelationTypes(childRelationTypes);
- }
-
-
- @Test
- public void testGetNodeType() throws Exception {
- RecursiveFilter testSubject;
- NodeTypeEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeType();
- }
-
-
- @Test
- public void testSetNodeType() throws Exception {
- RecursiveFilter testSubject;
- NodeTypeEnum nodeType = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNodeType(nodeType);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RecursiveFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java
deleted file mode 100644
index 55a9255d31..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.Map;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-
-
-public class UpdateFilterTest {
-
- private UpdateFilter createTestSubject() {
- return new UpdateFilter(null);
- }
-
-
- @Test
- public void testGetToUpdate() throws Exception {
- UpdateFilter testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getToUpdate();
- }
-
-
- @Test
- public void testSetToUpdate() throws Exception {
- UpdateFilter testSubject;
- Map<String, Object> toUpdate = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setToUpdate(toUpdate);
- }
-
-
-
-} \ No newline at end of file
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java
deleted file mode 100644
index 55531fec79..0000000000
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model.operations.impl;
-
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-public class Neo4jStatusConverter {
-
- public static StorageOperationStatus convertNeo4jStatusToStorageStatus(Neo4jOperationStatus neo4jStatus) {
-
- if (neo4jStatus == null) {
- return StorageOperationStatus.GENERAL_ERROR;
- }
-
- switch (neo4jStatus) {
-
- case OK:
- return StorageOperationStatus.OK;
-
- case NOT_CONNECTED:
- return StorageOperationStatus.CONNECTION_FAILURE;
-
- case NOT_AUTHORIZED:
- return StorageOperationStatus.PERMISSION_ERROR;
-
- case HTTP_PROTOCOL_ERROR:
- return StorageOperationStatus.HTTP_PROTOCOL_ERROR;
- case DB_NOT_AVAILABLE:
- return StorageOperationStatus.STORAGE_NOT_AVAILABLE;
- case DB_READ_ONLY:
- return StorageOperationStatus.READ_ONLY_STORAGE;
- case BAD_REQUEST:
- return StorageOperationStatus.BAD_REQUEST;
- case LEGACY_INDEX_ERROR:
- return StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR;
- case SCHEMA_ERROR:
- return StorageOperationStatus.SCHEMA_ERROR;
- case TRANSACTION_ERROR:
- return StorageOperationStatus.TRANSACTION_ERROR;
- case EXECUTION_FAILED:
- return StorageOperationStatus.EXEUCTION_FAILED;
- case ENTITY_ALREADY_EXIST:
- return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
- case WRONG_INPUT:
- return StorageOperationStatus.BAD_REQUEST;
- case GENERAL_ERROR:
- return StorageOperationStatus.GENERAL_ERROR;
- case NOT_SUPPORTED:
- return StorageOperationStatus.OPERATION_NOT_SUPPORTED;
- case NOT_FOUND:
- return StorageOperationStatus.NOT_FOUND;
-
- default:
- return StorageOperationStatus.GENERAL_ERROR;
- }
-
- }
-
-}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java
new file mode 100644
index 0000000000..8b259f7cb8
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/version/VersionTest.java
@@ -0,0 +1,133 @@
+package org.openecomp.sdc.be.model.tosca.version;
+
+import java.util.StringTokenizer;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+
+public class VersionTest {
+
+ private Version createTestSubject() {
+ return new Version("");
+ }
+
+
+ @Test
+ public void testHashCode() throws Exception {
+ Version testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+
+ @Test
+ public void testEquals() throws Exception {
+ Version testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+
+
+ @Test
+ public void testCompareTo() throws Exception {
+ Version testSubject;
+ Version otherVersion = null;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ }
+
+
+ @Test
+ public void testGetMajorVersion() throws Exception {
+ Version testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getMajorVersion();
+ }
+
+
+ @Test
+ public void testGetMinorVersion() throws Exception {
+ Version testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getMinorVersion();
+ }
+
+
+ @Test
+ public void testGetIncrementalVersion() throws Exception {
+ Version testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getIncrementalVersion();
+ }
+
+
+ @Test
+ public void testGetBuildNumber() throws Exception {
+ Version testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getBuildNumber();
+ }
+
+
+ @Test
+ public void testGetQualifier() throws Exception {
+ Version testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getQualifier();
+ }
+
+
+ @Test
+ public void testParseVersion() throws Exception {
+ Version testSubject;
+ String version = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.parseVersion(version);
+ }
+
+
+ @Test
+ public void testGetNextIntegerToken() throws Exception {
+ Integer result;
+
+ // default test
+ }
+
+
+ @Test
+ public void testToString() throws Exception {
+ Version testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+} \ No newline at end of file
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java
index a01c761072..bb4c569f8a 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/rest/api/RestResponseAsByteArrayTest.java
@@ -3,6 +3,8 @@ package org.openecomp.sdc.common.rest.api;
import javax.annotation.Generated;
import org.junit.Test;
+import java.util.*;
+import org.junit.Assert;
public class RestResponseAsByteArrayTest {
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ConfigurationChangeNotifier.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ConfigurationChangeNotifier.java
index 5c3df4a56d..3922720d48 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ConfigurationChangeNotifier.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/ConfigurationChangeNotifier.java
@@ -24,10 +24,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
@@ -44,15 +44,15 @@ import javax.management.ObjectName;
*/
public final class ConfigurationChangeNotifier {
- private HashMap<String, List<NotificationData>> store = new HashMap<>();
- private ScheduledExecutorService executor =
+ private final HashMap<String, List<NotificationData>> store = new HashMap<>();
+ private final ScheduledExecutorService executor =
Executors.newScheduledThreadPool(5, ConfigurationUtils.getThreadFactory());
- private ExecutorService notificationExcecutor =
+ private final ExecutorService notificationExecutor =
Executors.newCachedThreadPool(ConfigurationUtils.getThreadFactory());
- private Map<String, WatchService> watchServiceCollection =
+ private final Map<String, WatchService> watchServiceCollection =
Collections.synchronizedMap(new HashMap<>());
- {
+ static {
if (!Thread.currentThread().getStackTrace()[2].getClassName()
.equals(ConfigurationImpl.class.getName())) {
throw new RuntimeException("Illegal access.");
@@ -66,13 +66,13 @@ public final class ConfigurationChangeNotifier {
*/
public ConfigurationChangeNotifier(Map<String, AggregateConfiguration> inMemoryConfig) {
executor.scheduleWithFixedDelay(() -> this
- .pollFilesystemAndUpdateConfigurationIfREquired(inMemoryConfig,
+ .pollFilesystemAndUpdateConfigurationIfRequired(inMemoryConfig,
System.getProperty("config.location"), false), 1, 1, TimeUnit.MILLISECONDS);
executor.scheduleWithFixedDelay(() -> this
- .pollFilesystemAndUpdateConfigurationIfREquired(inMemoryConfig,
+ .pollFilesystemAndUpdateConfigurationIfRequired(inMemoryConfig,
System.getProperty("tenant.config.location"), true), 1, 1, TimeUnit.MILLISECONDS);
executor.scheduleWithFixedDelay(() -> this
- .pollFilesystemAndUpdateNodeSpecificConfigurationIfREquired(
+ .pollFilesystemAndUpdateNodeSpecificConfigurationIfRequired(
System.getProperty("node.config.location")), 1, 1, TimeUnit.MILLISECONDS);
}
@@ -91,13 +91,13 @@ public final class ConfigurationChangeNotifier {
}
/**
- * Poll filesystem and update configuration if r equired.
+ * Poll filesystem and update configuration if required.
*
* @param inMemoryConfig the in memory config
* @param location the location
* @param isTenantLocation the is tenant location
*/
- public void pollFilesystemAndUpdateConfigurationIfREquired(
+ public void pollFilesystemAndUpdateConfigurationIfRequired(
Map<String, AggregateConfiguration> inMemoryConfig, String location,
boolean isTenantLocation) {
try {
@@ -132,20 +132,19 @@ public final class ConfigurationChangeNotifier {
updateConfigurationValues(tenantNamespaceArray[0], tenantNamespaceArray[1], map);
}
} else {
- Iterator<String> repoKeys = inMemoryConfig.keySet().iterator();
- while (repoKeys.hasNext()) {
- repositoryKey = repoKeys.next();
+ for (String configKey : inMemoryConfig.keySet()) {
+ repositoryKey = configKey;
AggregateConfiguration config = inMemoryConfig.get(repositoryKey);
if (config.containsConfig(file)) {
LinkedHashMap origConfig = ConfigurationUtils.toMap(config.getFinalConfiguration());
config.removeConfig(file);
LinkedHashMap latestConfig =
- ConfigurationUtils.toMap(config.getFinalConfiguration());
+ ConfigurationUtils.toMap(config.getFinalConfiguration());
Map map = ConfigurationUtils.diff(origConfig, latestConfig);
String[] tenantNamespaceArray =
- repositoryKey.split(Constants.KEY_ELEMENTS_DELEMETER);
+ repositoryKey.split(Constants.KEY_ELEMENTS_DELEMETER);
updateConfigurationValues(tenantNamespaceArray[0], tenantNamespaceArray[1],
- map);
+ map);
}
}
}
@@ -169,26 +168,26 @@ public final class ConfigurationChangeNotifier {
}
/**
- * Poll filesystem and update node specific configuration if r equired.
+ * Poll filesystem and update node specific configuration if required.
*
* @param location the location
*/
- public void pollFilesystemAndUpdateNodeSpecificConfigurationIfREquired(String location) {
+ public void pollFilesystemAndUpdateNodeSpecificConfigurationIfRequired(String location) {
try {
Set<Path> paths = watchForChange(location);
if (paths != null) {
for (Path path : paths) {
File file = path.toAbsolutePath().toFile();
- String repositoryKey = null;
+
if (ConfigurationUtils.isConfig(file)) {
- repositoryKey = ConfigurationUtils.getConfigurationRepositoryKey(file);
+ String repositoryKey = ConfigurationUtils.getConfigurationRepositoryKey(file);
ConfigurationRepository.lookup().populateOverrideConfigurtaion(repositoryKey, file);
} else {
ConfigurationRepository.lookup().removeOverrideConfigurtaion(file);
}
}
}
- } catch (Throwable exception) {
+ } catch (Exception exception) {
exception.printStackTrace();
}
}
@@ -241,7 +240,7 @@ public final class ConfigurationChangeNotifier {
private void triggerScanning(String key) {
if (store.get(key) != null) {
- notificationExcecutor.submit(() -> scanForChanges(key));
+ notificationExecutor.submit(() -> scanForChanges(key));
} else {
throw new IllegalArgumentException("Notification service for " + key + " is suspended.");
}
@@ -250,13 +249,9 @@ public final class ConfigurationChangeNotifier {
private void scanForChanges(String key) {
List<NotificationData> list = store.get(key);
if (list != null) {
- int size = list.size();
- for (int i = 0; i < size; i++) {
- NotificationData notificationData = list.get(i);
- if (notificationData.isChanged()) {
- notificationExcecutor.submit(() -> sendNotification(notificationData));
- }
- }
+ list.stream()
+ .filter(NotificationData::isChanged)
+ .forEach(notificationData -> notificationExecutor.submit(() -> sendNotification(notificationData)));
}
}
@@ -321,24 +316,24 @@ public final class ConfigurationChangeNotifier {
/**
* The type Notification data.
*/
- class NotificationData {
+ static class NotificationData {
/**
* The Tenant.
*/
- String tenant;
+ final String tenant;
/**
* The Namespace.
*/
- String namespace;
+ final String namespace;
/**
* The Key.
*/
- String key;
+ final String key;
/**
* The Myself.
*/
- ConfigurationChangeListener myself;
+ final ConfigurationChangeListener myself;
/**
* The Current value.
*/
@@ -381,8 +376,17 @@ public final class ConfigurationChangeNotifier {
return false;
}
NotificationData nd = (NotificationData) obj;
- return tenant.equals(nd.tenant) && namespace.equals(nd.namespace) && key.equals(nd.key)
- && myself.equals(nd.myself);
+ return Objects.equals(tenant, nd.tenant)
+ && Objects.equals(namespace, nd.namespace)
+ && Objects.equals(key, nd.key)
+ && Objects.equals(myself, nd.myself)
+ && Objects.equals(currentValue, nd.currentValue) // it's either String or List<String>
+ && isArray == nd.isArray;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tenant, namespace, key, myself, currentValue, isArray);
}
/**
@@ -424,7 +428,7 @@ public final class ConfigurationChangeNotifier {
Method method = null;
Vector<Object> parameters = null;
try {
- Object latestValue = null;
+ Object latestValue;
if (isArray) {
latestValue = ConfigurationManager.lookup().getAsStringValues(tenant, namespace, key);
} else {
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
index 7eb591c6d2..731826b53c 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ConfigSourceLocationTest.java
@@ -33,10 +33,10 @@ public class ConfigSourceLocationTest {
Properties props = new Properties();
props.setProperty("maxCachedBufferSize", "1024");
props.setProperty("artifact.maxsize", "1024");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Config Property at Conventional Resource");
+ }
}
@Test
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
index 1ca41f8a81..2140e84873 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/DynamicConfigurationTest.java
@@ -39,10 +39,10 @@ public class DynamicConfigurationTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "20");
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
//Verify configuration with Configuration without wait. This should fetch cached value
Assert.assertEquals("14" , config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
@@ -60,7 +60,7 @@ public class DynamicConfigurationTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
index 795780b83b..43729cbaf2 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NodeSpecificCLITest.java
@@ -51,10 +51,10 @@ public class NodeSpecificCLITest {
Properties props = new Properties();
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "50");
props.setProperty("_config.namespace",NAMESPACE);
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
Thread.sleep(35000);
@@ -86,7 +86,7 @@ public class NodeSpecificCLITest {
//Verify maxlength on other nodes by deleting node specific configuration
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
Thread.sleep(35000);
@@ -103,7 +103,7 @@ public class NodeSpecificCLITest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
index 3d1579e25e..9d719103df 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationForNodeConfigTest.java
@@ -25,7 +25,7 @@ import java.util.Properties;
public class NotificationForNodeConfigTest {
public final static String NAMESPACE = "NotificationForNodeConfig";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -42,10 +42,10 @@ public class NotificationForNodeConfigTest {
Properties props = new Properties();
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "30");
props.setProperty("_config.namespace",NAMESPACE);
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
Thread.sleep(35000);
@@ -55,9 +55,9 @@ public class NotificationForNodeConfigTest {
config.addConfigurationChangeListener(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, new NodePropValListener());
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "80");
- out = new FileOutputStream( f );
- props.store(out, "Updated Node Config Property");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Updated Node Config Property");
+ }
Thread.sleep(35000);
@@ -79,7 +79,7 @@ public class NotificationForNodeConfigTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
index 8a461503ae..7354cd19f7 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/NotificationOnPropValTest.java
@@ -25,7 +25,7 @@ public class NotificationOnPropValTest {
public final static String NAMESPACE = "NotificationOnPropVal";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -45,10 +45,10 @@ public class NotificationOnPropValTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "20");
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
- File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ File f = new File(TestUtil.jsonSchemaLoc + "config.properties");
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
Thread.sleep(35000);
@@ -70,7 +70,7 @@ public class NotificationOnPropValTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
index a53f3c2d40..e387f13e93 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/UnregisterNotificationTest.java
@@ -25,7 +25,7 @@ import java.util.Properties;
public class UnregisterNotificationTest {
public final static String NAMESPACE = "UnregisterNotification";
- public String updatedValue = null;
+ private String updatedValue = null;
@Before
public void setUp() throws IOException {
@@ -70,9 +70,9 @@ public class UnregisterNotificationTest {
props.setProperty("_config.namespace",NAMESPACE);
props.setProperty("_config.mergeStrategy","override");
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Override Config Property at Conventional Resource");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Override Config Property at Conventional Resource");
+ }
}
private class PropertyListener implements ConfigurationChangeListener {
@@ -88,7 +88,7 @@ public class UnregisterNotificationTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
}
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
index 03a6786275..8f7d703468 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-test/src/test/java/org/openecomp/config/test/ValidateNodeConfigTest.java
@@ -40,9 +40,9 @@ public class ValidateNodeConfigTest {
props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "56");
props.setProperty("_config.namespace","ValidateNodeConfig");
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
- OutputStream out = new FileOutputStream( f );
- props.store(out, "Node Config Property");
- out.close();
+ try (OutputStream out = new FileOutputStream(f)) {
+ props.store(out, "Node Config Property");
+ }
System.out.println(System.getProperty("node.config.location"));
@@ -73,7 +73,7 @@ public class ValidateNodeConfigTest {
TestUtil.cleanUp();
File f = new File(TestUtil.jsonSchemaLoc+"config.properties");
if(f.exists()) {
- boolean isDeleted = f.delete();
+ f.delete();
}
}
diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst
index bdc5034eb0..349e7bad4f 100644
--- a/docs/offeredapis.rst
+++ b/docs/offeredapis.rst
@@ -1,13 +1,14 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-Offered APIs
-============
+=============
+Offered API’s
+=============
-:Date: 2017-10-18
+:Date: 2017-10-23
.. contents::
- :depth: 3
+ :depth: 4
..
Overview
@@ -7519,7 +7520,7 @@ Consumer credentials
Description
~~~~~~~~~~~
-Returns created ECOMP consumer credentials
+Returns created ONAP consumer credentials
Parameters
~~~~~~~~~~
@@ -7675,8 +7676,8 @@ Tags
- Consumer Servlet
-Retrieve ecomp portal menu - MOC
---------------------------------
+Retrieve ONAP portal menu - MOC
+-------------------------------
::
@@ -7685,7 +7686,7 @@ Retrieve ecomp portal menu - MOC
Description
~~~~~~~~~~~
-Retrieve ecomp portal menu
+Retrieve ONAP portal menu
Responses
~~~~~~~~~
@@ -7694,7 +7695,7 @@ Responses
| HTTP | Description | Schema |
| Code | | |
+=========+====================================================+================+
-| **200** | Retrieve ecomp portal menu | No Content |
+| **200** | Retrieve ONAP portal menu | No Content |
+---------+----------------------------------------------------+----------------+
Consumes
diff --git a/onboarding/pom.xml b/onboarding/pom.xml
index f0a2edcd75..50f4649c11 100644
--- a/onboarding/pom.xml
+++ b/onboarding/pom.xml
@@ -2,7 +2,6 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
<artifactId>sdc-onboarding</artifactId>
<packaging>pom</packaging>
@@ -95,7 +94,7 @@
<woodstox.version>4.4.1</woodstox.version>
<ws.rs.version>2.0.1</ws.rs.version> <!-- New version 2.0.1 to fix blackduck violation Failing with comiplation issues-->
<zusammen.version>0.2.0</zusammen.version>
- <zusammen-state-store.version>0.2.1</zusammen-state-store.version>
+ <zusammen-state-store.version>0.2.2</zusammen-state-store.version>
<skipSA>true</skipSA>
<pmd.version>5.8.1</pmd.version>
<build.tools.version>${project.version}</build.tools.version>
@@ -108,7 +107,7 @@
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
<configuration>
- <skip>${skipSA}</skip>
+ <skip>${pmd.skip}</skip>
</configuration>
<executions>
<execution>
@@ -126,9 +125,10 @@
<artifactId>maven-pmd-plugin</artifactId>
<version>3.8</version>
<configuration>
- <skip>${skipSA}</skip>
+ <skip>${pmd.skip}</skip>
<aggregate>false</aggregate>
- <targetJdk>${maven.compiler.target}</targetJdk>
+ <includeTests>${pmd.include.tests}</includeTests>
+ <printFailingErrors>true</printFailingErrors>
<rulesets>
<ruleset>build-pmd-ruleset.xml</ruleset>
</rulesets>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
index 53ebf0baab..875b51548e 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
@@ -557,15 +557,13 @@ public class ActionsImpl implements Actions {
ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE);
}
- InputStream artifactInputStream = null;
- try {
- artifactInputStream = artifactToUpload.getDataHandler().getInputStream();
+ try (InputStream artifactInputStream = artifactToUpload.getDataHandler().getInputStream()) {
+ payload = FileUtils.toByteArray(artifactInputStream);
} catch (IOException exception) {
LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception);
throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR);
}
- payload = FileUtils.toByteArray(artifactInputStream);
//Validate Artifact size
if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) {
throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR);
@@ -761,15 +759,14 @@ public class ActionsImpl implements Actions {
}
if (artifactToUpdate != null) {
- InputStream artifactInputStream = null;
- try {
- artifactInputStream = artifactToUpdate.getDataHandler().getInputStream();
+
+ try (InputStream artifactInputStream = artifactToUpdate.getDataHandler().getInputStream()) {
+ payload = FileUtils.toByteArray(artifactInputStream);
} catch (IOException exception) {
LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception);
throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR);
}
- payload = FileUtils.toByteArray(artifactInputStream);
//Validate Artifact size
if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) {
throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE,
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java
index 6bfd50b401..80160bc202 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java
@@ -24,14 +24,15 @@ import java.io.Serializable;
public enum ActivityType implements Serializable {
- CREATE_NEW("Create New"),
- CHECKOUT("Check Out"),
- CHECKIN("Check In"),
- UPLOAD_HEAT("Upload Heat"),
+ CREATE_NEW("Create New"),
+ CHECKOUT("Check Out"),
+ UNDO_CHECKOUT("Undo Check Out"),
+ CHECKIN("Check In"),
+ UPLOAD_HEAT("Upload Heat"),
UPLOAD_MONITORING_FILE("Upload Monitoring File"),
- SUBMIT("Submit");
+ SUBMIT("Submit");
- // after collaboration will be added - this will be added:
+ // after collaboration will be added - this will be added:
/*
CREATE_NEW,
COMMIT,
@@ -39,14 +40,14 @@ public enum ActivityType implements Serializable {
REMOVE_PERMISSION,
*/
- private String name;
+ private String name;
- ActivityType(String name) {
- this.name = name;
- }
+ ActivityType(String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return name;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
index ddb56ddbfc..1d1ce4f03c 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
@@ -62,20 +62,19 @@ import java.util.zip.ZipInputStream;
*/
public class UploadValidationManagerImpl implements UploadValidationManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
private static FileContentHandler getFileContentMapFromZip(byte[] uploadFileData)
throws IOException, CoreException {
+
ZipEntry zipEntry;
List<String> folderList = new ArrayList<>();
FileContentHandler mapFileContent = new FileContentHandler();
- try {
- ZipInputStream inputZipStream;
+ try (ZipInputStream inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData))) {
byte[] fileByteContent;
String currentEntryName;
- inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData));
while ((zipEntry = inputZipStream.getNextEntry()) != null) {
currentEntryName = zipEntry.getName();
@@ -130,7 +129,7 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
throws IOException {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null, (String[]) null);
ValidationFileResponse validationFileResponse = new ValidationFileResponse();
@@ -150,15 +149,12 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
Map<String, List<ErrorMessage>> errors = validateHeatUploadData(content);
tree = HeatTreeManagerUtil.initHeatTreeManager(content);
tree.createTree();
- if (MapUtils.isNotEmpty(errors)) {
-
+ if (MapUtils.isNotEmpty(errors)) {
tree.addErrors(errors);
validationStructureList.setImportStructure(tree.getTree());
- //validationFileResponse.setStatus(ValidationFileStatus.Failure);
- } else {
- //validationFileResponse.setStatus(ValidationFileStatus.Success);
}
+
} else {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.VALIDATE_FILE_TYPE, ErrorLevel.ERROR.name(),
@@ -167,12 +163,11 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
}
validationFileResponse.setValidationData(validationStructureList);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null, (String[]) null);
return validationFileResponse;
}
- private Map<String, List<ErrorMessage>> validateHeatUploadData(FileContentHandler fileContentMap)
- throws IOException {
+ private Map<String, List<ErrorMessage>> validateHeatUploadData(FileContentHandler fileContentMap) {
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
return validationManager.validate();
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
index 924a956628..53b05eb953 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
@@ -29,6 +29,7 @@ import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@@ -43,11 +44,12 @@ public class ValidationManagerUtil {
* @param errors the errors
*/
public static void handleMissingManifest(FileContentHandler fileContentMap,
- Map<String, List<ErrorMessage>> errors) {
- InputStream manifest = fileContentMap.getFileContent(SdcCommon.MANIFEST_NAME);
- if (manifest == null) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.MANIFEST_NAME, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage()));
+ Map<String, List<ErrorMessage>> errors) throws IOException {
+ try (InputStream manifest = fileContentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ if (manifest == null) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.MANIFEST_NAME, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage()));
+ }
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
index edbf165ec1..e07a13c2e8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
@@ -24,7 +24,6 @@ import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICE
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -41,17 +40,11 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
-import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
-import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
-import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
@@ -64,10 +57,8 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
@@ -151,6 +142,12 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
Version newVersion = versioningManager
.undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
+
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor() + 1),
+ ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+
vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index 4df00fd74a..a3d0286019 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -50,10 +50,10 @@ import java.io.InputStream;
import java.util.Collection;
public class ProcessManagerImpl implements ProcessManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogManager activityLogManager;
+ private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+ private final ActivityLogManager activityLogManager;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
+ private final VendorSoftwareProductDao vendorSoftwareProductDao;
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@@ -66,15 +66,15 @@ public class ProcessManagerImpl implements ProcessManager {
public Collection<ProcessEntity> listProcesses(String vspId, Version version,
String componentId,
String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
return vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
}
@Override
public void deleteProcesses(String vspId, Version version, String componentId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
Collection<ProcessEntity> processes =
vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
@@ -87,12 +87,12 @@ public class ProcessManagerImpl implements ProcessManager {
vendorSoftwareProductDao.deleteProcesses(vspId, version, componentId);
}
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public ProcessEntity createProcess(ProcessEntity process, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
@@ -102,7 +102,7 @@ public class ProcessManagerImpl implements ProcessManager {
createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
return process;
@@ -112,20 +112,20 @@ public class ProcessManagerImpl implements ProcessManager {
@Override
public ProcessEntity getProcess(String vspId, Version version, String componentId,
String processId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
validateProcessExistence(vspId, version, componentId, processId, retrieved);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
return retrieved;
}
@Override
public void updateProcess(ProcessEntity process, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
ProcessEntity retrieved = vendorSoftwareProductDao
@@ -138,14 +138,14 @@ public class ProcessManagerImpl implements ProcessManager {
retrieved.getName(), process.getName());
vendorSoftwareProductDao.updateProcess(process);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
}
@Override
public void deleteProcess(String vspId, Version version, String componentId, String processId,
String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
@@ -155,33 +155,30 @@ public class ProcessManagerImpl implements ProcessManager {
deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
retrieved.getName());
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public File getProcessArtifact(String vspId, Version version, String componentId,
String processId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
- try {
- FileOutputStream fos = new FileOutputStream(file);
+ try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(retrieved.getArtifact().array());
- fos.close();
} catch (IOException exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.GET_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build());
+ throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
}
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
return file;
}
@@ -189,7 +186,7 @@ public class ProcessManagerImpl implements ProcessManager {
@Override
public void deleteProcessArtifact(String vspId, Version version, String componentId,
String processId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
@@ -197,14 +194,14 @@ public class ProcessManagerImpl implements ProcessManager {
vendorSoftwareProductDao.deleteProcessArtifact(vspId, version, componentId, processId);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
Version version, String componentId, String processId,
String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
@@ -221,11 +218,10 @@ public class ProcessManagerImpl implements ProcessManager {
try {
artifact = FileUtils.toByteArray(artifactFile);
} catch (RuntimeException exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build());
+ throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
}
vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
@@ -234,13 +230,13 @@ public class ProcessManagerImpl implements ProcessManager {
ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
activityLogManager.addActionLog(activityLogEntity, user);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
private void validateProcessExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
processId);
if (retrieved != null) {
@@ -250,13 +246,13 @@ public class ProcessManagerImpl implements ProcessManager {
new ProcessEntity(vspId, version, componentId, processId),
VspDetails.ENTITY_TYPE);//todo retrieved is always null ??
- mdcDataDebugMessage.debugExitMessage("VSP id, component id, process id", vspId, componentId,
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
processId);
}
private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
processId);
if (retrieved != null) {
@@ -269,7 +265,7 @@ public class ProcessManagerImpl implements ProcessManager {
VspDetails.ENTITY_TYPE); //todo retrieved is always null ??
}
- mdcDataDebugMessage.debugExitMessage("VSP id, component id, process id", vspId, componentId,
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
processId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 1891cddfd5..dde5d61663 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -146,25 +146,25 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
//private static final String VALIDATION_VSP_USER = "validationOnlyVspUser";
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final Logger logger =
+ private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+ private static final Logger LOGGER =
LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
- private OrchestrationTemplateDao orchestrationTemplateDao;
- private VendorSoftwareProductInfoDao vspInfoDao;
- private VersioningManager versioningManager;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
- private VendorLicenseFacade vendorLicenseFacade;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
- private HealingManager healingManager;
- private VendorLicenseArtifactsService licenseArtifactsService;
- private InformationArtifactGenerator informationArtifactGenerator;
- private PackageInfoDao packageInfoDao;
- private ActivityLogManager activityLogManager;
- private DeploymentFlavorDao deploymentFlavorDao;
- private NicDao nicDao;
- private ManualVspToscaManager manualVspToscaManager;
+ private final OrchestrationTemplateDao orchestrationTemplateDao;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final VersioningManager versioningManager;
+ private final VendorSoftwareProductDao vendorSoftwareProductDao;
+ private final VendorLicenseFacade vendorLicenseFacade;
+ private final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private final EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private final HealingManager healingManager;
+ private final VendorLicenseArtifactsService licenseArtifactsService;
+ private final InformationArtifactGenerator informationArtifactGenerator;
+ private final PackageInfoDao packageInfoDao;
+ private final ActivityLogManager activityLogManager;
+ private final DeploymentFlavorDao deploymentFlavorDao;
+ private final NicDao nicDao;
+ private final ManualVspToscaManager manualVspToscaManager;
/**
* Instantiates a new Vendor software product manager.
@@ -230,7 +230,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public Version checkout(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_Entity.toString());
Version newVersion = versioningManager
@@ -244,18 +244,24 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
activityLogManager.addActionLog(activityLogEntity, user);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
return newVersion;
}
@Override
public Version undoCheckout(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
Version version =
getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user)
.getActiveVersion();
+
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(version.getMajor() + 1),
+ ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+
String preVspName = vspInfoDao
.get(new VspDetails(vendorSoftwareProductId, version)).getName();
@@ -269,14 +275,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
updateUniqueName(preVspName, postVspName);
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
return newVersion;
}
@Override
public Version checkin(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
Version newVersion = versioningManager.checkin(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
@@ -289,14 +295,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
activityLogManager.addActionLog(activityLogEntity, user);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
return newVersion;
}
@Override
public ValidationResponse submit(String vspId, String user) throws IOException {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
Version version = getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
VspDetails vspDetails = getVsp(vspId, version, user);
@@ -373,7 +379,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
activityLogManager.addActionLog(activityLogEntity, user);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return validationResponse;
}
@@ -391,7 +397,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Collection<ErrorCode> deploymentFlavorValidation(String vspId,
Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
Set<CompositionEntityValidationData> validationData = new HashSet<>();
Collection<ErrorCode> errorCodeList = new ArrayList<>();
Collection<DeploymentFlavorEntity> deploymentFlavors =
@@ -407,8 +413,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
getFeatureGroupMandatoryErrorBuilder(deploymentlocalFlavor.getModel());
errorCodeList.add(deploymentFlavorErrorBuilder);
}
- List<ComponentComputeAssociation> componetComputeAssociations = new ArrayList<>();
- componetComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
+ List<ComponentComputeAssociation> componetComputeAssociations =
+ deploymentlocalFlavor.getComponentComputeAssociations();
if (CollectionUtils.isEmpty(componetComputeAssociations)) {
CompositionEntityValidationData compositionEntityValidationData = new
CompositionEntityValidationData(CompositionEntityType.deployment, deploymentFlavor
@@ -445,7 +451,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private Set<CompositionEntityValidationData> componentValidation(String vspId, Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
Set<CompositionEntityValidationData> validationData = new HashSet<>();
Collection<ComponentEntity> components =
@@ -572,8 +578,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
return SchemaGenerator
.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
}
@@ -600,7 +606,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
if (MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, enrichErrors))) {
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.ENRICHMENT_COMPLETED
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.ENRICHMENT_COMPLETED
+ vendorSoftwareProductId);
} else {
enrichErrors.values().forEach(errorList ->
@@ -615,7 +621,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspDetails.getId());
if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null
|| vspDetails.getLicenseAgreement() == null
@@ -623,7 +629,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return null;
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspDetails.getId());
return vendorLicenseFacade
.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(),
vspDetails.getLicenseAgreement(), vspDetails.getFeatureGroups());
@@ -634,7 +640,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
try {
validateUniqueName(VALIDATION_VSP_NAME);
} catch (Exception ignored) {
- logger.debug("", ignored);
+ LOGGER.debug("Ignored exception when validating unique VSP name", ignored);
return VALIDATION_VSP_ID;
}
VspDetails validationVsp = new VspDetails();
@@ -653,7 +659,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public VspDetails createVsp(VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
validateUniqueName(vspDetails.getName());
@@ -673,13 +679,13 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
activityLogManager.addActionLog(activityLogEntity, user);
String vspName = vspDetails.getName();
createUniqueName(vspName);
- mdcDataDebugMessage.debugExitMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
return vspDetails;
}
@Override
public List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user) {
- mdcDataDebugMessage.debugEntryMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
Map<String, VersionInfo> idToVersionsInfo = versioningManager.listEntitiesVersionInfo(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
@@ -708,25 +714,23 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
}
} catch (RuntimeException rte) {
- logger.debug("", rte);
- logger.error(
+ LOGGER.error(
"Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
() + "] " +
- "message:" + rte
- .getMessage());
+ "message:" + rte.getMessage(), rte);
}
}
sortVspListByModificationTimeDescOrder(vsps);
- mdcDataDebugMessage.debugExitMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
return vsps;
}
@Override
public void updateVsp(VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
if (!Objects.equals(retrieved.getOnboardingMethod(), vspDetails.getOnboardingMethod())) {
@@ -750,7 +754,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vspInfoDao.update(vspDetails);
//vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
- mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspDetails.getId());
}
private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
@@ -779,7 +783,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public VspDetails getVsp(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
if (vsp == null) {
@@ -797,7 +801,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vsp.setNetworkPackageName("Upload File");
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return vsp;
}
@@ -847,12 +851,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public void deleteVsp(String vspId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_VSP, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Unsupported operation");
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
throw new UnsupportedOperationException(
VendorSoftwareProductConstants.UNSUPPORTED_OPERATION_ERROR);
@@ -860,7 +864,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public void heal(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
@@ -876,17 +880,17 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vspDetails.setOldVersion(null);
vspInfoDao.updateOldVersionIndication(vspDetails);
- logger.audit("Healed VSP " + vspDetails.getId());
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ LOGGER.audit("Healed VSP " + vspDetails.getId());
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
- if (errorMessages.isPresent()) {
+ errorMessages.ifPresent(s -> {
throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(errorMessages.get()).build());
- }
+ .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
+ });
}
private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
checkoutVersion.setStatus(VersionStatus.Locked);
Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
@@ -897,13 +901,13 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vspDetails.setOldVersion(null);
vspInfoDao.updateOldVersionIndication(vspDetails);
- logger.audit("Healed VSP " + vspDetails.getName());
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ LOGGER.audit("Healed VSP " + vspDetails.getName());
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
- if (errorMessages.isPresent()) {
+ errorMessages.ifPresent(s -> {
throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(errorMessages.get()).build());
- }
+ .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
+ });
}
private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
@@ -923,7 +927,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public File getTranslatedFile(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
String errorMessage;
if (version == null) {
errorMessage = "Package not found";
@@ -960,10 +964,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
- try {
- FileOutputStream fos = new FileOutputStream(translatedFile);
+ try (FileOutputStream fos = new FileOutputStream(translatedFile)) {
fos.write(translatedFileBuffer.array());
- fos.close();
} catch (IOException exception) {
errorMessage = "Can't create package";
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -973,7 +975,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
exception);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return translatedFile;
}
@@ -981,7 +983,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public byte[] getOrchestrationTemplateFile(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
ByteBuffer contentData = uploadData.getContentData();
@@ -1002,13 +1004,13 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return baos.toByteArray();
}
@Override
public PackageInfo createPackage(String vspId, Version version, String user) throws IOException {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
if (!version.isFinal()) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -1036,9 +1038,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfoDao.create(packageInfo);
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_PACKAGE + vspId);
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_PACKAGE + vspId);
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return packageInfo;
}
@@ -1059,7 +1061,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
VersioningUtil.validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version),
@@ -1071,7 +1073,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
questionnaireResponse.setData(questionnaireData);
questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return questionnaireResponse;
}
@@ -1079,11 +1081,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData,
String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
}
@@ -1122,7 +1124,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
String onboardingMethod) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
// The apis of CompositionEntityDataManager used here are stateful!
// so, it must be re-created from scratch when it is used!
@@ -1168,18 +1170,18 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
compositionEntityDataManager.getEntityListWithErrors();*/
//Collection<CompositionEntityValidationData> roots = compositionEntityDataManager.getTrees();
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return new QuestionnaireValidationResult(
compositionEntityDataManager.getAllErrorsByVsp(vspId));
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return null;
}
@Override
public File getInformationArtifact(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
if (vspDetails == null) {
@@ -1196,14 +1198,15 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
infoArtifactFile =
new File(
String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
- OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile));
- out.write(infoArtifactAsByteBuffer.array());
- out.close();
+ try (OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile))) {
+ out.write(infoArtifactAsByteBuffer.array());
+ }
+
} catch (IOException ex) {
throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return infoArtifactFile;
}
@@ -1233,7 +1236,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
- logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
+ LOGGER.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
vspId));
}
});
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index 53d34749e7..db0851cd5f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -22,10 +22,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.*;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.ELIGBLE_FOLDERS;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.ELIGIBLE_FILES;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME;
+
public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler
implements OrchestrationTemplateFileHandler {
@@ -59,14 +62,22 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
}
private void validateManifest(UploadFileResponse uploadFileResponse, FileContentHandler contentMap) {
+
if (!validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)){
return;
}
- InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME);
- OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
- if (!onboardingManifest.isValid()){
- onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
+
+ try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
+
+ OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
+ if (!onboardingManifest.isValid()) {
+ onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
+ }
+
+ } catch (IOException e) {
+ // convert to runtime to keep the throws unchanged
+ throw new RuntimeException("Failed to validate manifest", e);
}
}
@@ -79,8 +90,6 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(),
unwantedFile))));
-
- ;
}
}
@@ -97,14 +106,11 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
}
private boolean filterFiles(String inFileName) {
boolean valid = ELIGIBLE_FILES.stream().anyMatch(fileName -> fileName.equals(inFileName));
- if (valid){
- return !valid;
- }
- return filterFolders(inFileName);
+ return !valid && filterFolders(inFileName);
}
private boolean filterFolders(String fileName) {
- return !ELIGBLE_FOLDERS.stream().anyMatch(dirName -> fileName.startsWith(dirName));
+ return ELIGBLE_FOLDERS.stream().noneMatch(fileName::startsWith);
}
private boolean validateFileExist(UploadFileResponse uploadFileResponse, FileContentHandler contentMap, String fileName) {
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
index 1f5e20fd0b..bde9d06ae4 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
@@ -20,25 +20,28 @@
package org.openecomp.core.nosqldb.util;
+import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.services.YamlUtil;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.function.Function;
/**
* The type Configuration manager.
*/
public class ConfigurationManager {
- private static final String CONFIGURATION_YAML_FILE = "configuration.yaml";
- private static final String cassandraKey = "cassandraConfig";
+ static final String CONFIGURATION_YAML_FILE = "configuration.yaml";
+
+ private static final String CASSANDRA_KEY = "cassandraConfig";
private static final String DEFAULT_KEYSPACE_NAME = "dox";
private static final String CASSANDRA_ADDRESSES = "cassandra.addresses";
private static final String CASSANDRA_DOX_KEY_STORE = "cassandra.dox.keystore";
@@ -49,14 +52,14 @@ public class ConfigurationManager {
private static final String CASSANDRA_SSL = "cassandra.ssl";
private static final String CASSANDRA_TRUSTSTORE = "cassandra.Truststore";
private static final String CASSANDRA_TRUSTSTORE_PASSWORD = "cassandra.TruststorePassword";
- private static final String cassandraHostsKey = "cassandraHosts";
- private static final String cassandraPortKey = "port";
- private static final String cassandraUsernameKey = "username";
- private static final String cassandraPasswordKey = "password";
- private static final String cassandraAuthenticateKey = "authenticate";
- private static final String cassandraSSLKey = "ssl";
- private static final String cassandraTruststorePathKey = "truststorePath";
- private static final String cassandraTruststorePasswordKey = "truststorePassword";
+ private static final String CASSANDRA_HOSTS_KEY = "cassandraHosts";
+ private static final String CASSANDRA_PORT_KEY = "port";
+ private static final String CASSANDRA_USERNAME_KEY = "username";
+ private static final String CASSANDRA_PASSWORD_KEY = "password";
+ private static final String CASSANDRA_AUTHENTICATE_KEY = "authenticate";
+ private static final String CASSANDRA_SSL_KEY = "ssl";
+ private static final String CASSANDRA_TRUSTSTORE_PATH_KEY = "truststorePath";
+ private static final String CASSANDRA_TRUSTSTORE_PASSWORD_KEY = "truststorePassword";
private static ConfigurationManager instance = null;
private final LinkedHashMap<String, Object> cassandraConfiguration;
@@ -64,18 +67,24 @@ public class ConfigurationManager {
private ConfigurationManager() {
- YamlUtil yamlUtil = new YamlUtil();
+
String configurationYamlFile = System.getProperty(CONFIGURATION_YAML_FILE);
- InputStream yamlAsString;
- if (configurationYamlFile != null) {
- yamlAsString = getConfigFileIs(configurationYamlFile);
- } else {
- //Load from resources
- yamlAsString = yamlUtil.loadYamlFileIs("/" + CONFIGURATION_YAML_FILE);
- }
- Map<String, LinkedHashMap<String, Object>> configurationMap = yamlUtil.yamlToMap(yamlAsString);
- cassandraConfiguration = configurationMap.get(cassandraKey);
+ Function<InputStream, Map<String, LinkedHashMap<String, Object>>> reader = (is) -> {
+ YamlUtil yamlUtil = new YamlUtil();
+ return yamlUtil.yamlToMap(is);
+ };
+
+ try {
+
+ Map<String, LinkedHashMap<String, Object>> configurationMap = configurationYamlFile != null
+ ? readFromFile(configurationYamlFile, reader) // load from file
+ : FileUtils.readViaInputStream(CONFIGURATION_YAML_FILE, reader); // or from resource
+ cassandraConfiguration = configurationMap.get(CASSANDRA_KEY);
+
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read configuration", e);
+ }
}
/**
@@ -101,7 +110,7 @@ public class ConfigurationManager {
if (addresses != null) {
return addresses.split(",");
}
- List lsAddresses = (ArrayList) cassandraConfiguration.get(cassandraHostsKey);
+ List lsAddresses = (ArrayList) cassandraConfiguration.get(CASSANDRA_HOSTS_KEY);
String[] addressesArray;
addressesArray = (String[]) lsAddresses.toArray(new String[lsAddresses.size()]);
return addressesArray;
@@ -131,7 +140,7 @@ public class ConfigurationManager {
public String getUsername() {
String username = System.getProperty(CASSANDRA_USER);
if (username == null) {
- username = (String) cassandraConfiguration.get(cassandraUsernameKey);
+ username = (String) cassandraConfiguration.get(CASSANDRA_USERNAME_KEY);
}
return username;
}
@@ -144,7 +153,7 @@ public class ConfigurationManager {
public String getPassword() {
String password = System.getProperty(CASSANDRA_PASSWORD);
if (password == null) {
- password = (String) cassandraConfiguration.get(cassandraPasswordKey);
+ password = (String) cassandraConfiguration.get(CASSANDRA_PASSWORD_KEY);
}
return password;
}
@@ -157,7 +166,7 @@ public class ConfigurationManager {
public String getTruststorePath() {
String truststorePath = System.getProperty(CASSANDRA_TRUSTSTORE);
if (truststorePath == null) {
- truststorePath = (String) cassandraConfiguration.get(cassandraTruststorePathKey);
+ truststorePath = (String) cassandraConfiguration.get(CASSANDRA_TRUSTSTORE_PATH_KEY);
}
return truststorePath;
}
@@ -170,7 +179,7 @@ public class ConfigurationManager {
public String getTruststorePassword() {
String truststorePassword = System.getProperty(CASSANDRA_TRUSTSTORE_PASSWORD);
if (truststorePassword == null) {
- truststorePassword = (String) cassandraConfiguration.get(cassandraTruststorePasswordKey);
+ truststorePassword = (String) cassandraConfiguration.get(CASSANDRA_TRUSTSTORE_PASSWORD_KEY);
}
return truststorePassword;
}
@@ -184,7 +193,7 @@ public class ConfigurationManager {
int port;
String sslPort = System.getProperty(CASSANDRA_PORT);
if (sslPort == null) {
- sslPort = (String) cassandraConfiguration.get(cassandraPortKey);
+ sslPort = (String) cassandraConfiguration.get(CASSANDRA_PORT_KEY);
if (sslPort == null) {
sslPort = "0";
}
@@ -200,7 +209,7 @@ public class ConfigurationManager {
* @return the boolean
*/
public boolean isSsl() {
- return getBooleanResult(CASSANDRA_SSL, cassandraSSLKey);
+ return getBooleanResult(CASSANDRA_SSL, CASSANDRA_SSL_KEY);
}
/**
@@ -209,7 +218,7 @@ public class ConfigurationManager {
* @return the boolean
*/
public boolean isAuthenticate() {
- return getBooleanResult(CASSANDRA_AUTHENTICATE, cassandraAuthenticateKey);
+ return getBooleanResult(CASSANDRA_AUTHENTICATE, CASSANDRA_AUTHENTICATE_KEY);
}
private Boolean getBooleanResult(String property, String key) {
@@ -226,13 +235,9 @@ public class ConfigurationManager {
return res;
}
- private InputStream getConfigFileIs(String file) {
- InputStream is = null;
- try {
- is = new FileInputStream(file);
- } catch (FileNotFoundException exception) {
- log.debug("",exception);
+ private <T> T readFromFile(String file, Function<InputStream, T> reader) throws IOException {
+ try (InputStream is = new FileInputStream(file)) {
+ return reader.apply(is);
}
- return is;
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java
new file mode 100644
index 0000000000..f8d5d2dce7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java
@@ -0,0 +1,73 @@
+package org.openecomp.core.nosqldb.util;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import static org.testng.Assert.*;
+
+/**
+ * @author EVITALIY
+ * @since 22 Oct 17
+ */
+public class ConfigurationManagerTest {
+
+ private static final String NON_EXISTENT = "unexistentfile";
+
+ @BeforeMethod
+ public void resetInstance() throws NoSuchFieldException, IllegalAccessException {
+ Field field = ConfigurationManager.class.getDeclaredField("instance");
+ field.setAccessible(true);
+ field.set(null, null);
+ }
+
+ @Test(expectedExceptions = IOException.class,
+ expectedExceptionsMessageRegExp = ".*" + NON_EXISTENT + ".*")
+ public void testGetInstanceSystemProperty() throws Throwable {
+
+ try (ConfigurationSystemPropertyUpdater updater = new ConfigurationSystemPropertyUpdater(NON_EXISTENT)) {
+ ConfigurationManager.getInstance();
+ } catch (RuntimeException e) {
+ Throwable cause = e.getCause();
+ throw cause == null ? e : cause;
+ }
+ }
+
+ @Test()
+ public void testGetInstanceDefault() throws Exception {
+
+ try (ConfigurationSystemPropertyUpdater property = new ConfigurationSystemPropertyUpdater()) {
+ ConfigurationManager manager = ConfigurationManager.getInstance();
+ assertNotNull(manager.getUsername());
+ }
+ }
+
+
+ private static class ConfigurationSystemPropertyUpdater implements Closeable {
+
+ private final String oldValue;
+
+ private ConfigurationSystemPropertyUpdater(String value) {
+ this.oldValue = System.getProperty(ConfigurationManager.CONFIGURATION_YAML_FILE);
+ System.setProperty(ConfigurationManager.CONFIGURATION_YAML_FILE, value);
+ }
+
+ private ConfigurationSystemPropertyUpdater() {
+ this.oldValue = System.getProperty(ConfigurationManager.CONFIGURATION_YAML_FILE);
+ System.clearProperty(ConfigurationManager.CONFIGURATION_YAML_FILE);
+ }
+
+ @Override
+ public void close() throws IOException {
+
+ if (oldValue == null) {
+ System.clearProperty(ConfigurationManager.CONFIGURATION_YAML_FILE);
+ } else {
+ System.setProperty(ConfigurationManager.CONFIGURATION_YAML_FILE, oldValue);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
index 6ff213c34c..6ab3f8b049 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
@@ -28,6 +28,7 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.services.YamlUtil;
import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -54,7 +55,16 @@ public class FileUtils {
* @param function logic to be applied to the input stream
*/
public static <T> T readViaInputStream(String fileName, Function<InputStream, T> function) {
- return readViaInputStream(FileUtils.class.getClassLoader().getResource(fileName), function);
+
+ Objects.requireNonNull(fileName);
+
+ // the leading slash doesn't make sense and doesn't work when used with a class loader
+ URL resource = FileUtils.class.getClassLoader().getResource(fileName.startsWith("/") ? fileName.substring(1) : fileName);
+ if (resource == null) {
+ throw new IllegalArgumentException("Resource not found: " + fileName);
+ }
+
+ return readViaInputStream(resource, function);
}
/**
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileUtilsTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileUtilsTest.java
new file mode 100644
index 0000000000..e32aa39904
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileUtilsTest.java
@@ -0,0 +1,48 @@
+package org.openecomp.core.utilities.file;
+
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.function.Function;
+
+import static org.testng.Assert.assertTrue;
+
+/**
+ * @author EVITALIY
+ * @since 22 Oct 17
+ */
+public class FileUtilsTest {
+
+ private static final String TEST_RESOURCE = FileUtilsTest.class.getPackage().getName()
+ .replace('.', '/') + "/test-resource.txt";
+
+ private static final Function<InputStream, Integer> TEST_FUNCTION = (s) -> {
+
+ try {
+ return s.available();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ };
+
+ @Test
+ public void testReadViaInputStreamWithSlash() throws Exception {
+ assertTrue(FileUtils.readViaInputStream(TEST_RESOURCE, TEST_FUNCTION) > 0);
+ }
+
+ @Test
+ public void testReadViaInputStreamWithoutSlash() throws Exception {
+ assertTrue(FileUtils.readViaInputStream(TEST_RESOURCE, TEST_FUNCTION) > 0);
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testReadViaInputStreamNull() throws Exception {
+ FileUtils.readViaInputStream((String) null, TEST_FUNCTION);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testReadViaInputStreamNotFound() throws Exception {
+ FileUtils.readViaInputStream("notfound.txt", TEST_FUNCTION);
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/resources/org/openecomp/core/utilities/file/test-resource.txt b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/resources/org/openecomp/core/utilities/file/test-resource.txt
new file mode 100644
index 0000000000..dce400c8a5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/resources/org/openecomp/core/utilities/file/test-resource.txt
@@ -0,0 +1 @@
+CLASSPATH RESOURCE \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
index fa08ba49a8..deb5ffde35 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
@@ -60,13 +60,12 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
@Override
public Collection<Item> listItems(SessionContext context) {
- Response<Collection<Item>> response =
- itemAdaptorFactory.createInterface(context).list(context);
- if (response.isSuccessful()) {
- return response.getValue();
- } else {
- return null;
+ Response<Collection<Item>> response = itemAdaptorFactory.createInterface(context).list(context);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ "Failed to list Items. message:" + response.getReturnCode().toString());
}
+ return response.getValue();
}
@Override
@@ -76,7 +75,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
return response.getValue();
} else {
throw new RuntimeException(
- "failed to create Item. message:" + response.getReturnCode().getMessage());
+ "failed to create Item. message:" + response.getReturnCode().toString());
}
}
@@ -87,7 +86,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
if (!response.isSuccessful()) {
throw new RuntimeException("failed to update Item . ItemId:" + itemId + "" +
- " message:" + response.getReturnCode().getMessage());
+ " message:" + response.getReturnCode().toString());
}
}
@@ -98,7 +97,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
if (!versions.isSuccessful()) {
logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ITEM_VERSION_RETRIEVAL, versions
.getReturnCode());
- throw new RuntimeException(versions.getReturnCode().getMessage()); // TODO: 3/26/2017
+ throw new RuntimeException(versions.getReturnCode().toString()); // TODO: 3/26/2017
}
return versions.getValue();
}
@@ -114,7 +113,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
throw new RuntimeException("failed to create Item Version. ItemId:" + itemId + " based " +
"on:" + baseVersionId +
" message:" + response
- .getReturnCode().getMessage());
+ .getReturnCode().toString());
}
}
@@ -126,7 +125,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
if (!response.isSuccessful()) {
throw new RuntimeException(
String.format("failed to create Item Version. ItemId: %s, versionId: %s, message: %s",
- itemId.getValue(), versionId.getValue(), response.getReturnCode().getMessage()));
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
}
}
@@ -151,7 +150,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
throw new RuntimeException(String.format(
"failed to reset Item Version back to %s. ItemId: %s, versionId: %s, message: %s",
changeRef, itemId.getValue(), versionId.getValue(),
- response.getReturnCode().getMessage()));
+ response.getReturnCode().toString()));
}
}
@@ -166,7 +165,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
} else {
logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ELEMENT_GET_BY_PROPERTY,
elementInfosResponse.getReturnCode());
- throw new RuntimeException(elementInfosResponse.getReturnCode().getMessage());
+ throw new RuntimeException(elementInfosResponse.getReturnCode().toString());
}
}
@@ -187,11 +186,15 @@ public class ZusammenConnectorImpl implements ZusammenConnector {
@Override
public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
ZusammenElement element, String message) {
- Response<Element> saveResponse = elementAdaptorFactory.createInterface(context)
+ Response<Element> response = elementAdaptorFactory.createInterface(context)
.save(context, elementContext, element, message);
- return saveResponse.isSuccessful()
- ? Optional.of(saveResponse.getValue())
- : Optional.empty(); // TODO: 3/21/2017 error?
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String
+ .format("Failed to save element %s. ItemId: %s, versionId: %s, message: %s",
+ element.getElementId().getValue(), elementContext.getItemId().getValue(),
+ elementContext.getVersionId().getValue(), response.getReturnCode().toString()));
+ }
+ return Optional.of(response.getValue());
}
private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
index 76b0a900c1..ac103c0fbf 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
@@ -11,17 +11,20 @@ import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.Objects;
import java.util.Optional;
-import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getCollaborationElement;
import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
public class ElementCollaborationStore {
+ private static final String SUB_ELEMENT_NOT_EXIST_ERROR_MSG =
+ "List sub elements error: item %s, version %s - " +
+ "element %s, which appears as sub element of element %s, does not exist";
+
public Collection<CollaborationElement> listElements(SessionContext context,
ElementContext elementContext,
Id elementId) {
@@ -33,14 +36,26 @@ public class ElementCollaborationStore {
}
ElementRepository elementRepository = getElementRepository(context);
- return elementRepository.get(context, elementEntityContext, new ElementEntity(elementId))
- .map(ElementEntity::getSubElementIds).orElse(new HashSet<>()).stream()
- .map(subElementId -> elementRepository
- .get(context, elementEntityContext, new ElementEntity(subElementId)).get())
- .filter(Objects::nonNull)
- .map(subElement -> ZusammenPluginUtil
- .getCollaborationElement(elementEntityContext, subElement))
- .collect(Collectors.toList());
+ String elementIdValue = elementId.getValue();
+ String versionIdValue = elementContext.getChangeRef() == null
+ ? elementContext.getVersionId().getValue()
+ : elementContext.getChangeRef();
+ Collection<CollaborationElement> subElements = new ArrayList<>();
+
+ Optional<ElementEntity> element =
+ elementRepository.get(context, elementEntityContext, new ElementEntity(elementId));
+ if (element.isPresent() && element.get().getSubElementIds() != null) {
+ for (Id subElementId : element.get().getSubElementIds()) {
+ ElementEntity subElement =
+ elementRepository.get(context, elementEntityContext, new ElementEntity(subElementId))
+ .orElseThrow(
+ () -> new IllegalStateException(String.format(SUB_ELEMENT_NOT_EXIST_ERROR_MSG,
+ elementContext.getItemId().getValue(), versionIdValue,
+ subElementId.getValue(), elementIdValue)));
+ subElements.add(getCollaborationElement(elementEntityContext, subElement));
+ }
+ }
+ return subElements;
}
public CollaborationElement getElement(SessionContext context, ElementContext elementContext,
@@ -49,8 +64,7 @@ public class ElementCollaborationStore {
new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext);
return getElementRepository(context)
.get(context, elementEntityContext, new ElementEntity(elementId))
- .map(elementEntity -> ZusammenPluginUtil
- .getCollaborationElement(elementEntityContext, elementEntity))
+ .map(elementEntity -> getCollaborationElement(elementEntityContext, elementEntity))
.orElse(null);
}
@@ -78,7 +92,7 @@ public class ElementCollaborationStore {
ZusammenPluginUtil.getElementEntity(element));
}
- public boolean checkHealth(SessionContext sessionContext){
+ public boolean checkHealth(SessionContext sessionContext) {
return getElementRepository(sessionContext).checkHealth(sessionContext);
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
index ae23b6e8a9..db3066c313 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
@@ -14,7 +14,10 @@ import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
public class VersionCollaborationStore {
@@ -25,46 +28,74 @@ public class VersionCollaborationStore {
throw new UnsupportedOperationException(
"In this plugin implementation tag is supported only on versionId");
}
- copyElements(context, getSpaceName(context, Space.PRIVATE), itemId, versionId, tag.getName());
+ String space = getSpaceName(context, Space.PRIVATE);
+ ElementEntityContext targetContext = new ElementEntityContext(space, itemId, versionId);
+ targetContext.setChangeRef(tag.getName());
+ copyElements(context, new ElementEntityContext(space, itemId, versionId), targetContext,
+ getElementRepository(context));
}
public CollaborationMergeChange resetItemVersionHistory(SessionContext context, Id itemId,
Id versionId, String changeRef) {
ElementRepository elementRepository = getElementRepository(context);
- ElementEntityContext elementContext =
- new ElementEntityContext(getSpaceName(context, Space.PRIVATE), itemId, versionId);
- CollaborationMergeChange resetChange = new CollaborationMergeChange();
+ String spaceName = getSpaceName(context, Space.PRIVATE);
+ ElementEntityContext versionContext = new ElementEntityContext(spaceName, itemId, versionId);
- Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext);
- versionElements.stream()
- .map(elementEntity ->
- convertElementEntityToElementChange(elementEntity, elementContext, Action.DELETE))
- .forEach(resetChange.getChangedElements()::add);
+ Collection<ElementEntity> deletedElements =
+ deleteElements(context, versionContext, elementRepository);
- elementContext.setChangeRef(changeRef);
- Collection<ElementEntity> changeRefElements = elementRepository.list(context, elementContext);
- changeRefElements.stream()
- .map(elementEntity ->
- convertElementEntityToElementChange(elementEntity, elementContext, Action.CREATE))
- .forEach(resetChange.getChangedElements()::add);
+ ElementEntityContext changeRefContext = new ElementEntityContext(spaceName, itemId, versionId);
+ changeRefContext.setChangeRef(changeRef);
- return resetChange; // TODO: 4/19/2017 version change...
+ Collection<ElementEntity> createdElements =
+ copyElements(context, changeRefContext, versionContext, elementRepository);
+
+ // TODO: 4/19/2017 version change...
+ return createCollaborationMergeChange(versionContext, deletedElements, createdElements);
}
- private void copyElements(SessionContext context, String space, Id itemId, Id sourceVersionId,
- String targetTag) {
- ElementRepository elementRepository = getElementRepository(context);
- ElementEntityContext elementContext = new ElementEntityContext(space, itemId, sourceVersionId);
+ private Collection<ElementEntity> deleteElements(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementRepository elementRepository) {
+ Collection<ElementEntity> elements = elementRepository.list(context, elementContext);
+ elements.forEach(element -> elementRepository
+ .delete(context, elementContext, new ElementEntity(element.getId())));
+ elementRepository.delete(context, elementContext, new ElementEntity(ROOT_ELEMENTS_PARENT_ID));
+ return elements;
+ }
- Collection<ElementEntity> versionElements = elementRepository.list(context, elementContext);
+ private Collection<ElementEntity> copyElements(SessionContext context,
+ ElementEntityContext sourceElementContext,
+ ElementEntityContext targetElementContext,
+ ElementRepository elementRepository) {
+ Collection<ElementEntity> elements = elementRepository.list(context, sourceElementContext);
+ elements.forEach(elementEntity ->
+ elementRepository.create(context, targetElementContext, elementEntity));
+ return elements;
+ }
+
+ private CollaborationMergeChange createCollaborationMergeChange(
+ ElementEntityContext versionContext,
+ Collection<ElementEntity> deletedElements,
+ Collection<ElementEntity> createdElements) {
+ CollaborationMergeChange mergeChange = new CollaborationMergeChange();
+ mergeChange.getChangedElements().addAll(
+ convertToCollaborationElementChanges(versionContext, deletedElements, Action.DELETE));
+ mergeChange.getChangedElements().addAll(
+ convertToCollaborationElementChanges(versionContext, createdElements, Action.CREATE));
+ return mergeChange;
+ }
- elementContext.setChangeRef(targetTag);
- versionElements
- .forEach(elementEntity -> elementRepository.create(context, elementContext, elementEntity));
+ private List<CollaborationElementChange> convertToCollaborationElementChanges(
+ ElementEntityContext elementContext, Collection<ElementEntity> changedElements,
+ Action action) {
+ return changedElements.stream()
+ .map(element -> convertToCollaborationElementChange(element, elementContext, action))
+ .collect(Collectors.toList());
}
- private CollaborationElementChange convertElementEntityToElementChange(
+ private CollaborationElementChange convertToCollaborationElementChange(
ElementEntity elementEntity, ElementEntityContext elementContext, Action action) {
CollaborationElementChange elementChange = new CollaborationElementChange();
elementChange
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
index c19e8799d1..6cc1350444 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
@@ -16,12 +16,6 @@
package org.openecomp.core.zusammen.plugin.dao.impl;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Param;
-import com.datastax.driver.mapping.annotations.Query;
-import com.google.gson.reflect.TypeToken;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.Namespace;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -29,6 +23,12 @@ import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import com.google.gson.reflect.TypeToken;
import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
@@ -38,22 +38,30 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
public class CassandraElementRepository implements ElementRepository {
+ private static final String VERSION_ELEMENT_NOT_EXIST_ERROR_MSG =
+ "List version elements error: " +
+ "element %s, which appears as an element of item %s version %s, does not exist";
+
@Override
public Collection<ElementEntity> list(SessionContext context,
ElementEntityContext elementContext) {
Set<String> elementIds = getVersionElementIds(context, elementContext);
- return elementIds.stream()
- .map(elementId -> get(context, elementContext, new ElementEntity(new Id(elementId))).get())
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
+ Collection<ElementEntity> elements = new ArrayList<>();
+ for (String elementId : elementIds) {
+ elements.add(get(context, elementContext, new ElementEntity(new Id(elementId)))
+ .orElseThrow(
+ () -> new IllegalStateException(String.format(VERSION_ELEMENT_NOT_EXIST_ERROR_MSG,
+ elementId, elementContext.getItemId().getValue(),
+ getVersionId(elementContext)))));
+ }
+ return elements;
}
@Override
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
index c1f69cf3bf..4e1a60fff8 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
@@ -119,9 +119,12 @@ public class HeatToToscaUtil {
mdcDataDebugMessage.debugEntryMessage(null, null);
HeatToToscaTranslator heatToToscaTranslator =
HeatToToscaTranslatorFactory.getInstance().createInterface();
- InputStream fileContent = fileNameContentMap.getFileContent(SdcCommon.MANIFEST_NAME);
- heatToToscaTranslator.addManifest(SdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
+ try (InputStream fileContent = fileNameContentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ heatToToscaTranslator.addManifest(SdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read manifest", e);
+ }
fileNameContentMap.getFileList().stream()
.filter(fileName -> !(fileName.equals(SdcCommon.MANIFEST_NAME))).forEach(
@@ -143,7 +146,7 @@ public class HeatToToscaUtil {
return heatToToscaTranslator.translate();
} catch (IOException e) {
// rethrow as a RuntimeException to keep the signature backward compatible
- throw new RuntimeException(e);
+ throw new RuntimeException("Failed to read Heat template tree", e);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
index 353b791a1f..9ff1ff9992 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
@@ -40,8 +40,7 @@ public class ResourceWalker {
Exception {
Map<String, String> filesContent = new HashMap<>();
traverse(resourceDirectoryToStart, (fileName, stream) -> {
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- try {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
filesContent.put(fileName, IOUtils.toString(reader));
} catch (IOException exception) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
index fa1946f987..2b58a30e50 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
@@ -25,6 +25,7 @@ import org.testng.Assert;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
@@ -55,8 +56,6 @@ public class ValidationTestUtil {
private static Map<String, byte[]> getContentMapByPath(String path) {
Map<String, byte[]> contentMap = new HashMap<>();
- byte[] fileContent;
- FileInputStream fis;
URL url = ValidationTestUtil.class.getResource(path);
File pathFile = new File(url.getFile());
File[] files;
@@ -71,13 +70,13 @@ public class ValidationTestUtil {
}
for (File file : files) {
- try {
- fis = new FileInputStream(file);
- fileContent = FileUtils.toByteArray(fis);
- contentMap.put(file.getName(), fileContent);
+
+ try (FileInputStream fis = new FileInputStream(file)) {
+ contentMap.put(file.getName(), FileUtils.toByteArray(fis));
} catch (IOException e) {
- log.debug("",e);
+ throw new RuntimeException("Failed to read file: " + file, e);
}
+
}
return contentMap;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
index f7ca6463cb..dd303c7bb9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
@@ -53,7 +53,7 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
private static final String DESCRIPTION = "DESCRIPTION";
private static final String NESTED_PATTERN = "NESTED_PATTERN";
- private Map<String, Pattern> patterns;
+ private final Map<String, Pattern> patterns;
public HeatFileAnalyzerRowDataImpl() {
patterns = new HashMap<>();
@@ -72,16 +72,17 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
throws IOException {
AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles();
- BufferedReader bfReader;
for (Map.Entry<String, byte[]> fileData : files.entrySet()) {
String fileName = fileData.getKey();
if (!HeatFileAnalyzer.isYamlFile(fileName)) {
analyzedZipHeatFiles.addOtherNonModuleFile(fileName);
continue;
}
+
boolean foundHeatIdentifier = false;
- try (InputStream is = new ByteArrayInputStream(fileData.getValue())) {
- bfReader = new BufferedReader(new InputStreamReader(is));
+ try (InputStream is = new ByteArrayInputStream(fileData.getValue());
+ BufferedReader bfReader = new BufferedReader(new InputStreamReader(is))) {
+
String line;
boolean isResourcesSection = false;
Set<String> nestedFilesNames = new HashSet<>();
@@ -108,11 +109,9 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
}
analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames,
foundHeatIdentifier));
- if (Objects.nonNull(bfReader)) {
- bfReader.close();
- }
}
}
+
return analyzedZipHeatFiles;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index ca5329344b..41510ecc13 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -38,6 +38,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.HeatFileAnalyzerRow
import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
+import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@@ -45,8 +46,10 @@ import java.util.Objects;
import java.util.Optional;
public class CandidateEntityBuilder {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private CandidateService candidateService;
+
+ private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+
+ private final CandidateService candidateService;
public CandidateEntityBuilder(CandidateService candidateService) {
this.candidateService = candidateService;
@@ -57,35 +60,28 @@ public class CandidateEntityBuilder {
Map<String, List<ErrorMessage>> uploadErrors, String user) throws Exception {
//mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
- InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME);
- HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
- AnalyzedZipHeatFiles analyzedZipHeatFiles =
- heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
- HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
+ try (InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
+ AnalyzedZipHeatFiles analyzedZipHeatFiles =
+ heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
+ HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
- CandidateDataEntityTo candidateDataEntityTo =
- new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
- vspDetails.getVersion());
- candidateDataEntityTo.setErrors(uploadErrors);
- OrchestrationTemplateCandidateData candidateDataEntity =
- candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
- analyzedZipHeatFiles);
+ CandidateDataEntityTo candidateDataEntityTo =
+ new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
+ vspDetails.getVersion());
+ candidateDataEntityTo.setErrors(uploadErrors);
+ OrchestrationTemplateCandidateData candidateDataEntity =
+ candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
+ analyzedZipHeatFiles);
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return candidateDataEntity;
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
+ return candidateDataEntity;
+ }
}
-// public OrchestrationTemplateCandidateData buildOrchestrationTemplateFromCsar(VspDetails vspDetails,
-// byte[] uploadedFileData,
-// FileContentHandler contentMap,
-// Map<String, List<ErrorMessage>> uploadErrors,
-// String user){
-//
-// }
-
private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
FileContentHandler contentMap,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
heatTreeManager.createTree();
@@ -94,22 +90,24 @@ public class CandidateEntityBuilder {
private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails,
FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP Id", vspDetails.getId());
+
+ try (InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME)) {
- InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME);
- if (Objects.isNull(manifest)) {
- Optional<ManifestContent> manifestContentOptional =
- candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
- if (!manifestContentOptional.isPresent()) {
- throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ if (Objects.isNull(manifest)) {
+ Optional<ManifestContent> manifestContentOptional =
+ candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ if (!manifestContentOptional.isPresent()) {
+ throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ }
+ ManifestContent manifestContent = manifestContentOptional.get();
+ fileContentHandler.addFile(
+ SdcCommon.MANIFEST_NAME,
+ String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
}
- ManifestContent manifestContent = manifestContentOptional.get();
- fileContentHandler.addFile(
- SdcCommon.MANIFEST_NAME,
- String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
+ } finally {
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
}
-
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
index 0bbe3f81e7..4a49d5391f 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
@@ -492,11 +492,12 @@ public class VersioningManagerImpl implements VersioningManager {
versionInfoEntity.setActiveVersion(userCandidateVersion.getVersion());
versionInfoEntity.getViewableVersions().add(versionInfoEntity.getActiveVersion());
versionInfoEntity.setStatus(VersionStatus.Available);
- versionInfoDao.update(versionInfoEntity);
closeVersionOnEntity(versionInfoEntity.getEntityType(), versionInfoEntity.getEntityId(),
versionInfoEntity.getActiveVersion());
+ versionInfoDao.update(versionInfoEntity);
+
return versionInfoEntity.getActiveVersion();
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
index 323bd8a5fb..d17f79bb6c 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
@@ -5,5 +5,6 @@ public enum CsarFileTypes {
globalServiceTemplate,
externalFile,
toscaMetadata,
- definitionsFile,;
+ definitionsFile,
+ Artifacts;
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
index 348739e780..9b694c5207 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -54,7 +54,8 @@ public class ToscaConverterImpl implements ToscaConverter {
break;
case externalFile:
- artifacts.addFile(fileEntry.getKey(), fileEntry.getValue());
+ artifacts.addFile(
+ getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
break;
case definitionsFile:
@@ -94,6 +95,17 @@ public class ToscaConverterImpl implements ToscaConverter {
}
}
+ private String getConcreteArtifactFileName(String fileName){
+ int artifactIndex = fileName.indexOf(CsarFileTypes.Artifacts.name());
+ if(artifactIndex < 0){
+ return fileName;
+ }
+
+ int artifactDirectoryIndex =
+ artifactIndex + CsarFileTypes.Artifacts.name().length() + 1;
+ return fileName.substring(artifactDirectoryIndex);
+ }
+
private void updateToscaServiceModel(ToscaServiceModel toscaServiceModel,
Map<String, ServiceTemplate> serviceTemplates,
FileContentHandler externalFilesHandler,
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
index f29ca4a427..471e3891c7 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
@@ -41,22 +41,18 @@ public class ToscaConverterImplTest {
private static final String VIRTUAL_LINK = "virtualLink";
private static final String UNBOUNDED = "UNBOUNDED";
- private static String inputFilesPath;
- private static String outputFilesPath;
- private static Map<String, ServiceTemplate> expectedOutserviceTemplates;
-
@Test
public void testConvertMainSt() throws IOException {
- inputFilesPath = "/mock/toscaConverter/convertMainSt/in";
- outputFilesPath = "/mock/toscaConverter/convertMainSt/out";
+ String inputFilesPath = "/mock/toscaConverter/convertMainSt/in";
+ String outputFilesPath = "/mock/toscaConverter/convertMainSt/out";
FileContentHandler fileContentHandler =
createFileContentHandlerFromInput(inputFilesPath);
- expectedOutserviceTemplates = new HashMap<>();
+ Map<String, ServiceTemplate> expectedOutserviceTemplates = new HashMap<>();
loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(),
- expectedOutserviceTemplates);
+ expectedOutserviceTemplates);
ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler);
ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName);
@@ -201,18 +197,15 @@ public class ToscaConverterImplTest {
private static void addServiceTemplateFiles(Map<String, ServiceTemplate> serviceTemplates,
File[] files,
- ToscaExtensionYamlUtil toscaExtensionYamlUtil)
- throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil) throws IOException {
+
for (File file : files) {
+
try (InputStream yamlFile = new FileInputStream(file)) {
ServiceTemplate serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil);
serviceTemplates.put(file.getName(), serviceTemplateFromYaml);
- try {
- yamlFile.close();
- } catch (IOException ignore) {
- }
}
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh
index 42c347f4e8..78af19b0f9 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh
+++ b/openecomp-be/tools/zusammen-tools/src/main/resources/zusammenMainTool.sh
@@ -22,5 +22,5 @@ else
fi
echo "Configuration file location: ${CONF_FILE_LOCATION}"
-java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=${CONF_FILE_LOCATION} -jar openecomp-zusammen-tools-1.0-SNAPSHOT.jar org.openecomp.core.tools.main.ZusammenMainTool $1 $2 $3 $4 $5 $6
+java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=${CONF_FILE_LOCATION} -jar openecomp-zusammen-tools-1.2.0-SNAPSHOT.jar org.openecomp.core.tools.main.ZusammenMainTool $1 $2 $3 $4 $5 $6
STATUS="${?}" echo "${STATUS}"
diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh
index 20cde17f57..417db0994c 100755
--- a/sdc-os-chef/scripts/docker_run.sh
+++ b/sdc-os-chef/scripts/docker_run.sh
@@ -57,7 +57,7 @@ fi
RELEASE=latest
LOCAL=false
SKIPTESTS=false
-DEBUG_PORT = "--publish 4000:4000"
+DEBUG_PORT="--publish 4000:4000"
[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__
[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release
@@ -155,7 +155,7 @@ echo "docker run sdc-backend..."
if [ ${LOCAL} = false ]; then
docker pull ${PREFIX}/sdc-backend:${RELEASE}
else
- ADDITIONAL_ARGUMENTS = ${DEBUG_PORT}
+ ADDITIONAL_ARGUMENTS=${DEBUG_PORT}
fi
docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 4g --memory-swap=4g --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/BE/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE}