summaryrefslogtreecommitdiffstats
path: root/artifactbroker/plugins/reception-plugins
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2019-04-03 02:26:05 +0800
committerliboNet <libo.zhu@intel.com>2019-04-03 02:26:05 +0800
commit41373a9619308bdbab6a31c02fe3d54e91ac6ee3 (patch)
tree4e79dc6d6573e9fab2415294e5e926589b0f9827 /artifactbroker/plugins/reception-plugins
parentb852967aa9ebbf7a37e562e562c21b9df76f04d7 (diff)
add subplugin field support and new Cloud Artifact class
. add subplugin field to integrate with Distribution framework . add new Cloud Artifact which is to be used by subplugin like k8s . update test .json file to include reception and forward fields . add dummy test class to ensure the flow works as expected . fix typos Change-Id: I9d69d88e448a18247e19b3b7a6062b20814b5f8c Issue-ID: MULTICLOUD-512 Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'artifactbroker/plugins/reception-plugins')
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java12
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java34
2 files changed, 10 insertions, 36 deletions
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
index fc2211b..998527b 100644
--- a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
@@ -36,7 +36,7 @@ import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.CloudArtifact;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.model.GsonUtil;
-import org.onap.policy.distribution.model.VfModuelModel;
+import org.onap.policy.distribution.model.VfModuleModel;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.handling.sdc.SdcClientHandler.SdcClientOperationType;
@@ -220,13 +220,11 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
DistributionStatisticsManager.updateTotalDistributionCount();
List<String> relevantArtifactTypes = sdcConfig.getRelevantArtifactTypes();
Path path = Paths.get("/data");
- List<VfModuelModel> vfModuelModels = null;
- Map<String, String> artifactTypeMap = null; //key is UUID, value is type for k8s plugin
+ List<VfModuleModel> vfModuleModels = null;
Map<String, IArtifactInfo> artifactMap = null;//key is UUID, value is artifact for shared folder
String vfArtifactData = null;
for (final IArtifactInfo artifact : resource.getArtifacts()) {
- artifactTypeMap.put(artifact.getArtifactUUID(),artifact.getArtifactType());
artifactMap.put(artifact.getArtifactUUID(),artifact);
//extract the artifactlist and write them into MongoDB
@@ -235,7 +233,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
final IDistributionClientDownloadResult resultArtifact =
downloadTheArtifact(artifact,notificationData);
vfArtifactData = new String(resultArtifact.getArtifactPayload());
- vfModuelModels= GsonUtil.parseJsonArrayWithGson(vfArtifactData,VfModuelModel.class);
+ vfModuleModels= GsonUtil.parseJsonArrayWithGson(vfArtifactData,VfModuleModel.class);
} catch (final ArtifactDownloadException exp) {
LOGGER.error("Failed to process csar service artifacts ", exp);
artifactsProcessedSuccessfully = false;
@@ -251,7 +249,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
// 2. put the vfmodule-meta.json into it
// 3. put the service-meta.json into it
// 3. go through each aritfact uuid under artifact_list of vf_module and download
- for (final VfModuelModel vfModule : vfModuelModels) {
+ for (final VfModuleModel vfModule : vfModuleModels) {
try {
//create the new dir
Path temp = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID());
@@ -283,7 +281,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
//for subplug work
try {
- final CloudArtifact cloudArtifact = new CloudArtifact(vfModuelModels, artifactTypeMap);
+ final CloudArtifact cloudArtifact = new CloudArtifact(vfModuleModels, artifactMap);
inputReceived(cloudArtifact);
} catch ( final PolicyDecodingException exp) {
LOGGER.error("Failed to process cloud artifacts ", exp);
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java
index 445d47c..e3bafc5 100644
--- a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java
@@ -18,14 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.distribution.reception.handling.sdc;
+package org.onap.policy.distribution.main.testclasses;
import java.util.ArrayList;
import java.util.Collection;
-
import org.onap.policy.distribution.forwarding.ArtifactForwarder;
import org.onap.policy.distribution.forwarding.ArtifactForwardingException;
-import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.policy.distribution.model.PolicyInput;
/**
* Class to create a dummy forwarder for test cases.
@@ -34,39 +33,16 @@ import org.onap.sdc.api.notification.IArtifactInfo;
*/
public class DummyArtifactForwarder implements ArtifactForwarder {
private int numberOfPoliciesReceived = 0;
- private Collection<IArtifactInfo> policiesReceived = new ArrayList<>();
- /**
- * {@inheritDoc}.
- */
@Override
- public void forward(final Collection<IArtifactInfo> policies) throws ArtifactForwardingException {
- numberOfPoliciesReceived += policies.size();
- policiesReceived.addAll(policies);
+ public void forward(final PolicyInput policy) throws ArtifactForwardingException {
+ numberOfPoliciesReceived += 1;
}
- /**
- * Returns the number of policies received by this forwarder.
- *
- * @return the integer value
- */
public int getNumberOfPoliciesReceived() {
return numberOfPoliciesReceived;
}
- /**
- * Checks if the forwarder has received a policy with given policy type.
- *
- * @param policyType the policy type
- * @return the boolean result
- */
- public boolean receivedPolicyWithGivenType(final String policyType) {
- return true;
- }
-
- /**
- * {@inheritDoc}.
- */
@Override
- public void configure(final String parameterGroupName) {}
+ public void configure(String parameterGroupName) {}
}