summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql29
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java5
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java38
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java16
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java98
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java6
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java58
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java12
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json22
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java6
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java (renamed from adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java)28
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java181
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java10
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java32
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java196
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java47
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java50
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java37
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java74
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java119
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java51
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java24
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java154
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java107
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java24
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java257
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java70
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java654
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/FlowsToExecute.json292
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn41
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn90
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java30
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java39
-rw-r--r--common/pom.xml2
-rw-r--r--common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java14
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java4
51 files changed, 2397 insertions, 803 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index ede499f9ee..e5daf24d6c 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -65,16 +65,19 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL
('Service-Macro-Create', '5', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Create', '6', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Create', '7', 'ConfigAssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '8', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '9', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '10', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '11', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '12', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '13', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '14', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '15', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '16', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '17', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '8', 'AssignPnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '9', 'WaitForPnfReadyBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '10', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '11', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '12', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '13', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '14', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '15', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '16', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '17', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '18', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '19', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '20', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
@@ -249,6 +252,7 @@ VALUES
('AssignVolumeGroupBB', 'VOLUME_GROUP', 'ASSIGN'),
('AssignVfModuleBB', 'VF_MODULE', 'ASSIGN'),
('AssignNetworkBB', 'NETWORK', 'ASSIGN'),
+('AssignPnfBB', 'NO_VALIDATE', 'ASSIGN'),
('UnassignServiceInstanceBB', 'SERVICE', 'UNASSIGN'),
('UnassignVnfBB', 'VNF', 'UNASSIGN'),
@@ -261,6 +265,7 @@ VALUES
('ActivateVfModuleBB', 'VF_MODULE', 'ACTIVATE'),
('ActivateNetworkBB', 'NETWORK', 'ACTIVATE'),
('ActivateNetworkCollectionBB', 'NETWORK', 'ACTIVATE'),
+('ActivatePnfBB', 'NO_VALIDATE', 'ACTIVATE'),
('DeactivateServiceInstanceBB', 'SERVICE', 'DEACTIVATE'),
('DeactivateVnfBB', 'VNF', 'DEACTIVATE'),
@@ -285,7 +290,9 @@ VALUES
('DeleteNetworkCollectionBB', 'NETWORK', 'DELETE'),
('ConfigurationScaleOutBB', 'NO_VALIDATE', 'CUSTOM'),
-('GenericVnfHealthCheckBB', 'NO_VALIDATE', 'CUSTOM');
+('GenericVnfHealthCheckBB', 'NO_VALIDATE', 'CUSTOM'),
+
+('WaitForPnfReadyBB', 'NO_VALIDATE', 'CUSTOM');
INSERT INTO orchestration_status_state_transition_directive (resource_type, orchestration_status, target_action, flow_directive)
VALUES
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java
index 91c7c7c65f..294dccdb90 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java
@@ -40,4 +40,9 @@ public interface Constants {
public static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey";
public static final String REQUEST_TUNABLES = "org.onap.so.adapters.sdnc";
+
+ public static final String MSO_ACTION_LCM = "lcm";
+ public static final String LCM_API_VER = "2.00";
+ public static final int LCM_FLAGS_TTL = 65000;
+ public static final String LCM_ORIGINATOR_ID = "MSO";
}
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java
index 880ef0a7b0..b15831ff03 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java
@@ -45,27 +45,35 @@ public class MapRequestTunables {
RequestTunables reqTunable = new RequestTunables(reqTunableOriginal);
String error = null;
String key;
- if ("query".equals(reqTunable.getAction())) { // due to variable format for reqTunable.getOperation() eg
- // services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
- key = Constants.REQUEST_TUNABLES + "." + reqTunable.getMsoAction() + ".." + reqTunable.getAction();
- logger.debug(GENERATED_KEY + key);
- } else if ("put".equals(reqTunable.getAction()) || "restdelete".equals(reqTunable.getAction())) { // due to
- // variable
- // format for
- // reqTunable.getOperation()
- // eg
- // services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
- key = Constants.REQUEST_TUNABLES + "..." + reqTunable.getAction();
- logger.debug(GENERATED_KEY + key);
+ String msoAction = reqTunable.getMsoAction();
+
+ if (Constants.MSO_ACTION_LCM.equals(msoAction)) {
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + "." + reqTunable.getOperation();
} else {
- key = Constants.REQUEST_TUNABLES + "." + reqTunable.getMsoAction() + "." + reqTunable.getOperation() + "."
- + reqTunable.getAction();
- logger.debug(GENERATED_KEY + key);
+ if ("query".equals(reqTunable.getAction())) {
+ // due to variable format for reqTunable.getOperation(), eg
+ // services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + ".." + reqTunable.getAction();
+ } else if ("put".equals(reqTunable.getAction()) || "restdelete".equals(reqTunable.getAction())) {
+ // due to variable format for reqTunable.getOperation(), eg
+ // services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9
+ key = Constants.REQUEST_TUNABLES + "..." + reqTunable.getAction();
+ } else {
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + "." + reqTunable.getOperation() + "."
+ + reqTunable.getAction();
+ }
}
+ logger.debug(GENERATED_KEY + key);
String value;
value = env.getProperty(key, "");
+ if (Constants.MSO_ACTION_LCM.equals(msoAction) && (value == null || value.length() == 0)) {
+ key = Constants.REQUEST_TUNABLES + "." + msoAction + ".default";
+ logger.debug("Can not find key of " + reqTunable.getOperation() + ", use default: " + key);
+ value = env.getProperty(key, "");
+ }
+
if (value != null && value.length() > 0) {
String[] parts = value.split("\\|"); // escape pipe
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
index a8418ea901..bcd1db7929 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
@@ -98,19 +98,23 @@ public class SDNCRestClient {
String bpelReqId = bpelRequest.getRequestHeader().getRequestId();
String callbackUrl = bpelRequest.getRequestHeader().getCallbackUrl();
+ String msoAction = bpelRequest.getRequestHeader().getMsoAction();
String sdncReqBody = null;
- RequestTunables rt = new RequestTunables(bpelReqId, bpelRequest.getRequestHeader().getMsoAction(),
- bpelRequest.getRequestHeader().getSvcOperation(), bpelRequest.getRequestHeader().getSvcAction());
+ RequestTunables rt = new RequestTunables(bpelReqId, msoAction, bpelRequest.getRequestHeader().getSvcOperation(),
+ bpelRequest.getRequestHeader().getSvcAction());
rt = tunablesMapper.setTunables(rt);
rt.setSdncaNotificationUrl(env.getProperty(Constants.MY_URL_PROP));
-
if ("POST".equals(rt.getReqMethod())) {
Node node = (Node) bpelRequest.getRequestData();
Document reqDoc = node.getOwnerDocument();
- sdncReqBody = Utils.genSdncReq(reqDoc, rt);
+ if (Constants.MSO_ACTION_LCM.equals(msoAction)) {
+ sdncReqBody = Utils.genSdncLcmReq(reqDoc, rt);
+ } else {
+ sdncReqBody = Utils.genSdncReq(reqDoc, rt);
+ }
} else if ("PUT".equals(rt.getReqMethod())) {
Node node = (Node) bpelRequest.getRequestData();
Document reqDoc = node.getOwnerDocument();
@@ -317,7 +321,7 @@ public class SDNCRestClient {
}
- logger.debug("Invoking Bpel Callback. BpelCallbackUrl:{}", bpelUrl);
+ logger.debug("Invoking Bpel Callback. BpelCallbackUrl: {}", bpelUrl);
cbPort.sdncAdapterCallback(cbReq);
} catch (Exception e) {
@@ -325,6 +329,6 @@ public class SDNCRestClient {
logger.error("Error {} - {} - {}", ErrorCode.BusinessProcessError.getValue(),
MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), error, e);
}
- logger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA);
+ logger.info("{} : {}", MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA);
}
}
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java
index f710988886..56c38f8891 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java
@@ -24,6 +24,8 @@ package org.onap.so.adapters.sdnc.impl;
import java.io.StringWriter;
+import java.time.Instant;
+import java.util.UUID;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -94,7 +96,7 @@ public class Utils {
}
String s = domToStr(newdoc);
- logger.debug("Formatted SdncReq:\n", s);
+ logger.debug("Formatted SdncReq:\n{}", s);
return s;
} catch (Exception e) {
@@ -128,7 +130,7 @@ public class Utils {
}
String s = domToStr(newdoc);
- logger.debug("Formatted SdncPutReq:\n {}", s);
+ logger.debug("Formatted SdncPutReq:\n{}", s);
return s;
} catch (Exception e) {
@@ -138,6 +140,96 @@ public class Utils {
return null;
}
+ public static Element genLcmCommonHeader(Document doc, String requestId) {
+ Element commonHeader = doc.createElement("common-header");
+
+ Element hdrChild;
+
+ hdrChild = doc.createElement("api-ver");
+ hdrChild.appendChild(doc.createTextNode(Constants.LCM_API_VER));
+ commonHeader.appendChild(hdrChild);
+
+ hdrChild = doc.createElement("flags");
+
+ Element flagChild;
+
+ flagChild = doc.createElement("force");
+ flagChild.appendChild(doc.createTextNode("FALSE"));
+ hdrChild.appendChild(flagChild);
+
+ flagChild = doc.createElement("mode");
+ flagChild.appendChild(doc.createTextNode("NORMAL"));
+ hdrChild.appendChild(flagChild);
+
+ flagChild = doc.createElement("ttl");
+ flagChild.appendChild(doc.createTextNode(String.valueOf(Constants.LCM_FLAGS_TTL)));
+ hdrChild.appendChild(flagChild);
+
+ commonHeader.appendChild(hdrChild);
+
+ hdrChild = doc.createElement("originator-id");
+ hdrChild.appendChild(doc.createTextNode(Constants.LCM_ORIGINATOR_ID));
+ commonHeader.appendChild(hdrChild);
+
+ hdrChild = doc.createElement("request-id");
+ hdrChild.appendChild(doc.createTextNode(requestId));
+ commonHeader.appendChild(hdrChild);
+
+ hdrChild = doc.createElement("sub-request-id");
+ hdrChild.appendChild(doc.createTextNode(UUID.randomUUID().toString()));
+ commonHeader.appendChild(hdrChild);
+
+ hdrChild = doc.createElement("timestamp");
+ hdrChild.appendChild(doc.createTextNode(Instant.now().toString()));
+ commonHeader.appendChild(hdrChild);
+
+ return commonHeader;
+ }
+
+ public static String genSdncLcmReq(Document reqDoc, RequestTunables rt) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ Document newdoc = db.newDocument();
+ Element root = newdoc.createElementNS(rt.getNamespace(), "input");
+ newdoc.appendChild(root);
+
+ String elemData = rt.getReqId();
+ if (elemData == null || elemData.length() == 0) {
+ elemData = UUID.randomUUID().toString();
+ }
+
+ Element hdrChild;
+ hdrChild = genLcmCommonHeader(newdoc, elemData);
+ root.appendChild(hdrChild);
+
+ elemData = rt.getAction();
+ if (elemData != null && elemData.length() > 0) {
+ hdrChild = newdoc.createElement("action");
+ hdrChild.appendChild(newdoc.createTextNode(elemData));
+ root.appendChild(hdrChild);
+ }
+
+ // RequestData
+ NodeList nodes = reqDoc.getDocumentElement().getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ Node newNode = newdoc.importNode(n, true);
+ root.appendChild(newNode);
+ }
+
+ String s = domToStr(newdoc);
+ logger.debug("Formatted SdncLcmReq:\n{}", s);
+ return s;
+
+ } catch (Exception e) {
+ logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC",
+ ErrorCode.BusinessProcessError.getValue(), "Exception in genSdncLcmReq", e);
+ }
+ return null;
+ }
+
public static String genMsoFailResp(SDNCResponse resp) {
try {
@@ -163,7 +255,7 @@ public class Utils {
root.appendChild(elem3);
String s = domToStr(newdoc);
- logger.debug("Formatted SdncReq: {}", s);
+ logger.debug("Formatted MsoFailResp:\n{}", s);
return s;
} catch (Exception e) {
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
index e4a6bed300..875fddd7f0 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
@@ -26,7 +26,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
public class Application {
+ public static final String BASIC_PROFILE = "basic";
+
public static void main(final String... args) {
- SpringApplication.run(Application.class, args);
+ final SpringApplication springApplication = new SpringApplication(Application.class);
+ springApplication.setAdditionalProfiles(BASIC_PROFILE);
+ springApplication.run(args);
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
deleted file mode 100644
index cc56048262..0000000000
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SO
- * ================================================================================
- * Copyright (C) 2020 Samsung. 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.onap.so.adapters.vevnfm.configuration;
-
-import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.crypto.password.PasswordEncoder;
-
-@Configuration
-@EnableWebSecurity
-public class SecurityConfiguration extends SoBasicWebSecurityConfigurerAdapter {
-
- @Value("${notification.url}")
- private String notificationUrl;
-
- @Value("${notification.username}")
- private String notificationUsername;
-
- @Value("${notification.password}")
- private String notificationPassword;
-
- @Autowired
- private PasswordEncoder passwordEncoder;
-
- @Override
- protected void configure(final HttpSecurity https) throws Exception {
- https.csrf().disable().authorizeRequests().antMatchers(notificationUrl).authenticated().and().httpBasic();
- }
-
- @Override
- protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication().withUser(notificationUsername)
- .password(passwordEncoder.encode(notificationPassword)).authorities("ROLE_USER");
- }
-}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
index aa07ed65a2..c1a56fb452 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
@@ -43,11 +43,11 @@ public class SubscriberService {
@Value("${notification.url}")
private String notificationUrl;
- @Value("${notification.username}")
- private String notificationUsername;
+ @Value("${spring.security.usercredentials[0].username}")
+ private String username;
- @Value("${notification.password}")
- private String notificationPassword;
+ @Value("${spring.security.usercredentials[0].openpass}")
+ private String openpass;
@Autowired
private SubscribeSender sender;
@@ -62,8 +62,8 @@ public class SubscriberService {
request.callbackUri(getCallbackUri());
final SubscriptionsAuthenticationParamsBasic paramsBasic = new SubscriptionsAuthenticationParamsBasic();
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
- paramsBasic.setUserName(notificationUsername);
- paramsBasic.setPassword(notificationPassword);
+ paramsBasic.setUserName(username);
+ paramsBasic.setPassword(openpass);
authentication.setAuthType(Collections.singletonList(SubscriptionsAuthentication.AuthTypeEnum.BASIC));
authentication.setParamsBasic(paramsBasic);
request.authentication(authentication);
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
index b16fa6348f..f3ad9615ec 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
@@ -22,8 +22,6 @@ system:
notification:
url: /lcm/v1/vnf/instances/notifications
- username: admin
- password: a4b3c2d1
mso:
key: 07a7159d3bf51a0e53be7a8f89699be7
@@ -36,6 +34,12 @@ vnfm:
subscription: /vnflcm/v1/subscriptions
spring:
+ security:
+ usercredentials:
+ - username: admin
+ openpass: a4b3c2d1
+ password: '$2a$10$vU.mWyNTsikAxXIA5c269ewCpAbYTiyMS0m1N.kn4F2CSGEnrKN7K'
+ role: USER
http:
converters:
preferred-json-mapper: gson
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json
index 9827310627..3c5ec49b80 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json
@@ -2350,7 +2350,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"nsdId": {
@@ -2358,7 +2358,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"nsdName": {
@@ -2384,7 +2384,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"vnfPkgIds": {
@@ -2392,7 +2392,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"nestedNsdInfoIds": {
@@ -2400,7 +2400,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"nsdOnboardingState": {
@@ -2432,7 +2432,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"pnfdId": {
@@ -2440,7 +2440,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"pnfdName": {
@@ -2475,7 +2475,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"pnfdOnboardingState": {
@@ -2767,7 +2767,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"vnfPkgId": {
@@ -2775,7 +2775,7 @@
"type": "array",
"items": {
"type": "string",
- "format": "uuid"
+ "minLength": 1
}
},
"operationalState": {
@@ -2804,7 +2804,7 @@
"title": "Id",
"description": "Identifier of this subscription resource.",
"type": "string",
- "format": "uuid"
+ "minLength": 1
},
"callbackUri": {
"title": "Callbackuri",
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
index 40be4411c8..fb32fb9605 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
@@ -21,7 +21,10 @@
package org.onap.so.adapters.vnfmadapter;
/**
- * Adapter constants
+ * VNFM Adapter constants
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
*/
public class Constants {
@@ -29,8 +32,15 @@ public class Constants {
public static final String SERVICE_VERSION = "v1";
public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION;
public static final String PACKAGE_MANAGEMENT_BASE_URL = BASE_URL + "/vnfpkgm/v1";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL = BASE_URL + "/etsicatalogmanager/notification";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL = BASE_URL + "/etsicatalogmanager";
public static final String APPLICATION_ZIP = "application/zip";
public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification";
+ /**
+ * Name of the subscription cache
+ */
+ public static final String PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE = "PackageManagementSubscriptionCache";
+
private Constants() {}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
index 84282e0c7f..61d5adf9d8 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
@@ -23,7 +23,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collection;
-import org.onap.so.adapters.vnfmadapter.converters.Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter;
+import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.VnfPkgInfoConverter;
+import org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog.PkgmSubscriptionRequestConverter;
import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
@@ -43,7 +44,8 @@ public class MessageConverterConfiguration {
@Bean
public ConversionService conversionService() {
final DefaultConversionService service = new DefaultConversionService();
- service.addConverter(new Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter());
+ service.addConverter(new VnfPkgInfoConverter());
+ service.addConverter(new PkgmSubscriptionRequestConverter());
return service;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
index 62d2f7e2a9..405bf896ef 100755
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
@@ -27,6 +27,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
+import org.springframework.cache.annotation.EnableCaching;
/**
* The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
@@ -37,6 +38,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
* @see <a href= "https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf">ETSI
* SOL003 v2.5.1</a>
*/
+@EnableCaching
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
public class VnfmAdapterApplication {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java
index 4f3bbe6c5b..a5404607b4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java
@@ -23,14 +23,16 @@
package org.onap.so.adapters.vnfmadapter;
import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter;
+import org.onap.so.security.SoUserCredentialConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
*
*/
@EnableWebSecurity
@@ -39,6 +41,7 @@ public class VnfmBasicWebSecurityConfigurerAdapter extends SoBasicWebSecurityCon
@Value("${server.ssl.client-auth:none}")
private String clientAuth;
+ SoUserCredentialConfiguration soUserCredentialConfiguration;
@Override
protected void configure(final HttpSecurity http) throws Exception {
@@ -46,8 +49,8 @@ public class VnfmBasicWebSecurityConfigurerAdapter extends SoBasicWebSecurityCon
http.csrf().disable().authorizeRequests().anyRequest().permitAll();
} else {
super.configure(http);
+ http.authorizeRequests().antMatchers(HttpMethod.GET, "/etsi/subscription/notification").permitAll();
}
}
-
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java
index de18ecc43e..160b875374 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java
@@ -18,28 +18,36 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vnfmadapter.converters;
+package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.*;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.*;
+import java.util.ArrayList;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesChecksum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesSoftwareImages;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesAdditionalArtifacts;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.UriLink;
/**
- * Converter to convert from an Etsi Catalog Model {@link VnfPkgInfo} Object to a PackageManagement Model
+ * Converter to convert from an Etsi Catalog Manager {@link VnfPkgInfo} Object to its equivalent SOL003 Object
* {@link InlineResponse2001} Object
*
* @author andrew.a.lamb@est.tech
*/
@Service
-public class Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter
- implements Converter<VnfPkgInfo, InlineResponse2001> {
- private static final Logger logger =
- LoggerFactory.getLogger(Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.class);
+public class VnfPkgInfoConverter implements Converter<VnfPkgInfo, InlineResponse2001> {
+ private static final Logger logger = LoggerFactory.getLogger(VnfPkgInfoConverter.class);
/**
* Convert a {@link VnfPkgInfo} Object to an {@link InlineResponse2001} Object
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
new file mode 100644
index 0000000000..c6d51c99aa
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import javax.swing.text.html.Option;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.OperationalStateEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders;
+import org.slf4j.Logger;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Service;
+
+/**
+ * Converter to convert from an Etsi Catalog Manager {@link PkgmSubscriptionRequest} Object to its equivalent ETSI
+ * Catalog Manager Object
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ *
+ */
+@Service
+public class PkgmSubscriptionRequestConverter implements
+ Converter<PkgmSubscriptionRequest, org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest> {
+
+ private static final Logger logger = getLogger(PkgmSubscriptionRequestConverter.class);
+
+ @Override
+ public org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest convert(
+ PkgmSubscriptionRequest pkgmSubscriptionRequest) {
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest =
+ new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest();
+
+ etsiCatalogManagerSubscriptionRequest
+ .setFilters(getPkgmNotificationsFilter(pkgmSubscriptionRequest.getFilter()));
+
+ return etsiCatalogManagerSubscriptionRequest;
+ }
+
+
+ private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter(
+ final SubscriptionsFilter sol003SubscriptionsFilter) {
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters =
+ new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter();
+
+ if (sol003SubscriptionsFilter.getNotificationTypes() != null) {
+ etsiCatalogManagerFilters.setNotificationTypes(
+ getPkgmNotificationsFilterNotificationTypes(sol003SubscriptionsFilter.getNotificationTypes()));
+ }
+
+ etsiCatalogManagerFilters.setVnfProductsFromProviders(
+ getVnfProductsProviders(sol003SubscriptionsFilter.getVnfProductsFromProviders()));
+
+ etsiCatalogManagerFilters.setVnfdId(getVnfdIds(sol003SubscriptionsFilter.getVnfdId()));
+
+ etsiCatalogManagerFilters.setVnfPkgId(getVnfPkgIds(sol003SubscriptionsFilter.getVnfPkgId()));
+
+ etsiCatalogManagerFilters
+ .setOperationalState(getOperationalState(sol003SubscriptionsFilter.getOperationalState()));
+
+ etsiCatalogManagerFilters.setUsageState(null);
+
+ return etsiCatalogManagerFilters;
+ }
+
+ // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI Catalog Manager Swagger
+ // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once swagger is updated.
+ private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState(
+ final OperationalStateEnum operationalState) {
+ if (operationalState != null) {
+ return Arrays.asList(
+ org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum
+ .fromValue(operationalState.getValue()));
+ }
+ return Collections.emptyList();
+ }
+
+ private List<String> getVnfPkgIds(final List<String> vnfPkgId) {
+ if (vnfPkgId != null) {
+ final List<String> etsiCatalogManagerVnfPkgId = new ArrayList<>();
+ vnfPkgId.forEach(type -> {
+ etsiCatalogManagerVnfPkgId.add(type);
+ });
+ }
+ return Collections.emptyList();
+ }
+
+ private List<String> getVnfdIds(final List<String> vnfdId) {
+ if (vnfdId != null) {
+ final List<String> etsiCatalogManagerVnfdId = new ArrayList<>();
+ vnfdId.forEach(type -> {
+ etsiCatalogManagerVnfdId.add(type);
+ });
+ }
+ return Collections.emptyList();
+ }
+
+ private List<VnfProductsProviders> getVnfProductsProviders(
+ final List<SubscriptionsFilterVnfProductsFromProviders> filterProductsFromProvider) {
+
+ if (filterProductsFromProvider != null && !filterProductsFromProvider.isEmpty()) {
+ final List<VnfProductsProviders> etsiCatalogManagerVnfProductsProviders = new ArrayList<>();
+ filterProductsFromProvider.forEach(vnfProduct -> {
+ etsiCatalogManagerVnfProductsProviders
+ .add(new VnfProductsProviders().vnfProducts(getVnfProducts(vnfProduct.getVnfProducts())));
+ });
+ return etsiCatalogManagerVnfProductsProviders;
+ }
+ return Collections.emptyList();
+ }
+
+ private List<VnfProducts> getVnfProducts(final List<SubscriptionsFilterVnfProducts> sol003VnfProducts) {
+ if (sol003VnfProducts != null) {
+ final List<VnfProducts> etsiCatalogManagerVnfProductsList = new ArrayList<>();
+ sol003VnfProducts.forEach(vnfProduct -> {
+ etsiCatalogManagerVnfProductsList.add(new VnfProducts().vnfProductName(vnfProduct.getVnfProductName())
+ .versions(getVersion(vnfProduct.getVersions())));
+ });
+ return etsiCatalogManagerVnfProductsList;
+ }
+ return Collections.emptyList();
+ }
+
+ private List<Version> getVersion(final List<SubscriptionsFilterVersions> sol003FilterVersions) {
+ if (sol003FilterVersions != null && !sol003FilterVersions.isEmpty()) {
+ List<Version> etsiCatalogVersionList = new ArrayList<>();
+ sol003FilterVersions.forEach(vnfFilterVersion -> {
+ etsiCatalogVersionList.add(new Version().vnfSoftwareVersion(vnfFilterVersion.getVnfSoftwareVersion())
+ .vnfdVersions(vnfFilterVersion.getVnfdVersions()));
+ });
+ return etsiCatalogVersionList;
+ }
+ return Collections.emptyList();
+ }
+
+ private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> getPkgmNotificationsFilterNotificationTypes(
+ final List<NotificationTypesEnum> notificationTypes) {
+
+ if (notificationTypes != null && !notificationTypes.isEmpty()) {
+ final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogManagerNotificationTypes =
+ new ArrayList<>();
+ notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add(
+ org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum
+ .fromValue(type.getValue())));
+ }
+ return Collections.emptyList();
+ }
+
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
index 34fc2645a2..62b365745c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
@@ -21,7 +21,9 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
+import org.springframework.http.ResponseEntity;
/**
* Provides methods for invoking REST calls to the ETSI Catalog Manager.
@@ -71,4 +73,12 @@ public interface EtsiCatalogServiceProvider {
*/
Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath);
+ /**
+ * Post the SubscriptionRequest Object.
+ *
+ * @return The ResponseEntity containing the ETSI Catalog Manager's PkgmSubscription object.
+ */
+ Optional<PkgmSubscription> postSubscription(
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest);
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
index 779cb2a7a6..1a48494e1a 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
@@ -21,6 +21,8 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
import java.util.Optional;
+import javax.swing.text.html.Option;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.*;
@@ -102,6 +104,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
if (response.getStatusCode() == HttpStatus.OK) {
if (response.hasBody()) {
final VnfPkgInfo[] vnfPackages = response.getBody();
+ assert (vnfPackages != null);
final InlineResponse2001[] responses = new InlineResponse2001[vnfPackages.length];
for (int index = 0; index < vnfPackages.length; index++) {
if (conversionService.canConvert(vnfPackages[index].getClass(), InlineResponse2001.class)) {
@@ -113,7 +116,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
}
logger.error("Unable to find Converter for response class: {}", vnfPackages[index].getClass());
}
- return Optional.ofNullable(responses);
+ return Optional.of(responses);
}
logger.error("Received response without body ...");
}
@@ -170,6 +173,33 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
return requestVnfElement(vnfPkgId, vnfRequestUrl, vnfRequestName);
}
+ @Override
+ public Optional<PkgmSubscription> postSubscription(
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest) {
+ try {
+ final ResponseEntity<PkgmSubscription> responseEntity =
+ httpServiceProvider.postHttpRequest(etsiCatalogManagerSubscriptionRequest,
+ etsiCatalogUrlProvider.getSubscriptionUrl(), PkgmSubscription.class);
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ if (responseEntity.hasBody()) {
+ return Optional.of(responseEntity.getBody());
+ }
+ logger.error("Received response without body on postSubscription");
+ }
+ logger.error("Unexpected Status Code Received on postSubscription: {}", responseEntity.getStatusCode());
+ return Optional.empty();
+ } catch (final InvalidRestRequestException invalidRestRequestException) {
+ logger.error("Caught InvalidRestRequestException", invalidRestRequestException);
+ throw new EtsiCatalogManagerBadRequestException("Bad Request Received on postSubscription call.");
+ } catch (final RestProcessingException restProcessingException) {
+ logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(),
+ restProcessingException);
+ throw new EtsiCatalogManagerRequestFailureException(
+ "Internal Server Error Occurred. On postSubscription with StatusCode: "
+ + restProcessingException.getStatusCode());
+ }
+ }
+
private Optional<byte[]> requestVnfElement(final String vnfPkgId, final String vnfRequestUrl,
final String vnfRequestName) {
try {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
index 8382212d51..3b4c4c3066 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
@@ -99,4 +99,15 @@ public class EtsiCatalogUrlProvider {
logger.info("getEtsiCatalogVnfPackageVnfd: {}", url);
return url;
}
+
+ /**
+ * Get the URL for posting/retrieving a Subscription
+ *
+ * @return the URL for the operation
+ */
+ public String getSubscriptionUrl() {
+ final String url = etsiCatalogManagerEndpoint + "/subscriptions";
+ logger.info("getSubscriptionNotificationUrl: {}", url);
+ return url;
+ }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
new file mode 100644
index 0000000000..30a16f70a8
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication.AuthTypeEnum.BASIC;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogUrlProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionRequestConversionException;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.convert.ConversionException;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Service;
+
+/**
+ * Manages package management subscriptions from the VNFMs
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ *
+ */
+@Service
+public class SubscriptionManager {
+
+ private static final Logger logger = getLogger(SubscriptionManager.class);
+ private final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider;
+ private final EtsiCatalogUrlProvider etsiCatalogUrlProvider;
+ private final HttpRestServiceProvider httpServiceProvider;
+ private final ConversionService conversionService;
+ private final EtsiCatalogServiceProvider etsiCatalogServiceProvider;
+ private final String vnfmAdapterEndpoint;
+ private final String msoKeyString;
+ private final String vnfmAdapterAuth;
+
+
+ @Autowired
+ public SubscriptionManager(final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider,
+ final ConversionService conversionService, final HttpRestServiceProvider httpServiceProvider,
+ final EtsiCatalogUrlProvider etsiCatalogUrlProvider,
+ final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
+ @Value("${vnfmadapter.endpoint}") final String vnfmAdapterEndpoint,
+ @Value("${mso.key}") final String msoKeyString,
+ @Value("${vnfmadapter.auth:D6CFE56451508B75536C5E8A1E7AE06D0346006A693BF29293A6E1C762EFD59C671911DB6E9294E4FE15E4C1C5524B}") final String vnfmAdapterAuth) {
+ this.packageManagementCacheServiceProvider = packageManagementCacheServiceProvider;
+ this.etsiCatalogUrlProvider = etsiCatalogUrlProvider;
+ this.conversionService = conversionService;
+ this.httpServiceProvider = httpServiceProvider;
+ this.etsiCatalogServiceProvider = etsiCatalogServiceProvider;
+ this.vnfmAdapterEndpoint = vnfmAdapterEndpoint;
+ this.vnfmAdapterAuth = vnfmAdapterAuth;
+ this.msoKeyString = msoKeyString;
+ }
+
+ public Optional<InlineResponse2002> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest)
+ throws GeneralSecurityException {
+
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest =
+ buildEtsiCatalogManagerPkgmSubscriptionRequest(pkgmSubscriptionRequest);
+
+ final Optional<PkgmSubscription> optionalEtsiCatalogManagerSubscription =
+ etsiCatalogServiceProvider.postSubscription(etsiCatalogManagerSubscriptionRequest);
+
+ if (optionalEtsiCatalogManagerSubscription.isPresent()) {
+ PkgmSubscription etsiCatalogManagerSubscription = optionalEtsiCatalogManagerSubscription.get();
+ logger.debug("postPkgmSubscriptionRequest Response SubscriptionId: {}",
+ Objects.requireNonNull(etsiCatalogManagerSubscription.getId().toString()));
+ final String subscriptionId = etsiCatalogManagerSubscription.getId().toString();
+
+ packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest);
+
+ final InlineResponse2002 response2002 = new InlineResponse2002();
+ response2002.setId(subscriptionId);
+ response2002.setFilter(pkgmSubscriptionRequest.getFilter());
+ response2002.setCallbackUri(getSubscriptionUri(subscriptionId).toString());
+ response2002.setLinks(new SubscriptionsLinks()
+ .self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString())));
+
+ return Optional.of(response2002);
+ }
+ throw new InternalServerErrorException(
+ "Received empty response from POST to ETSI Catalog Manager Subscription Endpoint.");
+ }
+
+
+
+ public Optional<String> getSubscriptionId(final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
+ return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest);
+ }
+
+ public Optional<InlineResponse2002> getSubscription(final String subscriptionId) {
+ final Optional<PkgmSubscriptionRequest> optional =
+ packageManagementCacheServiceProvider.getSubscription(subscriptionId);
+ if (optional.isPresent()) {
+ final PkgmSubscriptionRequest subscription = optional.get();
+ return Optional.of(getInlineResponse2002(subscriptionId, subscription));
+ }
+ return Optional.empty();
+ }
+
+ public List<InlineResponse2002> getSubscriptions() {
+ final Map<String, PkgmSubscriptionRequest> subscriptions =
+ packageManagementCacheServiceProvider.getSubscriptions();
+ final List<InlineResponse2002> response = new ArrayList<>();
+ subscriptions.forEach((key, value) -> response.add(getInlineResponse2002(key, value)));
+ return response;
+ }
+
+ public URI getSubscriptionUri(final String subscriptionId) {
+ return URI.create(
+ vnfmAdapterEndpoint + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions/" + subscriptionId);
+ }
+
+ private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) {
+ return new InlineResponse2002().id(id).filter(subscription.getFilter())
+ .callbackUri(subscription.getCallbackUri());
+ }
+
+ private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest buildEtsiCatalogManagerPkgmSubscriptionRequest(
+ PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException {
+
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest;
+ try {
+ etsiCatalogManagerSubscriptionRequest = conversionService.convert(pkgmSubscriptionRequest,
+ org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest.class);
+ } catch (ConversionException conversionException) {
+ logger.error(conversionException.getMessage());
+ throw new SubscriptionRequestConversionException(
+ "Could not convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
+ } catch (Exception exception) {
+ logger.error(exception.getMessage());
+ throw new InternalServerErrorException(
+ "Could not convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
+ }
+
+ if (etsiCatalogManagerSubscriptionRequest != null) {
+ etsiCatalogManagerSubscriptionRequest
+ .setCallbackUri(vnfmAdapterEndpoint + Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL);
+
+ final String[] auth = decryptAuth();
+ final String username = auth[0];
+ final String password = auth[1];
+
+ etsiCatalogManagerSubscriptionRequest.setAuthentication(
+ new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication()
+ .addAuthTypeItem(BASIC).paramsBasic(new BasicAuth().userName(username).password(password)));
+ return etsiCatalogManagerSubscriptionRequest;
+ }
+ throw new SubscriptionRequestConversionException(
+ "Failed to convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
+ }
+
+ private String[] decryptAuth() throws GeneralSecurityException {
+ final String decryptedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoKeyString);
+ final String[] auth = decryptedAuth.split(":");
+ return auth;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java
new file mode 100644
index 0000000000..e1e9b2307e
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache;
+
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+
+/**
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ */
+public abstract class AbstractCacheServiceProvider {
+
+ private final CacheManager cacheManager;
+ private final String cacheName;
+
+ public AbstractCacheServiceProvider(final String cacheName, final CacheManager cacheManager) {
+ this.cacheName = cacheName;
+ this.cacheManager = cacheManager;
+ }
+
+ public Cache getCache() {
+ final Cache cache = cacheManager.getCache(cacheName);
+ if (cache == null) {
+ throw new CacheNotFoundException("Unable to find " + cacheName + " cache");
+ }
+ return cache;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java
new file mode 100644
index 0000000000..830db39888
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache;
+
+import java.util.Arrays;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.concurrent.ConcurrentMapCache;
+import org.springframework.cache.support.SimpleCacheManager;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ */
+@Configuration
+public class CacheManagerConfiguration {
+
+ @Bean
+ public CacheManager cacheManager() {
+ final SimpleCacheManager manager = new SimpleCacheManager();
+ manager.setCaches(Arrays.asList(getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE)));
+
+ return manager;
+ }
+
+ private Cache getCache(final String name) {
+ return new ConcurrentMapCache(name);
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java
new file mode 100644
index 0000000000..edd5982ab1
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache;
+
+/**
+ * Exception for failure to find the cache.
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ *
+ */
+public class CacheNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = -372361485260755367L;
+
+ public CacheNotFoundException(final String message) {
+ super(message);
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java
new file mode 100644
index 0000000000..6042513a50
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+
+/**
+ * Interface which provides methods for communicating with the cache
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ *
+ */
+public interface PackageManagementCacheServiceProvider {
+
+ /**
+ * Checks cache if subscription request Id is already present. If not, it adds the subscription to the cache.
+ *
+ * @param subscriptionId
+ * @param pkgmSubscriptionRequest
+ */
+ void addSubscription(final String subscriptionId, final PkgmSubscriptionRequest pkgmSubscriptionRequest);
+
+ /**
+ * Gets individual subscription from cache
+ *
+ * @param subscriptionId
+ * @return <AbstractMap.SimpleImmutableEntry<String, PkgmSubscriptionRequest>>
+ */
+ Optional<PkgmSubscriptionRequest> getSubscription(final String subscriptionId);
+
+ /**
+ * Gets Map of subscriptions from cache
+ *
+ * @return Map<String, PkgmSubscriptionRequest>>
+ */
+ Map<String, PkgmSubscriptionRequest> getSubscriptions();
+
+ /**
+ * Delete subscription from cache
+ *
+ * @param subscriptionId
+ * @return true if subscription exists and able to be removed, otherwise returns false
+ */
+ boolean deleteSubscription(final String subscriptionId);
+
+ /**
+ * Checks if subscription exists in cache and return its subscriptionId
+ *
+ * @param pkgmSubscriptionRequest
+ * @return Subscription Id
+ */
+ Optional<String> getSubscriptionId(final PkgmSubscriptionRequest pkgmSubscriptionRequest);
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java
new file mode 100644
index 0000000000..ba57eb5e05
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implementation which provides methods for communicating with the cache
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ */
+@Service
+public class PackageManagementCacheServiceProviderImpl extends AbstractCacheServiceProvider
+ implements PackageManagementCacheServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PackageManagementCacheServiceProviderImpl.class);
+
+ @Autowired
+ public PackageManagementCacheServiceProviderImpl(final CacheManager cacheManager) {
+ super(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE, cacheManager);
+ }
+
+ @Override
+ public void addSubscription(final String subscriptionId, final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
+ LOGGER.debug("Adding {} to cache with subscription id: {}", pkgmSubscriptionRequest, subscriptionId);
+ getCache().put(subscriptionId, pkgmSubscriptionRequest);
+ }
+
+ @Override
+ public Optional<PkgmSubscriptionRequest> getSubscription(final String subscriptionId) {
+ LOGGER.debug("Getting subscription from cache using Id: {}", subscriptionId);
+ final Cache cache = getCache();
+ final PkgmSubscriptionRequest cacheValue = cache.get(subscriptionId, PkgmSubscriptionRequest.class);
+ if (cacheValue != null) {
+ return Optional.of(cacheValue);
+ }
+ LOGGER.error("Unable to find Subscription in cache using Id: {}", subscriptionId);
+ return Optional.empty();
+ }
+
+ @Override
+ public Map<String, PkgmSubscriptionRequest> getSubscriptions() {
+ LOGGER.info("Getting all subscriptions from cache");
+ final Cache cache = getCache();
+
+ final Object nativeCache = cache.getNativeCache();
+ if (nativeCache instanceof ConcurrentHashMap) {
+ @SuppressWarnings("unchecked")
+ final ConcurrentHashMap<Object, Object> concurrentHashMap = (ConcurrentHashMap<Object, Object>) nativeCache;
+ final Map<String, PkgmSubscriptionRequest> result = new HashMap<>();
+ concurrentHashMap.keySet().forEach(key -> {
+ final Optional<PkgmSubscriptionRequest> optional = getSubscription(key.toString());
+ optional.ifPresent(pkgmSubscriptionRequest -> result.put(key.toString(), pkgmSubscriptionRequest));
+ });
+ return result;
+ }
+ LOGGER.error("Unable to find Subscriptions in cache");
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public boolean deleteSubscription(final String subscriptionId) {
+ final Cache cache = getCache();
+ final Optional<PkgmSubscriptionRequest> optional = getSubscription(subscriptionId);
+ if (optional.isPresent()) {
+ cache.evict(subscriptionId);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Optional<String> getSubscriptionId(final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
+ final Cache cache = getCache();
+ final Object nativeCache = cache.getNativeCache();
+ if (nativeCache instanceof ConcurrentHashMap) {
+ @SuppressWarnings("unchecked")
+ final ConcurrentHashMap<Object, Object> concurrentHashMap = (ConcurrentHashMap<Object, Object>) nativeCache;
+ final Optional<Entry<Object, Object>> optional = concurrentHashMap.entrySet().stream()
+ .filter(entry -> entry.getValue().equals(pkgmSubscriptionRequest)).findAny();
+ if (optional.isPresent()) {
+ return Optional.of(optional.get().getKey().toString());
+ }
+ }
+ return Optional.empty();
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
new file mode 100644
index 0000000000..c5bd5bc14e
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import javax.ws.rs.core.MediaType;
+import org.slf4j.Logger;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * This controller handles the ETSI Subscription Notification Endpoints.
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ */
+@Controller
+@RequestMapping(value = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL,
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+public class EtsiSubscriptionNotificationController {
+
+ private static final Logger logger = getLogger(EtsiSubscriptionNotificationController.class);
+
+ @GetMapping(value = "/notification")
+ public ResponseEntity<Void> testSubscriptionNotificationEndPoint() {
+ logger.debug("Testing Notification Endpoint");
+ return ResponseEntity.noContent().build();
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
index 9d8e29b3f9..cce7241757 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
@@ -75,7 +75,7 @@ public class Sol003PackageManagementController {
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" \n"
+ "endpoint.";
logger.error(errorMessage);
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
}
/**
@@ -97,7 +97,7 @@ public class Sol003PackageManagementController {
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" by vnfPkgId: \""
+ vnfPkgId + "\" \n" + "endpoint.";
logger.error(errorMessage);
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
}
/**
@@ -121,7 +121,7 @@ public class Sol003PackageManagementController {
+ "endpoint.";
logger.error(errorMessage);
- return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
+ return new ResponseEntity(new ProblemDetails().detail(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
}
/**
@@ -144,7 +144,7 @@ public class Sol003PackageManagementController {
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"package_content\" \n"
+ "endpoint.";
logger.error(errorMessage);
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
}
/**
@@ -170,19 +170,9 @@ public class Sol003PackageManagementController {
+ " Sol003PackageManagementController from the EtsiCatalogManager using the\n GET \"vnf_packages\" by vnfPkgId: \""
+ vnfPkgId + "\" for artifactPath: \"" + artifactPath + "\"\n" + "endpoint.";
logger.error(errorMessage);
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
- }
-
- /**
- * Builds the ProblemDetails Object, using the provided error message.
- *
- * @param detail The error message retrieved from the exception thrown.
- * @return ProblemDetails Object, containing error information.
- */
- private ProblemDetails buildProblemDetails(final String detail) {
- final ProblemDetails problemDetails = new ProblemDetails();
- problemDetails.setDetail(detail);
- return problemDetails;
+ // return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new
+ // ProblemDetails().detail(errorMessage));
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java
new file mode 100644
index 0000000000..cbad564210
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
+import java.util.List;
+import java.util.Optional;
+import javax.ws.rs.core.MediaType;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Controller for handling the Subscription Management. The client can use this resource to subscribe to notifications
+ * related to the VNF package management, and to query its subscriptions. For further information please read:
+ * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf Use the section number
+ * above each endpoint to find the corresponding section in the above document.
+ *
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ */
+@Controller
+@RequestMapping(value = PACKAGE_MANAGEMENT_BASE_URL, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+public class Sol003PackageManagementSubscriptionController {
+
+ private static final String LOG_REQUEST_RECEIVED = "Subscription Management Controller: {} {}";
+ private static final Logger logger = getLogger(Sol003PackageManagementSubscriptionController.class);
+ private final SubscriptionManager subscriptionManager;
+
+ @Autowired
+ public Sol003PackageManagementSubscriptionController(final SubscriptionManager subscriptionManager) {
+ this.subscriptionManager = subscriptionManager;
+ }
+
+ /**
+ * POST Subscribe request. Will send request and respond with the subscription that you subscribed to, if
+ * successful. Section Number: 10.4.7
+ *
+ * @param pkgmSubscriptionRequest This includes the details of the subscription to be created.
+ * @return The subscription requested, if successful. Object: InlineRespone2002 Response Code: 201 Created Response
+ * Code: 303 Duplicate Subscription
+ * @throws GeneralSecurityException
+ */
+ @PostMapping(value = "/subscriptions")
+ public ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest)
+ throws GeneralSecurityException {
+ logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called");
+
+ // Check if subscription exists already.
+ final Optional<String> exists = subscriptionManager.getSubscriptionId(pkgmSubscriptionRequest);
+
+ if (exists.isPresent()) {
+ final URI subscriptionUri = subscriptionManager.getSubscriptionUri(exists.get());
+ final HttpHeaders headers = createLocationHeader(subscriptionUri);
+ logger.info("PkgmSubscriptionRequest already exists with uri {} ", subscriptionUri);
+ return new ResponseEntity<>(headers, HttpStatus.SEE_OTHER);
+ }
+
+ logger.debug("No duplicate Subscription exists, continuing with POST.");
+ final Optional<InlineResponse2002> optionalInlineResponse2002 =
+ subscriptionManager.createSubscription(pkgmSubscriptionRequest);
+
+ if (optionalInlineResponse2002.isPresent()) {
+ InlineResponse2002 inlineResponse2002 = optionalInlineResponse2002.get();
+ final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse2002.getId());
+ final HttpHeaders headers = createLocationHeader(subscriptionUri);
+ logger.debug("Sending response with uri {} ", subscriptionUri);
+ return new ResponseEntity<>(inlineResponse2002, headers, HttpStatus.CREATED);
+ }
+ final String errorMessage = "A null response was received during the postSubscriptionRequest call.";
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ /**
+ * GET all subscriptions. Will return a list of all subscriptions currently active. Section Number: 10.4.7
+ *
+ * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK
+ */
+ @GetMapping(value = "/subscriptions")
+ public ResponseEntity<List<InlineResponse2002>> getSubscriptions() {
+ logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions.");
+ List<InlineResponse2002> subscriptionsList = subscriptionManager.getSubscriptions();
+ return new ResponseEntity<>(subscriptionsList, HttpStatus.OK);
+ }
+
+ /**
+ * GET a specific subscription, by subscriptionId. Section Number: 10.4.8
+ *
+ * @param subscriptionId The ID of the subscription that you wish to retrieve.
+ * @return A subscription based on subscriptionId. Object: InlineResponse2002 Response Code: 200 OK
+ */
+ @GetMapping(value = "/subscriptions/{subscriptionId}")
+ public ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId) {
+ logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId);
+ final Optional<InlineResponse2002> optional = subscriptionManager.getSubscription(subscriptionId);
+ if (optional.isPresent()) {
+ logger.debug("Return subscription with id {} and body {}", subscriptionId, optional);
+ return new ResponseEntity<>(optional.get(), HttpStatus.OK);
+ }
+ final String errorMessage =
+ "The requested subscription: " + subscriptionId + " was not found on call getSubscription";
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ /**
+ * Method to set the Location in the header with the URI parameter
+ *
+ * @param subscriptionUri
+ * @return header with callbackUri in Location
+ */
+ private HttpHeaders createLocationHeader(final URI subscriptionUri) {
+ final HttpHeaders headers = new HttpHeaders();
+ headers.setLocation(subscriptionUri);
+ return headers;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java
deleted file mode 100644
index 16650d4a3d..0000000000
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapters.vnfmadapter.rest;
-
-import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
-import static org.slf4j.LoggerFactory.getLogger;
-import java.util.List;
-import javax.ws.rs.core.MediaType;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
-import org.slf4j.Logger;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * Controller for handling the Subscription Management. For further information please read:
- * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf Use the section number
- * above each endpoint to find the corresponding section in the above document.
- *
- * @author gareth.roper@est.tech
- */
-@Controller
-@RequestMapping(value = PACKAGE_MANAGEMENT_BASE_URL, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-public class Sol003SubscriptionManagementController {
-
- private static final String LOG_REQUEST_RECEIVED = "Subscription Management Controller: {} {}";
- private static final Logger logger = getLogger(Sol003SubscriptionManagementController.class);
-
- /**
- * POST Subscribe request. Will send request and respond with the subscription that you subscribed to, if
- * successful. Section Number: 10.4.7
- *
- * @param pkgmSubscriptionRequest This includes the details of the subscription to be created.
- * @return The subscription requested, if successful. Object: InlineRespone2002 Response Code: 201 Created Response
- * Code: 303 Duplicate Subscription
- */
- @PostMapping(value = "/subscriptions")
- public ResponseEntity<InlineResponse2002> postSubscriptionRequest(
- @RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
- logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest: ", pkgmSubscriptionRequest);
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
- }
-
- /**
- * GET all subscriptions. Will return a list of all subscriptions currently active. Section Number: 10.4.7
- *
- * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK
- */
- @GetMapping(value = "/subscriptions")
- public ResponseEntity<List<InlineResponse2002>> getSubscriptions() {
- logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions.");
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
- }
-
- /**
- * GET a specific subscription, by subscriptionId. Section Number: 10.4.8
- *
- * @param subscriptionId The ID of the subscription that you wish to retrieve.
- * @return A subscription based on subscriptionId. Object: InlineResponse2002 Response Code: 200 OK
- */
- @GetMapping(value = "/subscriptions/{subscriptionId}")
- public ResponseEntity<InlineResponse2002> getSubscription(
- @PathVariable("subscriptionId") final String subscriptionId) {
- logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId);
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
- }
-
- /**
- * DELETE a specific subscription, by subscriptionId. Section Number: 10.4.7
- *
- * @param subscriptionId The ID of the subscription that you wish to delete.
- * @return Empty response if successful. Object: Void Response Code: 204 No Content
- */
- @DeleteMapping(value = "/subscriptions/{subscriptionId}")
- public ResponseEntity<Void> deleteSubscription(@PathVariable("subscriptionId") final String subscriptionId) {
- logger.info(LOG_REQUEST_RECEIVED, " Deleting Subscription: ", subscriptionId);
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
- }
-
-
-}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java
new file mode 100644
index 0000000000..dbd098f7cd
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an ETSI Catalog Manager Bad Request Exception.
+ *
+ * @author Gareth Roper (gareth.roper@est.tech
+ */
+@ResponseStatus(code = HttpStatus.BAD_REQUEST)
+public class EtsiCatalogManagerBadRequestException extends RuntimeException {
+
+ private static final long serialVersionUID = 6571317418914258768L;
+
+ public EtsiCatalogManagerBadRequestException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java
new file mode 100644
index 0000000000..9b547d3c5a
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an ETSI Catalog Manager Request Failure
+ *
+ * @author gareth.roper@est.tech
+ */
+@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+public class InternalServerErrorException extends RuntimeException {
+
+ private static final long serialVersionUID = 66864561537194516L;
+
+ public InternalServerErrorException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
index a49063a72f..da8b0cbff2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
@@ -48,6 +48,30 @@ public class Sol003PackageManagementControllerExceptionHandler {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(problemDetails);
}
+ @ExceptionHandler(EtsiCatalogManagerBadRequestException.class)
+ public ResponseEntity<ProblemDetails> handleEtsiCatalogManagerBadRequestFailureException(
+ final EtsiCatalogManagerBadRequestException etsiCatalogManagerBadRequestException) {
+ final ProblemDetails problemDetails = new ProblemDetails();
+ problemDetails.setDetail(etsiCatalogManagerBadRequestException.getMessage());
+ return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(problemDetails);
+ }
+
+ @ExceptionHandler(SubscriptionNotFoundException.class)
+ public ResponseEntity<ProblemDetails> handleSubscriptionNotFoundException(
+ final SubscriptionNotFoundException subscriptionNotFoundException) {
+ final ProblemDetails problemDetails = new ProblemDetails();
+ problemDetails.setDetail(subscriptionNotFoundException.getMessage());
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(problemDetails);
+ }
+
+ @ExceptionHandler(SubscriptionRequestConversionException.class)
+ public ResponseEntity<ProblemDetails> handleSubscriptionRequestConversionException(
+ final SubscriptionRequestConversionException subscriptionRequestConversionException) {
+ final ProblemDetails problemDetails = new ProblemDetails();
+ problemDetails.setDetail(subscriptionRequestConversionException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(problemDetails);
+ }
+
@ExceptionHandler(VnfPkgConflictException.class)
public ResponseEntity<ProblemDetails> handleVnfPkgConflictException(
final VnfPkgConflictException vnfPkgConflictException) {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java
new file mode 100644
index 0000000000..58c2ef050d
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an ETSI Catalog Manager Request Failure
+ *
+ * @author gareth.roper@est.tech
+ */
+@ResponseStatus(code = HttpStatus.NOT_FOUND)
+public class SubscriptionNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = 85268561453194516L;
+
+ public SubscriptionNotFoundException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java
new file mode 100644
index 0000000000..daa544f928
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an ETSI Catalog Manager Request Failure
+ *
+ * @author gareth.roper@est.tech
+ */
+@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+public class SubscriptionRequestConversionException extends RuntimeException {
+
+ private static final long serialVersionUID = 45898561453196895L;
+
+ public SubscriptionRequestConversionException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
new file mode 100644
index 0000000000..f90978e0d5
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
@@ -0,0 +1,257 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import java.security.GeneralSecurityException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import com.google.gson.Gson;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.http.HttpMethod;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.hamcrest.Matchers.is;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+
+/**
+ * @author Ronan Kenny (ronan.kenny@est.tech)
+ * @author Gareth Roper (gareth.roper@est.tech)
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@SuppressWarnings("unchecked")
+public class Sol003PackageManagementSubscriptionControllerTest {
+
+ private static String subscriptionId;
+ private final Gson gson = new Gson();
+
+ @Autowired
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE)
+ private RestTemplate testRestTemplate;
+
+ private MockRestServiceServer mockRestServer;
+
+ @Autowired
+ private CacheManager cacheServiceProvider;
+ private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
+
+ @Autowired
+ private Sol003PackageManagementSubscriptionController sol003PackageManagementSubscriptionController;
+
+ @Before
+ public void setUp() {
+ mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build();
+ final Cache cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
+ cache.clear();
+ }
+
+ @Test
+ public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest();
+ final ResponseEntity<InlineResponse2002> response =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest);
+
+ final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri());
+
+ SubscriptionsLinks subscriptionsLinks = new SubscriptionsLinks();
+ VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf();
+ vnfPackagesLinksSelf.setHref("https://so-vnfm-adapter.onap:30406" + PACKAGE_MANAGEMENT_BASE_URL
+ + "/subscriptions/" + response.getBody().getId());
+ subscriptionsLinks.setSelf(vnfPackagesLinksSelf);
+
+ assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter());
+ assertEquals(subscriptionsLinks, response.getBody().getLinks());
+ assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter());
+ assert (response.getHeaders().equals(headers));
+ assertThat(response.getStatusCode(), is(HttpStatus.CREATED));
+ assertNotNull(response.getBody().getCallbackUri());
+ }
+
+ @Test
+ public void testFailPostSubscriptionAlreadyExists() throws GeneralSecurityException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest();
+
+ final ResponseEntity<InlineResponse2002> response =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest);
+ subscriptionId = Objects.requireNonNull(response.getBody()).getId();
+
+ // Create duplicate entry
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest2 = buildPkgmSubscriptionRequest();
+
+ final ResponseEntity<InlineResponse2002> response2002 =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest2);
+
+ assertEquals(HttpStatus.SEE_OTHER, response2002.getStatusCode());
+ }
+
+ @Test
+ public void testSuccessGetSubscriptionWithSubscriptionId() throws GeneralSecurityException, URISyntaxException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest();
+
+ final ResponseEntity<InlineResponse2002> response =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest);
+ subscriptionId = Objects.requireNonNull(response.getBody()).getId();
+
+ final ResponseEntity<InlineResponse2002> response2002 =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .getSubscription(subscriptionId);
+
+ final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri());
+
+
+ assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter());
+ assert (response.getHeaders().equals(headers));
+ assertEquals(HttpStatus.OK, response2002.getStatusCode());
+ assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter());
+ // Ensure CallBackUri is set to new URI
+ assertNotEquals(pkgmSubscriptionRequest.getCallbackUri(), response.getBody().getCallbackUri());
+ }
+
+ @Test
+ public void testFailGetSubscriptionWithInvalidSubscriptionId() {
+ final ResponseEntity<InlineResponse2002> response =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .getSubscription("invalidSubscriptionId");
+ assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
+ }
+
+ @Test
+ public void testSuccessGetSubscriptions() throws GeneralSecurityException {
+ final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
+
+ mockRestServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ .andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
+
+ sol003PackageManagementSubscriptionController.postSubscriptionRequest(pkgmSubscriptionRequest);
+ ResponseEntity<List<InlineResponse2002>> response =
+ sol003PackageManagementSubscriptionController.getSubscriptions();
+
+ List<InlineResponse2002> subscriptionsList = response.getBody();
+
+ assertEquals(Objects.requireNonNull(response.getBody()).get(0).getFilter(),
+ pkgmSubscriptionRequest.getFilter());
+ assert (subscriptionsList != null);
+ assertNotEquals('0', subscriptionsList.size());
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ }
+
+ private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest();
+ final SubscriptionsFilter sub = buildSubscriptionsFilter();
+ final SubscriptionsAuthentication auth = new SubscriptionsAuthentication();
+ pkgmSubscriptionRequest.setFilter(sub);
+ pkgmSubscriptionRequest.setCallbackUri(msbEndpoint.toString());
+ pkgmSubscriptionRequest.setAuthentication(auth);
+ return pkgmSubscriptionRequest;
+ }
+
+ private SubscriptionsFilter buildSubscriptionsFilter() {
+ final SubscriptionsFilter sub = new SubscriptionsFilter();
+ final List<String> vnfdIdList = new ArrayList();
+ final List<String> vnfPkgIdList = new ArrayList();
+ final List<NotificationTypesEnum> notificationTypes = new ArrayList<>();
+ final SubscriptionsFilterVnfProductsFromProviders subscriptionsFilterVnfProductsFromProviders =
+ new SubscriptionsFilterVnfProductsFromProviders();
+ final List<SubscriptionsFilterVnfProductsFromProviders> vnfProductsFromProviders = new ArrayList<>();
+
+ vnfProductsFromProviders.add(subscriptionsFilterVnfProductsFromProviders);
+ sub.setVnfdId(vnfdIdList);
+ sub.setNotificationTypes(notificationTypes);
+ sub.setVnfPkgId(vnfPkgIdList);
+ sub.setVnfProductsFromProviders(vnfProductsFromProviders);
+ return sub;
+ }
+
+ private PkgmSubscription buildPkgmSubscription() {
+ PkgmSubscription pkgmSubscription = new PkgmSubscription();
+ PkgmNotificationsFilter pkgmNotificationsFilter = new PkgmNotificationsFilter();
+ LinkSelf linkSelf = new LinkSelf();
+ String id = UUID.randomUUID().toString();
+ pkgmSubscription.setId(id);
+ pkgmSubscription.setCallbackUri(msbEndpoint + "/" + pkgmSubscription.getId().toString());
+ pkgmSubscription.setFilter(pkgmNotificationsFilter);
+ pkgmSubscription.setLinks(linkSelf);
+ return pkgmSubscription;
+ }
+
+ private PkgmSubscriptionRequest postSubscriptionForTest() {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
+ final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
+
+ mockRestServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ .andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
+ return pkgmSubscriptionRequest;
+ }
+
+ private HttpHeaders buildHttpHeaders(String uri) throws URISyntaxException {
+ final HttpHeaders headers = new HttpHeaders();
+ URI myUri = new URI(uri);
+ headers.setLocation(myUri);
+ return headers;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java
deleted file mode 100644
index ed1880035a..0000000000
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.onap.so.adapters.vnfmadapter.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import java.net.URISyntaxException;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.client.MockRestServiceServer;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * @author gareth.roper@est.tech
- */
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
-public class Sol003SubscriptionManagementControllerTest {
-
- private static final String subscriptionId = "mySubscriptionId";
-
- @Autowired
- @Qualifier(CONFIGURABLE_REST_TEMPLATE)
- private RestTemplate testRestTemplate;
-
- @Autowired
- private Sol003SubscriptionManagementController controller;
-
- @Before
- public void setUp() throws Exception {
- MockRestServiceServer.bindTo(testRestTemplate).build();
- }
-
- @Test
- public void postSubscriptionRequest() throws URISyntaxException, InterruptedException {
- final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest();
- final ResponseEntity<InlineResponse2002> response = controller.postSubscriptionRequest(pkgmSubscriptionRequest);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode());
- }
-
- @Test
- public void getSubscriptions() throws URISyntaxException, InterruptedException {
- final ResponseEntity<List<InlineResponse2002>> response = controller.getSubscriptions();
- assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode());
- }
-
- @Test
- public void deleteSubscription() throws URISyntaxException, InterruptedException {
- final ResponseEntity<Void> response = controller.deleteSubscription(subscriptionId);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode());
- }
-
- @Test
- public void getSubscription() throws URISyntaxException, InterruptedException {
- final ResponseEntity<InlineResponse2002> response = controller.getSubscription(subscriptionId);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode());
- }
-}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
index ae66464f29..cdb6662191 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml
@@ -40,6 +40,7 @@ sdc:
vnfmadapter:
endpoint: https://so-vnfm-adapter.onap:30406
+
#Actuator
management:
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index 0bb92e32ff..fcc59c3340 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -9,9 +9,9 @@
* 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.
@@ -27,6 +27,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -36,6 +37,9 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.io.File;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@@ -53,6 +57,7 @@ import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.Configurations;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.InstanceGroup;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.L3Networks;
import org.onap.aai.domain.yang.ServiceInstance;
@@ -74,20 +79,13 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
-import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
-import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
-import org.onap.so.db.catalog.beans.VfModuleCustomization;
-import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
-import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
@@ -119,296 +117,192 @@ public class BBInputSetupUtilsTest {
}
@Test
- public void testGetCatalogServiceByModelUUID() throws JsonParseException, JsonMappingException, IOException {
+ public void getCatalogServiceByModelUUIDTest() throws IOException {
Service expected = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
+ final String modelUUID = "modelUUIDTest";
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("modelUUID");
- requestDetails.setModelInfo(modelInfo);
- doReturn(expected).when(MOCK_catalogDbClient).getServiceByID("modelUUID");
- Service actual = bbInputSetupUtils.getCatalogServiceByModelUUID(modelInfo.getModelVersionId());
+ doReturn(expected).when(MOCK_catalogDbClient).getServiceByID(modelUUID);
- assertThat(actual, sameBeanAs(expected));
+ assertThat(bbInputSetupUtils.getCatalogServiceByModelUUID(modelUUID), sameBeanAs(expected));
}
@Test
- public void testGetCatalogServiceByModelVersionAndModelInvariantUUID()
- throws JsonParseException, JsonMappingException, IOException {
- String modelVersion = "modelVersion";
- String modelInvariantUUID = "modelInvariantUUID";
+ public void getCatalogServiceByModelVersionAndModelInvariantUUIDTest() throws IOException {
+ final String modelVersion = "modelVersionTest";
+ final String modelInvariantUUID = "modelInvariantUUIDTest";
Service expectedService =
mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
- doReturn(expectedService).when(MOCK_catalogDbClient)
- .getServiceByModelVersionAndModelInvariantUUID(isA(String.class), isA(String.class));
-
- Service actualService = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(modelVersion,
+ doReturn(expectedService).when(MOCK_catalogDbClient).getServiceByModelVersionAndModelInvariantUUID(modelVersion,
modelInvariantUUID);
- assertThat(actualService, sameBeanAs(expectedService));
+ assertThat(bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(modelVersion,
+ modelInvariantUUID), sameBeanAs(expectedService));
}
@Test
- public void testGetVnfcInstanceGroups() throws JsonParseException, JsonMappingException, IOException {
+ public void getVnfcInstanceGroupsTest() throws IOException {
+ final String modelCustomizationUUID = "modelCustomizationUUIDTest";
VnfcInstanceGroupCustomization vnfc = mapper.readValue(
new File(RESOURCE_PATH + "VnfcInstanceGroupCustomization.json"), VnfcInstanceGroupCustomization.class);
- String modelCustomizationUUID = "modelCustomizationUUID";
doReturn(Arrays.asList(vnfc)).when(MOCK_catalogDbClient)
- .getVnfcInstanceGroupsByVnfResourceCust(isA(String.class));
-
- List<VnfcInstanceGroupCustomization> actualVnfcList =
- bbInputSetupUtils.getVnfcInstanceGroups(modelCustomizationUUID);
+ .getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID);
- assertThat(actualVnfcList, sameBeanAs(Arrays.asList(vnfc)));
+ assertThat(bbInputSetupUtils.getVnfcInstanceGroups(modelCustomizationUUID), sameBeanAs(Arrays.asList(vnfc)));
}
@Test
- public void testGetRequestDetails() throws JsonParseException, JsonMappingException, IOException {
+ public void getRequestDetailsTest() throws IOException {
+ final String requestId = "requestId";
InfraActiveRequests infraActiveRequest = mapper
.readValue(new File(RESOURCE_PATH + "InfraActiveRequestExpected.json"), InfraActiveRequests.class);
-
RequestDetails expected =
mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsExpected.json"), RequestDetails.class);
- String requestId = "requestId";
+
doReturn(infraActiveRequest).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
- RequestDetails actual = bbInputSetupUtils.getRequestDetails(requestId);
- assertThat(actual, sameBeanAs(expected));
+ assertThat(bbInputSetupUtils.getRequestDetails(requestId), sameBeanAs(expected));
}
@Test
public void getRequestDetailsNullTest() throws IOException {
- RequestDetails requestDetails = bbInputSetupUtils.getRequestDetails("");
-
- assertNull(requestDetails);
+ assertNull(bbInputSetupUtils.getRequestDetails(""));
}
@Test
- public void testGetCloudRegion() {
+ public void getCloudRegionTest() {
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
- Optional<org.onap.aai.domain.yang.CloudRegion> expected =
- Optional.of(new org.onap.aai.domain.yang.CloudRegion());
- expected.get().setCloudOwner("cloudOwner");
- expected.get().setCloudRegionId("lcpCloudRegionId");
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class,
+ Optional<CloudRegion> expected = Optional.of(new CloudRegion());
+
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(CloudRegion.class,
AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO);
- bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri);
+ assertThat(bbInputSetupUtils.getCloudRegion(cloudConfig), sameBeanAs(expected.get()));
}
@Test
- public void testGetCloudRegionExceptionTest() {
-
+ public void getCloudRegionNullTest() {
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setCloudConfiguration(cloudConfig);
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- assertNull(cloudRegion);
+ assertNull(bbInputSetupUtils.getCloudRegion(cloudConfig));
}
@Test
- public void testGetCloudRegionEmptyId() {
+ public void getCloudRegionEmptyIdTest() {
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("");
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setCloudConfiguration(cloudConfig);
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- assertNull(cloudRegion);
+ assertNull(bbInputSetupUtils.getCloudRegion(cloudConfig));
}
@Test
- public void testGetCloudRegionEmptyConfiguration() {
- RequestDetails requestDetails = new RequestDetails();
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration());
-
- assertNull(cloudRegion);
- }
-
- @Test
- public void testGetAAIInstanceGroup() {
- Optional<org.onap.aai.domain.yang.InstanceGroup> expected =
- Optional.of(new org.onap.aai.domain.yang.InstanceGroup());
- String instanceGroupId = "instanceGroupId";
+ public void getAAIInstanceGroupTest() {
+ final String instanceGroupId = "instanceGroupId";
+ Optional<InstanceGroup> expected = Optional.of(new InstanceGroup());
expected.get().setId(instanceGroupId);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
+
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(InstanceGroup.class,
AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
- bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.InstanceGroup.class, expectedUri);
+ assertThat(bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId), sameBeanAs(expected.get()));
}
@Test
- public void testGetAAIInstanceGroupThrowNotFound() {
- String instanceGroupId = "instanceGroupId";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
- AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
-
- org.onap.aai.domain.yang.InstanceGroup actual = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
-
- assertNull(actual);
+ public void getAAIInstanceGroupNullTest() {
+ assertNull(bbInputSetupUtils.getAAIInstanceGroup(""));
}
@Test
- public void testGetAAICustomer() {
+ public void getAAICustomerTest() {
+ final String globalSubscriberId = "globalSubscriberId";
Optional<org.onap.aai.domain.yang.Customer> expected = Optional.of(new org.onap.aai.domain.yang.Customer());
- String globalSubscriberId = "globalSubscriberId";
expected.get().setGlobalCustomerId(globalSubscriberId);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId);
- bbInputSetupUtils.getAAICustomer(globalSubscriberId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Customer.class, expectedUri);
+ assertThat(bbInputSetupUtils.getAAICustomer(globalSubscriberId), sameBeanAs(expected.get()));
}
@Test
- public void testGetAAICustomerThrowNotFound() {
- String globalSubscriberId = "globalSubscriberId";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
- AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
-
- org.onap.aai.domain.yang.Customer actual = bbInputSetupUtils.getAAICustomer(globalSubscriberId);
-
- assertNull(actual);
+ public void getAAICustomerNullTest() {
+ assertNull(bbInputSetupUtils.getAAICustomer(""));
}
@Test
- public void testGetAAIServiceSubscription() {
+ public void getAAIServiceSubscriptionTest() {
+ final String globalSubscriberId = "globalSubscriberId";
+ final String subscriptionServiceType = "subscriptionServiceType";
Optional<org.onap.aai.domain.yang.ServiceSubscription> expected =
Optional.of(new org.onap.aai.domain.yang.ServiceSubscription());
- String globalSubscriberId = "globalSubscriberId";
- String subscriptionServiceType = "subscriptionServiceType";
+
expected.get().setServiceType(subscriptionServiceType);
doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class,
AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
subscriptionServiceType));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION,
- globalSubscriberId, subscriptionServiceType);
- bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceSubscription.class, expectedUri);
+ assertThat(bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType),
+ sameBeanAs(expected.get()));
}
@Test
- public void testGetAAIServiceSubscriptionErrors() {
- String globalSubId = null;
- String subServiceType = null;
- org.onap.aai.domain.yang.ServiceSubscription actual =
- bbInputSetupUtils.getAAIServiceSubscription(globalSubId, subServiceType);
- assertNull(actual);
-
- String globalSubId2 = "";
- String subServiceType2 = "";
- org.onap.aai.domain.yang.ServiceSubscription actual2 =
- bbInputSetupUtils.getAAIServiceSubscription(globalSubId2, subServiceType2);
- assertNull(actual2);
-
- String globalSubId3 = "";
- String subServiceType3 = null;
- org.onap.aai.domain.yang.ServiceSubscription actual3 =
- bbInputSetupUtils.getAAIServiceSubscription(globalSubId3, subServiceType3);
- assertNull(actual3);
-
- String globalSubId4 = null;
- String subServiceType4 = "";
- org.onap.aai.domain.yang.ServiceSubscription actual4 =
- bbInputSetupUtils.getAAIServiceSubscription(globalSubId4, subServiceType4);
- assertNull(actual4);
+ public void getAAIServiceSubscriptionErrorsTest() {
+ assertNull(bbInputSetupUtils.getAAIServiceSubscription(null, null));
+ assertNull(bbInputSetupUtils.getAAIServiceSubscription("", ""));
+ assertNull(bbInputSetupUtils.getAAIServiceSubscription("", null));
+ assertNull(bbInputSetupUtils.getAAIServiceSubscription(null, ""));
}
@Test
- public void testGetAAIServiceSubscriptionThrowNotFound() {
- String globalSubscriberId = "globalSubscriberId";
- String subscriptionServiceType = "subscriptionServiceType";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class,
- AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
- subscriptionServiceType));
- org.onap.aai.domain.yang.ServiceSubscription actual =
- bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
- assertNull(actual);
- }
-
- @Test
- public void testGetAAIServiceInstanceById() {
- String serviceInstanceId = "serviceInstanceId";
-
+ public void getAAIServiceInstanceByIdTest() {
+ final String serviceInstanceId = "serviceInstanceId";
ServiceInstance expectedServiceInstance = new ServiceInstance();
doReturn(Optional.of(expectedServiceInstance)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
isA(AAIResourceUri.class));
- ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
-
- assertThat(actualServiceInstance, sameBeanAs(expectedServiceInstance));
+ assertThat(bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId), sameBeanAs(expectedServiceInstance));
}
@Test
- public void testGetAAIServiceInstanceByIdThrowNotFound() {
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ public void getAAIServiceInstanceById_ifEmptyReturnNull() {
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(ServiceInstance.class),
+ any(AAIResourceUri.class));
- assertNull(actualServiceInstance);
+ assertNull(bbInputSetupUtils.getAAIServiceInstanceById("any"));
}
@Test
- public void testGetAAIServiceInstanceByIdAndCustomer() {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
+ public void getAAIServiceInstanceByIdAndCustomerTest() {
+ final String globalCustomerId = "globalCustomerId";
+ final String serviceType = "serviceType";
+ final String serviceInstanceId = "serviceInstanceId";
ServiceInstance expected = new ServiceInstance();
expected.setServiceInstanceId(serviceInstanceId);
- doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory
- .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId)
- .depth(Depth.TWO);
- this.bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType, serviceInstanceId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstance.class, expectedUri);
+ doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient).get(ServiceInstance.class, AAIUriFactory
+ .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId)
+ .depth(Depth.TWO));
+ assertThat(bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType,
+ serviceInstanceId), sameBeanAs(expected));
}
@Test
- public void testGetAAIServiceInstanceByIdAndCustomerThrowNotFound() {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- ServiceInstance actual = this.bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId,
- serviceType, serviceInstanceId);
+ public void getAAIServiceInstanceByIdAndCustomerNullTest() {
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(ServiceInstance.class),
+ any(AAIResourceUri.class));
- assertNull(actual);
+ assertNull(bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer("", "", ""));
}
@Test
- public void testGetAAIServiceInstanceByName() throws Exception {
- String serviceInstanceName = "serviceInstanceName";
+ public void getAAIServiceInstanceByNameTest() throws Exception {
+ final String serviceInstanceName = "serviceInstanceName";
ServiceInstance expectedServiceInstance = new ServiceInstance();
expectedServiceInstance.setServiceInstanceId("serviceInstanceId");
@@ -425,20 +319,17 @@ public class BBInputSetupUtilsTest {
doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory
- .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
- customer.getServiceSubscription().getServiceType())
- .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO);
- bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstances.class, expectedUri);
+ assertThat(bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer),
+ sameBeanAs(serviceInstances.getServiceInstance().get(0)));
}
@Test
- public void testGetAAIServiceInstanceByNameException() throws Exception {
- expectedException.expect(Exception.class);
+ public void getAAIServiceInstanceByNameExceptionTest() throws Exception {
+ final String serviceInstanceName = "serviceInstanceName";
- String serviceInstanceName = "serviceInstanceName";
+ expectedException.expect(Exception.class);
+ expectedException.expectMessage("Multiple Service Instances Returned");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
@@ -461,45 +352,26 @@ public class BBInputSetupUtilsTest {
}
@Test
- public void testGetAAIServiceInstanceByNameNull() throws Exception {
- String serviceInstanceName = "serviceInstanceName";
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("serviceType");
-
+ public void getAAIServiceInstanceByNameNullTest() throws Exception {
Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(serviceSubscription);
-
- ServiceInstances serviceInstances = new ServiceInstances();
- serviceInstances.getServiceInstance().add(serviceInstance);
- serviceInstances.getServiceInstance().add(serviceInstance);
+ customer.setServiceSubscription(new ServiceSubscription());
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- ServiceInstance actualServiceInstance =
- bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
-
- assertNull(actualServiceInstance);
+ assertNull(bbInputSetupUtils.getAAIServiceInstanceByName("", customer));
}
@Test
- public void testGetOptionalAAIServiceInstanceByNameException() throws Exception {
+ public void getOptionalAAIServiceInstanceByNameExceptionTest() throws Exception {
expectedException.expect(MultipleObjectsFoundException.class);
expectedException.expectMessage(containsString(
"Multiple service instances found for customer-id: globalCustomerId, service-type: serviceType and service-instance-name: serviceInstanceId."));
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
+ final String globalCustomerId = "globalCustomerId";
+ final String serviceType = "serviceType";
+ final String serviceInstanceId = "serviceInstanceId";
ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
+ serviceInstance.setServiceInstanceId(serviceInstanceId);
serviceInstance.setServiceType(serviceType);
- serviceInstance.setServiceInstanceName("serviceInstanceName");
ServiceInstances serviceInstances = new ServiceInstances();
serviceInstances.getServiceInstance().add(serviceInstance);
@@ -512,99 +384,81 @@ public class BBInputSetupUtilsTest {
}
@Test
- public void testGetOptionalAAIServiceInstanceByNameNull() throws Exception {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- Optional<ServiceInstance> actual =
- this.bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId);
+ public void getOptionalAAIServiceInstanceByNameNullTest() throws Exception {
+ Optional<ServiceInstance> actual = bbInputSetupUtils.getAAIServiceInstanceByName("", "", "");
assertThat(actual, sameBeanAs(Optional.empty()));
}
@Test
- public void testGetCatalogInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
- String modelUUID = "modelUUID";
+ public void getCatalogInstanceGroupNullTest() {
+ assertNull(bbInputSetupUtils.getCatalogInstanceGroup(""));
+ }
+ @Test
+ public void getCatalogInstanceGroupTest() throws IOException {
+ final String modelUUID = "modelUUIDTest";
org.onap.so.db.catalog.beans.InstanceGroup expectedInstanceGroup = mapper.readValue(
new File(RESOURCE_PATH + "InstanceGroup.json"), org.onap.so.db.catalog.beans.InstanceGroup.class);
- doReturn(expectedInstanceGroup).when(MOCK_catalogDbClient).getInstanceGroupByModelUUID(isA(String.class));
+ doReturn(expectedInstanceGroup).when(MOCK_catalogDbClient).getInstanceGroupByModelUUID(modelUUID);
- org.onap.so.db.catalog.beans.InstanceGroup actualInstanceGroup =
- bbInputSetupUtils.getCatalogInstanceGroup(modelUUID);
-
- assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
+ assertThat(bbInputSetupUtils.getCatalogInstanceGroup(modelUUID), sameBeanAs(expectedInstanceGroup));
}
@Test
- public void testGetCollectionResourceInstanceGroupCustomization() {
- String modelCustomizationUUID = "modelCustomizationUUID";
-
+ public void getCollectionResourceInstanceGroupCustomizationTest() {
+ final String modelCustomizationUUID = "modelCustomizationUUID";
CollectionResourceInstanceGroupCustomization expectedCollection =
new CollectionResourceInstanceGroupCustomization();
doReturn(Arrays.asList(expectedCollection)).when(MOCK_catalogDbClient)
.getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID);
- List<CollectionResourceInstanceGroupCustomization> actualCollection =
- bbInputSetupUtils.getCollectionResourceInstanceGroupCustomization(modelCustomizationUUID);
-
- assertThat(actualCollection, sameBeanAs(Arrays.asList(expectedCollection)));
+ assertThat(bbInputSetupUtils.getCollectionResourceInstanceGroupCustomization(modelCustomizationUUID),
+ sameBeanAs(Arrays.asList(expectedCollection)));
}
@Test
- public void testGetAAIGenericVnf() throws JsonParseException, JsonMappingException, IOException {
- String vnfId = "vnfId";
-
- GenericVnf expectedAaiVnf =
- mapper.readValue(new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), GenericVnf.class);
-
- doReturn(Optional.of(expectedAaiVnf)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
- isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE);
- GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
-
- assertThat(actualAaiVnf, sameBeanAs(expectedAaiVnf));
-
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.GenericVnf.class, expectedUri);
+ public void getAAIConfigurationNullTest() {
+ assertNull(bbInputSetupUtils.getAAIConfiguration(""));
}
@Test
- public void testGetAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
- String configurationId = "configurationId";
-
+ public void getAAIConfigurationTest() throws IOException {
+ final String configurationId = "configurationId";
Configuration expectedAaiConfiguration =
mapper.readValue(new File(RESOURCE_PATH + "ConfigurationInput.json"), Configuration.class);
doReturn(Optional.of(expectedAaiConfiguration)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
isA(AAIResourceUri.class));
- AAIResourceUri expectedUri =
- AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE);
- bbInputSetupUtils.getAAIConfiguration(configurationId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Configuration.class, expectedUri);
+ assertThat(bbInputSetupUtils.getAAIConfiguration(configurationId), sameBeanAs(expectedAaiConfiguration));
}
@Test
- public void testGetAAIGenericVnfThrowNotFound() throws JsonParseException, JsonMappingException, IOException {
- String vnfId = "vnfId";
+ public void getAAIGenericVnfNullTest() {
+ assertNull(bbInputSetupUtils.getAAIGenericVnf(""));
+ }
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+ @Test
+ public void getAAIGenericVnfTest() throws IOException {
+ final String vnfId = "vnfId";
+ GenericVnf expectedAaiVnf =
+ mapper.readValue(new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), GenericVnf.class);
- GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
+ doReturn(Optional.of(expectedAaiVnf)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)));
- assertNull(actualAaiVnf);
+ assertThat(bbInputSetupUtils.getAAIGenericVnf(vnfId), sameBeanAs(expectedAaiVnf));
}
@Test
- public void testGetAAIResourceDepthOne() {
- String vnfId = "vnfId";
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
+ public void getAAIResourceDepthOneTest() {
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "anyVnfId");
AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.ONE);
AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
+
bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri);
verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
@@ -612,11 +466,11 @@ public class BBInputSetupUtilsTest {
}
@Test
- public void testGetAAIResourceDepthTwo() {
- String vnfId = "vnfId";
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
+ public void getAAIResourceDepthTwoTest() {
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "anyVnfId");
AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.TWO);
AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
+
bbInputSetupUtils.getAAIResourceDepthTwo(aaiResourceUri);
verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
@@ -625,25 +479,33 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedNetworkByNameFromServiceInstanceTest() throws Exception {
+ final String networkId = "id123";
+ final String networkName = "name123";
+
Optional<L3Networks> expected = Optional.of(new L3Networks());
L3Network network = new L3Network();
- network.setNetworkId("id123");
- network.setNetworkName("name123");
+ network.setNetworkId(networkId);
+ network.setNetworkName(networkName);
expected.get().getL3Network().add(network);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
Optional<L3Network> actual =
- this.bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance("id123", "name123");
- assertEquals(actual.get().getNetworkId(), expected.get().getL3Network().get(0).getNetworkId());
+ bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(networkId, networkName);
+
+ assertTrue(actual.isPresent());
+ assertEquals(networkId, actual.get().getNetworkId());
+ assertEquals(networkName, actual.get().getNetworkName());
+ assertEquals(expected.get().getL3Network().get(0).getNetworkId(), actual.get().getNetworkId());
}
@Test
public void getRelatedNetworkByNameFromServiceInstanceMultipleNetworksExceptionTest() throws Exception {
+ final String serviceInstanceId = "serviceInstanceId";
+ final String networkName = "networkName";
expectedException.expect(MultipleObjectsFoundException.class);
- expectedException.expectMessage(containsString(
- "Multiple networks found for service-instance-id: serviceInstanceId and network-name: networkName."));
-
- String serviceInstanceId = "serviceInstanceId";
- String networkName = "networkName";
+ expectedException.expectMessage(
+ String.format("Multiple networks found for service-instance-id: %s and network-name: %s.",
+ serviceInstanceId, networkName));
L3Network network = new L3Network();
network.setNetworkId("id123");
@@ -661,15 +523,7 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedNetworkByNameFromServiceInstanceNotFoundTest() throws Exception {
- String serviceInstanceId = "serviceInstanceId";
- String networkName = "networkName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
-
- Optional<L3Network> actualNetwork =
- bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
-
- assertEquals(Optional.empty(), actualNetwork);
+ assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance("", ""));
}
@Test
@@ -682,13 +536,19 @@ public class BBInputSetupUtilsTest {
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
- assertEquals(actual.get().getServiceInstanceId(),
- expected.get().getServiceInstance().get(0).getServiceInstanceId());
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getServiceInstance().get(0).getServiceInstanceId(),
+ actual.get().getServiceInstanceId());
}
@Test
- public void getRelatedServiceInstanceFromInstanceGroupMultipleTest() throws Exception {
+ public void getRelatedServiceInstanceFromInstanceGroupMultipleExceptionTest() throws Exception {
+ final String instanceGroupId = "ig-001";
expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(
+ String.format("Mulitple service instances were found for instance-group-id: %s.", instanceGroupId));
+
Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
ServiceInstance si1 = Mockito.mock(ServiceInstance.class);
ServiceInstance si2 = Mockito.mock(ServiceInstance.class);
@@ -697,39 +557,46 @@ public class BBInputSetupUtilsTest {
doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class),
any(AAIResourceUri.class));
- this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
}
@Test
- public void getRelatedServiceInstanceFromInstanceGroupNotFoundTest() throws Exception {
+ public void getRelatedServiceInstanceFromInstanceGroupNotFoundExceptionTest() throws Exception {
expectedException.expect(NoServiceInstanceFoundException.class);
+ expectedException.expectMessage("No ServiceInstances Returned");
+
Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class),
any(AAIResourceUri.class));
- this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
}
@Test
public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception {
+ final String vnfId = "id123";
+ final String vnfName = "name123";
+
Optional<GenericVnfs> expected = Optional.of(new GenericVnfs());
GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("id123");
- vnf.setVnfName("name123");
+ vnf.setVnfId(vnfId);
+ vnf.setVnfName(vnfName);
expected.get().getGenericVnf().add(vnf);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
- Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance("id123", "name123");
- assertEquals(actual.get().getVnfId(), expected.get().getGenericVnf().get(0).getVnfId());
+ Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(vnfId, vnfName);
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getGenericVnf().get(0).getVnfId(), actual.get().getVnfId());
}
@Test
public void getRelatedVnfByNameFromServiceInstanceMultipleVnfsExceptionTest() throws Exception {
+ final String serviceInstanceId = "serviceInstanceId";
+ final String vnfName = "vnfName";
expectedException.expect(MultipleObjectsFoundException.class);
- expectedException.expectMessage(containsString(
- "Multiple vnfs found for service-instance-id: serviceInstanceId and vnf-name: vnfName."));
-
- String serviceInstanceId = "serviceInstanceId";
- String vnfName = "vnfName";
+ expectedException.expectMessage(String.format(
+ "Multiple vnfs found for service-instance-id: %s and vnf-name: %s.", serviceInstanceId, vnfName));
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("id123");
@@ -740,7 +607,6 @@ public class BBInputSetupUtilsTest {
vnfs.getGenericVnf().add(vnf);
Optional<GenericVnfs> optVnfs = Optional.of(vnfs);
-
doReturn(optVnfs).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
@@ -748,38 +614,38 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVnfByNameFromServiceInstanceNotFoundTest() throws Exception {
- String serviceInstanceId = "serviceInstanceId";
- String vnfName = "vnfName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
-
- Optional<GenericVnf> actualVnf =
- this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
+ final String serviceInstanceId = "serviceInstanceId";
+ final String vnfName = "vnfName";
- assertEquals(actualVnf, Optional.empty());
+ assertEquals(Optional.empty(),
+ bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName));
}
@Test
public void getRelatedVolumeGroupByNameFromVnfTest() throws Exception {
+ final String vnfId = "id123";
+ final String vnfName = "name123";
+
Optional<VolumeGroups> expected = Optional.of(new VolumeGroups());
VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
+ volumeGroup.setVolumeGroupId(vnfId);
+ volumeGroup.setVolumeGroupName(vnfName);
expected.get().getVolumeGroup().add(volumeGroup);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
- Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123");
- assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
+ Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, vnfName);
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId());
}
@Test
public void getRelatedVolumeGroupByNameFromVnfMultipleVolumeGroupsExceptionTest() throws Exception {
+ final String vnfId = "vnfId";
+ final String volumeGroupName = "volumeGroupName";
expectedException.expect(MultipleObjectsFoundException.class);
- expectedException.expectMessage(containsString(
- "Multiple volume-groups found for vnf-id: vnfId and volume-group-name: volumeGroupName."));
-
-
- String vnfId = "vnfId";
- String volumeGroupName = "volumeGroupName";
+ expectedException.expectMessage(String.format(
+ "Multiple volume-groups found for vnf-id: %s and volume-group-name: %s.", vnfId, volumeGroupName));
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("id123");
@@ -797,15 +663,7 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVolumeGroupByNameFromVnfNotFoundTest() throws Exception {
- String vnfId = "vnfId";
- String volumeGroupName = "volumeGroupName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- Optional<VolumeGroup> actualVolumeGroup =
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
-
- assertEquals(actualVolumeGroup, Optional.empty());
+ assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf("", ""));
}
@Test
@@ -815,18 +673,20 @@ public class BBInputSetupUtilsTest {
volumeGroup.setVolumeGroupId("id123");
volumeGroup.setVolumeGroupName("name123");
expected.get().getVolumeGroup().add(volumeGroup);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
Optional<VolumeGroup> actual =
this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "name123");
- assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId());
}
@Test
public void getRelatedVolumeGroupFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
expectedException.expect(Exception.class);
-
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
+ final String vnfId = "vnfId";
+ final String volumeGroupId = "volumeGroupId";
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("id123");
@@ -844,15 +704,10 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVolumeGroupFromVfModuleNotFoundTest() throws Exception {
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- Optional<VolumeGroup> actualVolumeGroup =
- bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId);
+ final String vnfId = "vnfId";
+ final String volumeGroupId = "volumeGroupId";
- assertEquals(actualVolumeGroup, Optional.empty());
+ assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, volumeGroupId));
}
@Test
@@ -861,19 +716,24 @@ public class BBInputSetupUtilsTest {
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("id123");
expected.get().getVolumeGroup().add(volumeGroup);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
- Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("id123", "id123");
- assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
+ Optional<VolumeGroup> actual = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("id123", "id123");
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getVolumeGroup().get(0).getVolumeGroupId(), actual.get().getVolumeGroupId());
}
@Test
public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
+ final String vnfId = "vnfId";
+ final String vfModuleId = "vfModuleId";
+ final String volumeGroupName = "volumeGroupName";
+
expectedException.expect(MultipleObjectsFoundException.class);
- expectedException.expectMessage(containsString(
- "Multiple voulme-groups found for vnf-id: vnfId, vf-module-id: volumeGroupId and volume-group-name: volumeGroupName."));
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
- String volumeGroupName = "volumeGroupName";
+ expectedException.expectMessage(String.format(
+ "Multiple voulme-groups found for vnf-id: %s, vf-module-id: %s and volume-group-name: %s.", vnfId,
+ vfModuleId, volumeGroupName));
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("id123");
@@ -884,54 +744,39 @@ public class BBInputSetupUtilsTest {
volumeGroups.getVolumeGroup().add(volumeGroup);
Optional<VolumeGroups> optVolumeGroups = Optional.of(volumeGroups);
-
doReturn(optVolumeGroups).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, vfModuleId, volumeGroupName);
}
@Test
public void getRelatedVolumeGroupByNameFromVfModuleNotFoundTest() throws Exception {
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
- String volumeGroupName = "volumeGroupName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- Optional<VolumeGroup> actualVolumeGroup =
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
-
- assertEquals(actualVolumeGroup, Optional.empty());
+ assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("", "", ""));
}
-
@Test
- public void loadOriginalFlowExecutionPathTest() throws Exception {
-
- String requestId = "123";
- String flowsToExecuteString =
- "[{\"buildingBlock\":{\"mso-id\":\"2f9ddc4b-4dcf-4129-a35f-be1625ae0176\",\"bpmn-flow-name\":\"DeactivateFabricConfigurationBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":{\"vfModuleCustomizationUUID\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"vnfResourceCustomizationUUID\":\"a80f05b8-d651-44af-b999-8ed78fb4582f\",\"cvnfcCustomizationUUID\":\"69cce457-9ffd-4359-962b-0596a1e83ad1\",\"vnfcName\":\"zauk51bmcmr01mcm001\"}},{\"buildingBlock\":{\"mso-id\":\"1ca5584e-38a9-4c3f-a4b4-99b0d42089ba\",\"bpmn-flow-name\":\"UnassignFabricConfigurationBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":{\"vfModuleCustomizationUUID\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"vnfResourceCustomizationUUID\":\"a80f05b8-d651-44af-b999-8ed78fb4582f\",\"cvnfcCustomizationUUID\":\"69cce457-9ffd-4359-962b-0596a1e83ad1\",\"vnfcName\":\"zauk51bmcmr01mcm001\"}},{\"buildingBlock\":{\"mso-id\":\"68d16097-4810-477d-803b-8322106106ef\",\"bpmn-flow-name\":\"DeactivateVfModuleBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":null},{\"buildingBlock\":{\"mso-id\":\"0b02eb09-bc23-4329-b19e-716dcca4e4a6\",\"bpmn-flow-name\":\"DeleteVfModuleBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":null},{\"buildingBlock\":{\"mso-id\":\"bcf95d05-0782-44ff-920d-d5100525c275\",\"bpmn-flow-name\":\"UnassignVfModuleBB\",\"key\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"is-virtual-link\":false,\"virtual-link-key\":null},\"requestId\":\"9c944122-d161-4280-8594-48c06a9d96d5\",\"apiVersion\":\"7\",\"resourceId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"requestAction\":\"deleteInstance\",\"vnfType\":\"\",\"aLaCarte\":true,\"homing\":false,\"workflowResourceIds\":{\"serviceInstanceId\":\"ff9dae72-05bb-4277-ad2b-1b082467c138\",\"vnfId\":\"84a29830-e533-4f20-a838-910c740bf24c\",\"networkId\":\"\",\"volumeGroupId\":\"\",\"vfModuleId\":\"d1d35800-783d-42d3-82f6-d654c5054a6e\",\"networkCollectionId\":null,\"configurationId\":\"10f8a3a3-91bf-4821-9515-c01b2864dff0\",\"instanceGroupId\":\"\"},\"requestDetails\":{\"modelInfo\":{\"modelCustomizationName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelInvariantId\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelType\":\"vfModule\",\"modelId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\",\"modelVersion\":\"1\",\"modelCustomizationUuid\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelVersionId\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelCustomizationId\":\"7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9\",\"modelUuid\":\"00d15ebb-c80e-43c1-80f0-90c40dde70b0\",\"modelInvariantUuid\":\"8028fcc0-96dc-427d-a4de-4536245943da\",\"modelInstanceName\":\"McmrNcUpVnf20191..cr_mccm_fc_base..module-0\"},\"requestInfo\":{\"source\":\"VID\",\"suppressRollback\":false,\"requestorId\":\"pj8646\"},\"cloudConfiguration\":{\"tenantId\":\"e2a6af59d1cb43b2874e943bbbf8470a\",\"cloudOwner\":\"att-nc\",\"lcpCloudRegionId\":\"auk51b\"},\"requestParameters\":{\"testApi\":\"GR_API\"}},\"configurationResourceKeys\":null}]";
- ObjectMapper om = new ObjectMapper();
- List<ExecuteBuildingBlock> expectedFlowsToExecute = null;
- try {
- ExecuteBuildingBlock[] asArray = om.readValue(flowsToExecuteString, ExecuteBuildingBlock[].class);
- expectedFlowsToExecute = Arrays.asList(asArray);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ public void loadOriginalFlowExecutionPathTest() throws IOException {
+ final String requestId = "123";
+ final String originalRequestId = "originalRequestId";
+ final String flowsToExecuteString = new String(
+ Files.readAllBytes(Paths.get(RESOURCE_PATH + "FlowsToExecute.json")), StandardCharsets.UTF_8);
InfraActiveRequests request = new InfraActiveRequests();
- request.setRequestId("requestId");
- request.setOriginalRequestId("originalRequestId");
- doReturn(request).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(anyString());
- RequestProcessingData rpd = new RequestProcessingData();
- rpd.setValue(flowsToExecuteString);
- doReturn(rpd).when(MOCK_requestsDbClient).getRequestProcessingDataBySoRequestIdAndName(anyString(),
- anyString());
+ ExecuteBuildingBlock[] expectedFlowsToExecute =
+ mapper.readValue(flowsToExecuteString, ExecuteBuildingBlock[].class);
+
+ request.setRequestId(requestId);
+ request.setOriginalRequestId(originalRequestId);
+ doReturn(request).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
+
+ RequestProcessingData requestProcessingData = new RequestProcessingData();
+ requestProcessingData.setValue(flowsToExecuteString);
+ doReturn(requestProcessingData).when(MOCK_requestsDbClient)
+ .getRequestProcessingDataBySoRequestIdAndName(anyString(), anyString());
List<ExecuteBuildingBlock> flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
- assertEquals(expectedFlowsToExecute.size(), flowsToExecute.size());
+
+ assertEquals(mapper.writeValueAsString(expectedFlowsToExecute), mapper.writeValueAsString(flowsToExecute));
}
@Test
@@ -954,11 +799,7 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedConfigurationByNameFromServiceInstanceNotFoundTest() throws Exception {
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(Configurations.class),
- any(AAIResourceUri.class));
- Optional<Configuration> actualConfiguration =
- bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123");
- assertEquals(actualConfiguration, Optional.empty());
+ assertEquals(Optional.empty(), bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("", ""));
}
@Test
@@ -967,40 +808,47 @@ public class BBInputSetupUtilsTest {
Configuration configuration = new Configuration();
configuration.setConfigurationId("id123");
expected.get().getConfiguration().add(configuration);
+
doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(Configurations.class), any(AAIResourceUri.class));
Optional<Configuration> actual =
this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123");
- assertEquals(actual.get().getConfigurationId(), expected.get().getConfiguration().get(0).getConfigurationId());
+
+ assertTrue(actual.isPresent());
+ assertEquals(expected.get().getConfiguration().get(0).getConfigurationId(), actual.get().getConfigurationId());
}
@Test
- public void existsAAIVfModuleGloballyByNameTest() throws Exception {
+ public void existsAAIVfModuleGloballyByNameTest() {
AAIResourceUri expectedUri =
AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", "testVfModule");
bbInputSetupUtils.existsAAIVfModuleGloballyByName("testVfModule");
+
verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri);
}
@Test
- public void existsAAIConfigurationGloballyByNameTest() throws Exception {
+ public void existsAAIConfigurationGloballyByNameTest() {
AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION)
.queryParam("configuration-name", "testConfig");
bbInputSetupUtils.existsAAIConfigurationGloballyByName("testConfig");
+
verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri);
}
@Test
- public void existsAAINetworksGloballyByNameTest() throws Exception {
+ public void existsAAINetworksGloballyByNameTest() {
AAIResourceUri expectedUri =
AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "testNetwork");
bbInputSetupUtils.existsAAINetworksGloballyByName("testNetwork");
+
verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri);
}
@Test
- public void existsAAIVolumeGroupGloballyByNameTest() throws Exception {
+ public void existsAAIVolumeGroupGloballyByNameTest() {
AAIResourceUri expectedUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP)
.queryParam("volume-group-name", "testVoumeGroup");
+
bbInputSetupUtils.existsAAIVolumeGroupGloballyByName("testVoumeGroup");
verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri);
}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/FlowsToExecute.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/FlowsToExecute.json
new file mode 100644
index 0000000000..fa271b9e8d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/FlowsToExecute.json
@@ -0,0 +1,292 @@
+[
+ {
+ "buildingBlock": {
+ "mso-id": "2f9ddc4b-4dcf-4129-a35f-be1625ae0176",
+ "bpmn-flow-name": "DeactivateFabricConfigurationBB",
+ "key": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "is-virtual-link": false,
+ "virtual-link-key": null
+ },
+ "requestId": "9c944122-d161-4280-8594-48c06a9d96d5",
+ "apiVersion": "7",
+ "resourceId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "requestAction": "deleteInstance",
+ "vnfType": "",
+ "aLaCarte": true,
+ "homing": false,
+ "workflowResourceIds": {
+ "serviceInstanceId": "ff9dae72-05bb-4277-ad2b-1b082467c138",
+ "vnfId": "84a29830-e533-4f20-a838-910c740bf24c",
+ "networkId": "",
+ "volumeGroupId": "",
+ "vfModuleId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "networkCollectionId": null,
+ "configurationId": "10f8a3a3-91bf-4821-9515-c01b2864dff0",
+ "instanceGroupId": ""
+ },
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelInvariantId": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelType": "vfModule",
+ "modelId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelVersionId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelCustomizationId": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelUuid": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelInvariantUuid": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelInstanceName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ },
+ "configurationResourceKeys": {
+ "vfModuleCustomizationUUID": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "vnfResourceCustomizationUUID": "a80f05b8-d651-44af-b999-8ed78fb4582f",
+ "cvnfcCustomizationUUID": "69cce457-9ffd-4359-962b-0596a1e83ad1",
+ "vnfcName": "zauk51bmcmr01mcm001"
+ }
+ },
+ {
+ "buildingBlock": {
+ "mso-id": "1ca5584e-38a9-4c3f-a4b4-99b0d42089ba",
+ "bpmn-flow-name": "UnassignFabricConfigurationBB",
+ "key": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "is-virtual-link": false,
+ "virtual-link-key": null
+ },
+ "requestId": "9c944122-d161-4280-8594-48c06a9d96d5",
+ "apiVersion": "7",
+ "resourceId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "requestAction": "deleteInstance",
+ "vnfType": "",
+ "aLaCarte": true,
+ "homing": false,
+ "workflowResourceIds": {
+ "serviceInstanceId": "ff9dae72-05bb-4277-ad2b-1b082467c138",
+ "vnfId": "84a29830-e533-4f20-a838-910c740bf24c",
+ "networkId": "",
+ "volumeGroupId": "",
+ "vfModuleId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "networkCollectionId": null,
+ "configurationId": "10f8a3a3-91bf-4821-9515-c01b2864dff0",
+ "instanceGroupId": ""
+ },
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelInvariantId": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelType": "vfModule",
+ "modelId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelVersionId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelCustomizationId": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelUuid": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelInvariantUuid": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelInstanceName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ },
+ "configurationResourceKeys": {
+ "vfModuleCustomizationUUID": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "vnfResourceCustomizationUUID": "a80f05b8-d651-44af-b999-8ed78fb4582f",
+ "cvnfcCustomizationUUID": "69cce457-9ffd-4359-962b-0596a1e83ad1",
+ "vnfcName": "zauk51bmcmr01mcm001"
+ }
+ },
+ {
+ "buildingBlock": {
+ "mso-id": "68d16097-4810-477d-803b-8322106106ef",
+ "bpmn-flow-name": "DeactivateVfModuleBB",
+ "key": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "is-virtual-link": false,
+ "virtual-link-key": null
+ },
+ "requestId": "9c944122-d161-4280-8594-48c06a9d96d5",
+ "apiVersion": "7",
+ "resourceId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "requestAction": "deleteInstance",
+ "vnfType": "",
+ "aLaCarte": true,
+ "homing": false,
+ "workflowResourceIds": {
+ "serviceInstanceId": "ff9dae72-05bb-4277-ad2b-1b082467c138",
+ "vnfId": "84a29830-e533-4f20-a838-910c740bf24c",
+ "networkId": "",
+ "volumeGroupId": "",
+ "vfModuleId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "networkCollectionId": null,
+ "configurationId": "10f8a3a3-91bf-4821-9515-c01b2864dff0",
+ "instanceGroupId": ""
+ },
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelInvariantId": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelType": "vfModule",
+ "modelId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelVersionId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelCustomizationId": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelUuid": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelInvariantUuid": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelInstanceName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ },
+ "configurationResourceKeys": null
+ },
+ {
+ "buildingBlock": {
+ "mso-id": "0b02eb09-bc23-4329-b19e-716dcca4e4a6",
+ "bpmn-flow-name": "DeleteVfModuleBB",
+ "key": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "is-virtual-link": false,
+ "virtual-link-key": null
+ },
+ "requestId": "9c944122-d161-4280-8594-48c06a9d96d5",
+ "apiVersion": "7",
+ "resourceId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "requestAction": "deleteInstance",
+ "vnfType": "",
+ "aLaCarte": true,
+ "homing": false,
+ "workflowResourceIds": {
+ "serviceInstanceId": "ff9dae72-05bb-4277-ad2b-1b082467c138",
+ "vnfId": "84a29830-e533-4f20-a838-910c740bf24c",
+ "networkId": "",
+ "volumeGroupId": "",
+ "vfModuleId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "networkCollectionId": null,
+ "configurationId": "10f8a3a3-91bf-4821-9515-c01b2864dff0",
+ "instanceGroupId": ""
+ },
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelInvariantId": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelType": "vfModule",
+ "modelId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelVersionId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelCustomizationId": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelUuid": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelInvariantUuid": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelInstanceName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ },
+ "configurationResourceKeys": null
+ },
+ {
+ "buildingBlock": {
+ "mso-id": "bcf95d05-0782-44ff-920d-d5100525c275",
+ "bpmn-flow-name": "UnassignVfModuleBB",
+ "key": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "is-virtual-link": false,
+ "virtual-link-key": null
+ },
+ "requestId": "9c944122-d161-4280-8594-48c06a9d96d5",
+ "apiVersion": "7",
+ "resourceId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "requestAction": "deleteInstance",
+ "vnfType": "",
+ "aLaCarte": true,
+ "homing": false,
+ "workflowResourceIds": {
+ "serviceInstanceId": "ff9dae72-05bb-4277-ad2b-1b082467c138",
+ "vnfId": "84a29830-e533-4f20-a838-910c740bf24c",
+ "networkId": "",
+ "volumeGroupId": "",
+ "vfModuleId": "d1d35800-783d-42d3-82f6-d654c5054a6e",
+ "networkCollectionId": null,
+ "configurationId": "10f8a3a3-91bf-4821-9515-c01b2864dff0",
+ "instanceGroupId": ""
+ },
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelInvariantId": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelType": "vfModule",
+ "modelId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelVersionId": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelCustomizationId": "7adc7c29-21a3-40a2-b8b6-5d4ad08b68e9",
+ "modelUuid": "00d15ebb-c80e-43c1-80f0-90c40dde70b0",
+ "modelInvariantUuid": "8028fcc0-96dc-427d-a4de-4536245943da",
+ "modelInstanceName": "McmrNcUpVnf20191..cr_mccm_fc_base..module-0"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "pj8646"
+ },
+ "cloudConfiguration": {
+ "tenantId": "e2a6af59d1cb43b2874e943bbbf8470a",
+ "cloudOwner": "att-nc",
+ "lcpCloudRegionId": "auk51b"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ },
+ "configurationResourceKeys": null
+ }
+] \ No newline at end of file
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
index c8600586ce..1b4470b545 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
@@ -1,34 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:collaboration id="Collaboration_0go8wi3">
<bpmn:participant id="Participant_1dwc5st" name="SO&#10;Assign PNF" processRef="AssignPnfBB" />
<bpmn:participant id="Participant_0gycee4" name="AAI" />
<bpmn:messageFlow id="MessageFlow_0xh6bkn" sourceRef="CreatePnfEntryInAai" targetRef="Participant_0gycee4" />
</bpmn:collaboration>
<bpmn:process id="AssignPnfBB" name="AssignPnfBB" isExecutable="true">
- <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" />
<bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CreatePnfEntryInAai" />
- <bpmn:endEvent id="AaiEntryExists" name="AAI entry exists">
- <bpmn:incoming>SequenceFlow_0l6rtzy</bpmn:incoming>
- </bpmn:endEvent>
<bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:expression="${AAICreateTasks.createPnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0yrabnf</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:startEvent id="AssignPnf_StartEvent">
<bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing>
</bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0yrabnf" sourceRef="CreatePnfEntryInAai" targetRef="Task_UpdatePnfOrchestrationStatusAssigned" />
+ <bpmn:sequenceFlow id="SequenceFlow_1yb16sd" sourceRef="Task_UpdatePnfOrchestrationStatusAssigned" targetRef="AaiEntryExists" />
+ <bpmn:serviceTask id="Task_UpdatePnfOrchestrationStatusAssigned" name="Update Pnf Orchestration Status to Assigned" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedPnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0yrabnf</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1yb16sd</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="AaiEntryExists" name="AAI entry exists">
+ <bpmn:incoming>SequenceFlow_1yb16sd</bpmn:incoming>
+ </bpmn:endEvent>
<bpmn:association id="Association_1le3nwi" sourceRef="AssignPnf_StartEvent" targetRef="TextAnnotation_184cxp4" />
<bpmn:textAnnotation id="TextAnnotation_184cxp4">
<bpmn:text>Inputs:
- - pnfName - String
-</bpmn:text>
+ - pnfName - String</bpmn:text>
</bpmn:textAnnotation>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0go8wi3">
<bpmndi:BPMNShape id="Participant_1dwc5st_di" bpmnElement="Participant_1dwc5st" isHorizontal="true">
- <dc:Bounds x="160" y="80" width="646" height="391" />
+ <dc:Bounds x="160" y="80" width="738" height="391" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0gycee4_di" bpmnElement="Participant_0gycee4" isHorizontal="true">
<dc:Bounds x="260" y="567" width="502" height="60" />
@@ -51,19 +55,26 @@
<di:waypoint x="237" y="203" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1wfgsdz_di" bpmnElement="AaiEntryExists">
- <dc:Bounds x="722" y="269" width="36" height="36" />
+ <dc:Bounds x="772" y="269" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="703" y="312" width="77" height="14" />
+ <dc:Bounds x="753" y="312" width="77" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0l6rtzy_di" bpmnElement="SequenceFlow_0l6rtzy">
- <di:waypoint x="561" y="287" />
- <di:waypoint x="722" y="287" />
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x">
<di:waypoint x="255" y="287" />
<di:waypoint x="461" y="287" />
</bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0yrabnf_di" bpmnElement="SequenceFlow_0yrabnf">
+ <di:waypoint x="561" y="287" />
+ <di:waypoint x="620" y="287" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1kmas9h_di" bpmnElement="Task_UpdatePnfOrchestrationStatusAssigned">
+ <dc:Bounds x="620" y="247" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1yb16sd_di" bpmnElement="SequenceFlow_1yb16sd">
+ <di:waypoint x="720" y="287" />
+ <di:waypoint x="772" y="287" />
+ </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn
index b38ec69ba5..29e2f2bf11 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn
@@ -8,20 +8,26 @@
<bpmn:messageFlow id="MessageFlow_1py54jr" sourceRef="UnregisterfromPnfReadyEvent" targetRef="WorkflowMessageServiceForDmaap" />
</bpmn:collaboration>
<bpmn:process id="WaitForPnfReadyBB" name="WaitForPnfReadyBB" isExecutable="true">
- <bpmn:startEvent id="WaitForPnfReady_StartEvent">
- <bpmn:outgoing>SequenceFlow_1jzs6dp</bpmn:outgoing>
- </bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_17q5zqe" sourceRef="UpdatePnfOrchestrationStatusToRegistered" targetRef="AaiEntryUpdated" />
+ <bpmn:sequenceFlow id="SequenceFlow_0m2r6ye" sourceRef="UpdatePnfOrchestrationStatusToRegister" targetRef="WaitForDmaapPnfReadyNotification" />
+ <bpmn:sequenceFlow id="SequenceFlow_1miyzfe" sourceRef="UnregisterfromPnfReadyEvent" targetRef="ThrowTimeoutException" />
+ <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="UpdatePnfOrchestrationStatusToRegistered" />
+ <bpmn:sequenceFlow id="SequenceFlow_1o8od8e" sourceRef="RegisterForPnfReadyEvent" targetRef="UpdatePnfOrchestrationStatusToRegister" />
+ <bpmn:sequenceFlow id="SequenceFlow_1kc34bc" sourceRef="WaitForDmaapTimeout" targetRef="UnregisterfromPnfReadyEvent" />
+ <bpmn:sequenceFlow id="SequenceFlow_1jzs6dp" sourceRef="WaitForPnfReady_StartEvent" targetRef="RegisterForPnfReadyEvent" />
<bpmn:serviceTask id="RegisterForPnfReadyEvent" name="Register for Pnf Ready Event" camunda:delegateExpression="${RegisterForPnfReadyEvent}">
<bpmn:incoming>SequenceFlow_1jzs6dp</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1o8od8e</bpmn:outgoing>
</bpmn:serviceTask>
- <bpmn:sequenceFlow id="SequenceFlow_1miyzfe" sourceRef="UnregisterfromPnfReadyEvent" targetRef="ThrowTimeoutException" />
- <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" />
- <bpmn:sequenceFlow id="SequenceFlow_1o8od8e" sourceRef="RegisterForPnfReadyEvent" targetRef="WaitForDmaapPnfReadyNotification" />
- <bpmn:sequenceFlow id="SequenceFlow_1kc34bc" sourceRef="WaitForDmaapTimeout" targetRef="UnregisterfromPnfReadyEvent" />
- <bpmn:sequenceFlow id="SequenceFlow_1jzs6dp" sourceRef="WaitForPnfReady_StartEvent" targetRef="RegisterForPnfReadyEvent" />
- <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo">
+ <bpmn:startEvent id="WaitForPnfReady_StartEvent">
+ <bpmn:outgoing>SequenceFlow_1jzs6dp</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="UpdatePnfOrchestrationStatusToRegister" name="Update Pnf Orchestration Status to Register" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusRegisterPnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_1o8od8e</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0m2r6ye</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo">
+ <bpmn:incoming>SequenceFlow_0m2r6ye</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing>
</bpmn:receiveTask>
<bpmn:boundaryEvent id="WaitForDmaapTimeout" name="Timeout" attachedToRef="WaitForDmaapPnfReadyNotification">
@@ -30,17 +36,21 @@
<bpmn:timeDuration xsi:type="bpmn:tFormalExpression">#{timeoutForPnfEntryNotification}</bpmn:timeDuration>
</bpmn:timerEventDefinition>
</bpmn:boundaryEvent>
+ <bpmn:serviceTask id="UpdatePnfOrchestrationStatusToRegistered" name="Update Pnf Orchestration Status to Registered" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusRegisteredPnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_17q5zqe</bpmn:outgoing>
+ </bpmn:serviceTask>
<bpmn:serviceTask id="UnregisterfromPnfReadyEvent" name="Unregister from Pnf Ready Event" camunda:delegateExpression="${CancelDmaapSubscription}">
<bpmn:incoming>SequenceFlow_1kc34bc</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1miyzfe</bpmn:outgoing>
</bpmn:serviceTask>
+ <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated">
+ <bpmn:incoming>SequenceFlow_17q5zqe</bpmn:incoming>
+ </bpmn:endEvent>
<bpmn:endEvent id="ThrowTimeoutException" name="Throw timeout exception">
<bpmn:incoming>SequenceFlow_1miyzfe</bpmn:incoming>
<bpmn:errorEventDefinition errorRef="Error_1" />
</bpmn:endEvent>
- <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated">
- <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming>
- </bpmn:endEvent>
<bpmn:textAnnotation id="TextAnnotation_1eyzes8">
<bpmn:text>Inputs:
- pnf name - String</bpmn:text>
@@ -52,12 +62,12 @@
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1d0w8lf">
<bpmndi:BPMNShape id="Participant_1egg397_di" bpmnElement="WaitForPnfReadyBB_ID" isHorizontal="true">
- <dc:Bounds x="160" y="50" width="810" height="400" />
+ <dc:Bounds x="160" y="50" width="1040" height="400" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated">
- <dc:Bounds x="882" y="189" width="36" height="36" />
+ <dc:Bounds x="1112" y="189" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="858" y="230" width="88" height="14" />
+ <dc:Bounds x="1088" y="230" width="88" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="WaitForPnfReady_StartEvent">
@@ -67,12 +77,12 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0vmrrhf_di" bpmnElement="WorkflowMessageServiceForDmaap" isHorizontal="true">
- <dc:Bounds x="340" y="490" width="463" height="60" />
+ <dc:Bounds x="340" y="490" width="690" height="60" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0wbx6tt_di" bpmnElement="ThrowTimeoutException">
- <dc:Bounds x="882" y="322" width="36" height="36" />
+ <dc:Bounds x="1112" y="322" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="875" y="359" width="70" height="27" />
+ <dc:Bounds x="1105" y="359" width="70" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1eyzes8_di" bpmnElement="TextAnnotation_1eyzes8">
@@ -83,32 +93,32 @@
<di:waypoint x="237" y="109" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d">
- <di:waypoint x="582" y="490" />
- <di:waypoint x="582" y="247" />
+ <di:waypoint x="772" y="490" />
+ <di:waypoint x="772" y="247" />
<bpmndi:BPMNLabel>
<dc:Bounds x="996" y="380" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="BoundaryEvent_15eo1k9_di" bpmnElement="WaitForDmaapTimeout">
- <dc:Bounds x="596" y="229" width="36" height="36" />
+ <dc:Bounds x="786" y="229" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="639" y="240" width="40" height="14" />
+ <dc:Bounds x="829" y="240" width="40" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc">
- <di:waypoint x="614" y="265" />
- <di:waypoint x="614" y="340" />
- <di:waypoint x="710" y="340" />
+ <di:waypoint x="804" y="265" />
+ <di:waypoint x="804" y="340" />
+ <di:waypoint x="910" y="340" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1028" y="309" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ReceiveTask_1sfysua_di" bpmnElement="WaitForDmaapPnfReadyNotification">
- <dc:Bounds x="530" y="167" width="100" height="80" />
+ <dc:Bounds x="720" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm">
- <di:waypoint x="630" y="207" />
- <di:waypoint x="882" y="207" />
+ <di:waypoint x="820" y="207" />
+ <di:waypoint x="910" y="207" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1106.5" y="187" width="90" height="10" />
</bpmndi:BPMNLabel>
@@ -131,26 +141,40 @@
<dc:Bounds x="340" y="167" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1miyzfe_di" bpmnElement="SequenceFlow_1miyzfe">
- <di:waypoint x="810" y="340" />
- <di:waypoint x="882" y="340" />
+ <di:waypoint x="1010" y="340" />
+ <di:waypoint x="1112" y="340" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1233.5" y="343" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_1py54jr_di" bpmnElement="MessageFlow_1py54jr">
- <di:waypoint x="760" y="380" />
- <di:waypoint x="760" y="490" />
+ <di:waypoint x="960" y="380" />
+ <di:waypoint x="960" y="490" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1165" y="458" width="90" height="10" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_12j7hox_di" bpmnElement="UnregisterfromPnfReadyEvent">
- <dc:Bounds x="710" y="300" width="100" height="80" />
+ <dc:Bounds x="910" y="300" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1jzs6dp_di" bpmnElement="SequenceFlow_1jzs6dp">
<di:waypoint x="255" y="207" />
<di:waypoint x="340" y="207" />
</bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1kiymc9_di" bpmnElement="UpdatePnfOrchestrationStatusToRegister">
+ <dc:Bounds x="530" y="167" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0m2r6ye_di" bpmnElement="SequenceFlow_0m2r6ye">
+ <di:waypoint x="630" y="207" />
+ <di:waypoint x="720" y="207" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_17q5zqe_di" bpmnElement="SequenceFlow_17q5zqe">
+ <di:waypoint x="1010" y="207" />
+ <di:waypoint x="1112" y="207" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1e3i8pf_di" bpmnElement="UpdatePnfOrchestrationStatusToRegistered">
+ <dc:Bounds x="910" y="167" width="100" height="80" />
+ </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
index f1fbe545ce..4d5494d18c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
@@ -118,6 +118,14 @@ public class AAIUpdateTasks {
}
}
+ /**
+ * BPMN access method to update status of Pnf to Assigned in AAI
+ *
+ * @param execution
+ */
+ public void updateOrchestrationStatusAssignedPnf(BuildingBlockExecution execution) {
+ updateOrchestrationStatusForPnf(execution, OrchestrationStatus.ASSIGNED);
+ }
/**
* BPMN access method to update status of Pnf to Active in AAI
@@ -125,11 +133,29 @@ public class AAIUpdateTasks {
* @param execution
*/
public void updateOrchestrationStatusActivePnf(BuildingBlockExecution execution) {
+ updateOrchestrationStatusForPnf(execution, OrchestrationStatus.ACTIVE);
+ }
+
+ /**
+ * BPMN access method to update status of Pnf to Register in AAI
+ */
+ public void updateOrchestrationStatusRegisterPnf(BuildingBlockExecution execution) {
+ updateOrchestrationStatusForPnf(execution, OrchestrationStatus.REGISTER);
+ }
+
+ /**
+ * BPMN access method to update status of Pnf to Registered in AAI
+ */
+ public void updateOrchestrationStatusRegisteredPnf(BuildingBlockExecution execution) {
+ updateOrchestrationStatusForPnf(execution, OrchestrationStatus.REGISTERED);
+ }
+
+ private void updateOrchestrationStatusForPnf(BuildingBlockExecution execution, OrchestrationStatus status) {
try {
Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF);
- aaiPnfResources.updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE);
+ aaiPnfResources.updateOrchestrationStatusPnf(pnf, status);
} catch (Exception ex) {
- logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActivePnf", ex);
+ logger.error("Exception occurred in AAIUpdateTasks during update Orchestration Status to {}", status, ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index ae6dde6521..e26009a1de 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -139,6 +139,25 @@ public class AAIUpdateTasksTest extends BaseTaskTest {
aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
}
+ @Test
+ public void updateOrchestrationStatusAssignedPnfTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedPnf(execution);
+
+ verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedPnfExceptionTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf,
+ OrchestrationStatus.ASSIGNED);
+
+ expectedException.expect(BpmnError.class);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedPnf(execution);
+ }
@Test
public void updateOrchestrationStatusActivePnfTest() throws Exception {
@@ -161,6 +180,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest {
}
@Test
+ public void updateOrchestrationStatusRegisterPnfTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTER);
+
+ aaiUpdateTasks.updateOrchestrationStatusRegisterPnf(execution);
+
+ verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTER);
+ }
+
+ @Test
+ public void updateOrchestrationStatusRegisteredPnfTest() throws Exception {
+ Pnf pnf = preparePnfAndExtractForPnf();
+ doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTERED);
+
+ aaiUpdateTasks.updateOrchestrationStatusRegisteredPnf(execution);
+
+ verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTERED);
+ }
+
+ @Test
public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
diff --git a/common/pom.xml b/common/pom.xml
index 3f029bcb96..529841da72 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -59,7 +59,7 @@
<dependency>
<groupId>org.onap.aai.schema-service</groupId>
<artifactId>aai-schema</artifactId>
- <version>1.6.2-SNAPSHOT</version>
+ <version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
diff --git a/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java b/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java
index c778dde9af..21176e0d5d 100644
--- a/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java
+++ b/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java
@@ -28,6 +28,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.firewall.StrictHttpFirewall;
import org.springframework.util.StringUtils;
@@ -44,6 +46,12 @@ public class SoBasicWebSecurityConfigurerAdapter extends WebSecurityConfigurerAd
@Autowired
private SoUserCredentialConfiguration soUserCredentialConfiguration;
+ @Autowired
+ private UserDetailsService userDetailsService;
+
+ @Autowired
+ private BCryptPasswordEncoder passwordEncoder;
+
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
@@ -61,8 +69,6 @@ public class SoBasicWebSecurityConfigurerAdapter extends WebSecurityConfigurerAd
@Override
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(soUserCredentialConfiguration.userDetailsService())
- .passwordEncoder(soUserCredentialConfiguration.passwordEncoder());
+ auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);
}
-
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
index 483ac47235..3104c8415f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.filters.ResponseUpdater;
import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -71,14 +76,15 @@ public class Network {
public Response deleteNetworkInstance(@PathParam("version") String version,
@PathParam("serviceInstanceId") String serviceInstanceId,
@PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext)
- throws Exception {
- InfraActiveRequests currentRequest = null;
+ throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+ ValidateException {
+
String requestId = networkRestHandler.getRequestId(requestContext);
String requestorId = "Unknown";
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
- currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId,
- networkInstanceId, requestorId, source, requestURI);
+ InfraActiveRequests currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId,
+ serviceInstanceId, networkInstanceId, requestorId, source, requestURI);
ServiceInstancesRequest request = requestBuilder.buildNetworkDeleteRequest(networkInstanceId);
networkRestHandler.saveInstanceName(request, currentRequest);
networkRestHandler.checkDuplicateRequest(serviceInstanceId, networkInstanceId,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
index 135667d3e4..7aaf470e18 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.filters.ResponseUpdater;
import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -70,14 +75,15 @@ public class ServiceInstance {
@Transactional
public Response deleteServiceInstance(@PathParam("version") String version,
@PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext)
- throws Exception {
- InfraActiveRequests currentRequest = null;
+ throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+ ValidateException {
+
String requestId = requestHandler.getRequestId(requestContext);
String requestorId = "Unknown";
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
- currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, requestorId,
- source, requestURI);
+ InfraActiveRequests currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId,
+ serviceInstanceId, requestorId, source, requestURI);
ServiceInstancesRequest request = requestBuilder.buildServiceDeleteRequest(serviceInstanceId);
requestHandler.saveInstanceName(request, currentRequest);
requestHandler.checkDuplicateRequest(serviceInstanceId,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
index 4a86d944cf..ddbced98a4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
@@ -9,9 +9,9 @@
* 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.
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.filters.ResponseUpdater;
import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -72,15 +77,15 @@ public class VfModules {
public Response deleteVfModuleInstance(@PathParam("version") String version,
@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext)
- throws Exception {
- InfraActiveRequests currentRequest = null;
+ throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+ ValidateException {
String requestId = restHandler.getRequestId(requestContext);
String requestorId = "Unknown";
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
- currentRequest = restHandler.createInfraActiveRequestForDelete(requestId, vfmoduleInstanceId, serviceInstanceId,
- vnfInstanceId, requestorId, source, requestURL);
+ InfraActiveRequests currentRequest = restHandler.createInfraActiveRequestForDelete(requestId,
+ vfmoduleInstanceId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request =
requestBuilder.buildVFModuleDeleteRequest(vnfInstanceId, vfmoduleInstanceId, ModelType.vfModule);
restHandler.saveInstanceName(request, currentRequest);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
index edb09083d4..68e6eb5858 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
@@ -32,8 +32,12 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -69,14 +73,15 @@ public class Vnf {
@Transactional
public Response deleteVnfInstance(@PathParam("version") String version,
@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
- @Context ContainerRequestContext requestContext) throws Exception {
- InfraActiveRequests currentRequest = null;
+ @Context ContainerRequestContext requestContext)
+ throws AAIEntityNotFound, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
+
String requestId = vnfRestHandler.getRequestId(requestContext);
String requestorId = "Unknown";
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
- currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfInstanceId,
- requestorId, source, requestURL);
+ InfraActiveRequests currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId,
+ serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request = requestBuilder.buildVnfDeleteRequest(vnfInstanceId);
vnfRestHandler.saveInstanceName(request, currentRequest);
vnfRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
index 3154c86046..b842580b3f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.filters.ResponseUpdater;
import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler;
import org.onap.so.db.catalog.beans.Recipe;
@@ -76,14 +81,15 @@ public class Volumes {
public Response deleteVfModuleInstance(@PathParam("version") String version,
@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
@PathParam("volumeGroupInstanceId") String volumeGroupId, @Context ContainerRequestContext requestContext)
- throws Exception {
- InfraActiveRequests currentRequest = null;
+ throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+ ValidateException {
+
String requestId = volumeRestHandler.getRequestId(requestContext);
String requestorId = "Unknown";
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
- currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId, volumeGroupId,
- serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
+ InfraActiveRequests currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId,
+ volumeGroupId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request = requestBuilder.buildVolumeGroupDeleteRequest(vnfInstanceId, volumeGroupId);
volumeRestHandler.saveInstanceName(request, currentRequest);
volumeRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, volumeGroupId,
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
index 9691eff5f5..435c3a71ab 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatus.java
@@ -33,7 +33,9 @@ public enum OrchestrationStatus {
PRECREATED("PreCreated", "pre.?created"),
CONFIGASSIGNED("ConfigAssigned", "config.?assigned"),
CONFIGURE("Configure", "configure"),
- CONFIGURED("Configured", "configured");
+ CONFIGURED("Configured", "configured"),
+ REGISTER("Register", "register"),
+ REGISTERED("Registered", "registered");
private final String name;
private final String fuzzyMatcher;