summaryrefslogtreecommitdiffstats
path: root/blueprints-processor/plugin/assignment-provider
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints-processor/plugin/assignment-provider')
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java21
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java77
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java25
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java41
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java55
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java85
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java23
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java31
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java53
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java31
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml1
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java51
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java49
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java33
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java37
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java23
18 files changed, 377 insertions, 325 deletions
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
index 9ab5ae6a6..10e217b8c 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/ConfigAssignmentConstants.java
@@ -1,34 +1,37 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment;
@SuppressWarnings("squid:S1118")
public class ConfigAssignmentConstants {
-
+
public static final String OUTPUT_PARAM_STATUS = "status";
public static final String OUTPUT_PARAM_RESOURCE_ASSIGNMENT_PARAMS = "resource-assignment-params";
public static final String OUTPUT_PARAM_MASHED_DATA = "mashed-data";
public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
public static final String OUTPUT_STATUS_SUCCESS = "success";
public static final String OUTPUT_STATUS_FAILURE = "failure";
-
+
public static final String INPUT_PARAM_REQUEST_ID = "request-id";
public static final String INPUT_PARAM_RESOURCE_ID = "resource-id";
public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type";
public static final String INPUT_PARAM_ACTION_NAME = "action-name";
public static final String INPUT_PARAM_TEMPLATE_NAMES = "template-names";
public static final String INPUT_PARAM_INPUT_DATA = "input-data";
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
index d8a2745ea..816c943f3 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/data/ResourceAssignmentData.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.data;
@@ -21,7 +24,7 @@ import org.onap.ccsdk.config.model.data.ResourceAssignment;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class ResourceAssignmentData {
-
+
private String requestId;
private boolean reloadModel;
private String resourceType;
@@ -37,123 +40,123 @@ public class ResourceAssignmentData {
private Map<String, String> templatesMashedContents = new HashMap<>();
private Map<String, String> templatesData = new HashMap<>();
private Map<String, Object> context = new HashMap<>();
-
+
public String getRequestId() {
return requestId;
}
-
+
public void setRequestId(String requestId) {
this.requestId = requestId;
}
-
+
public String getResourceType() {
return resourceType;
}
-
+
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
-
+
public String getResourceId() {
return resourceId;
}
-
+
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
-
+
public String getServiceTemplateName() {
return serviceTemplateName;
}
-
+
public void setServiceTemplateName(String serviceTemplateName) {
this.serviceTemplateName = serviceTemplateName;
}
-
+
public String getServiceTemplateVersion() {
return serviceTemplateVersion;
}
-
+
public void setServiceTemplateVersion(String serviceTemplateVersion) {
this.serviceTemplateVersion = serviceTemplateVersion;
}
-
+
public String getActionName() {
return actionName;
}
-
+
public void setActionName(String actionName) {
this.actionName = actionName;
}
-
+
public String getInputData() {
return inputData;
}
-
+
public void setInputData(String inputData) {
this.inputData = inputData;
}
-
+
public List<String> getTemplateNames() {
return templateNames;
}
-
+
public void setTemplateNames(List<String> templateNames) {
this.templateNames = templateNames;
}
-
+
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments() {
return templatesResourceAssignments;
}
-
+
public void setTemplatesResourceAssignments(Map<String, List<ResourceAssignment>> templatesResourceAssignments) {
this.templatesResourceAssignments = templatesResourceAssignments;
}
-
+
public Map<String, String> getTemplatesContents() {
return templatesContents;
}
-
+
public void setTemplatesContents(Map<String, String> templatesContents) {
this.templatesContents = templatesContents;
}
-
+
public Map<String, String> getTemplatesMashedContents() {
return templatesMashedContents;
}
-
+
public void setTemplatesMashedContents(Map<String, String> templatesMashedContents) {
this.templatesMashedContents = templatesMashedContents;
}
-
+
public Map<String, String> getTemplatesData() {
return templatesData;
}
-
+
public void setTemplatesData(Map<String, String> templatesData) {
this.templatesData = templatesData;
}
-
+
public Map<String, Object> getContext() {
return context;
}
-
+
public void setContext(Map<String, Object> context) {
this.context = context;
}
-
+
public SvcLogicContext getSvcLogicContext() {
return svcLogicContext;
}
-
+
public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
this.svcLogicContext = svcLogicContext;
}
-
+
public boolean isReloadModel() {
return reloadModel;
}
-
+
public void setReloadModel(boolean reloadModel) {
this.reloadModel = reloadModel;
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
index d80fec8a9..5fcedd87f 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ProcessorFactory.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.processor;
@@ -21,20 +24,20 @@ import org.onap.ccsdk.config.model.service.ComponentNodeService;
import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;
public class ProcessorFactory {
-
+
private ConfigResourceService configResourceService;
private ConfigRestAdaptorService configRestAdaptorService;
private ComponentNodeService componentNodeService;
-
+
public ProcessorFactory(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ComponentNodeService componentNodeService) {
this.componentNodeService = componentNodeService;
this.configResourceService = configResourceService;
this.configRestAdaptorService = configRestAdaptorService;
}
-
+
public ComponentNode getInstance(String source) {
-
+
if (ConfigModelConstant.SOURCE_DEFAULT.equalsIgnoreCase(source)) {
return new DefaultResourceProcessor(configResourceService);
} else if (ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(source)) {
@@ -45,5 +48,5 @@ public class ProcessorFactory {
// Default
return new InputResourceProcessor(configResourceService);
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
index c1c9b93c0..70d9abc68 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/processor/ResourceAssignmentProcessor.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.processor;
@@ -27,16 +30,16 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceAssignmentProcessor {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentProcessor.class);
-
+
private List<ResourceAssignment> assignments;
private Map<String, ResourceAssignment> resourceAssignmentMap;
-
+
@SuppressWarnings("squid:S1172")
public ResourceAssignmentProcessor(List<ResourceAssignment> assignments, SvcLogicContext ctx) {
this.assignments = assignments;
this.resourceAssignmentMap = new HashMap<>();
}
-
+
@SuppressWarnings("squid:S3776")
public List<List<ResourceAssignment>> process() {
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = new ArrayList<>();
@@ -48,7 +51,7 @@ public class ResourceAssignmentProcessor {
resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);
}
});
-
+
TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();
this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {
if (mapping != null) {
@@ -61,30 +64,30 @@ public class ResourceAssignmentProcessor {
}
}
});
-
+
List<ResourceAssignment> sequencedResourceAssignments = topologySorting.topSort();
logger.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments);
-
+
List<ResourceAssignment> batchResourceAssignment = null;
List<String> batchAssignmentName = null;
for (int i = 0; i < sequencedResourceAssignments.size(); i++) {
ResourceAssignment resourceAssignment = sequencedResourceAssignments.get(i);
ResourceAssignment previousResourceAssignment = null;
-
+
if (i > 0) {
previousResourceAssignment = sequencedResourceAssignments.get(i - 1);
}
if (resourceAssignment != null) {
-
+
boolean dependencyPresence = false;
if (batchAssignmentName != null && resourceAssignment.getDependencies() != null) {
dependencyPresence =
CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.getDependencies());
}
-
+
logger.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.getName(),
batchAssignmentName, resourceAssignment.getDependencies(), dependencyPresence);
-
+
if (previousResourceAssignment != null && resourceAssignment.getDictionarySource() != null
&& resourceAssignment.getDictionarySource()
.equalsIgnoreCase(previousResourceAssignment.getDictionarySource())
@@ -98,12 +101,12 @@ public class ResourceAssignmentProcessor {
}
batchResourceAssignment = new ArrayList<>();
batchResourceAssignment.add(resourceAssignment);
-
+
batchAssignmentName = new ArrayList<>();
batchAssignmentName.add(resourceAssignment.getName());
}
}
-
+
if (i == (sequencedResourceAssignments.size() - 1)) {
logger.trace("Created old Set ({})", batchAssignmentName);
sequenceBatchResourceAssignment.add(batchResourceAssignment);
@@ -113,5 +116,5 @@ public class ResourceAssignmentProcessor {
}
return sequenceBatchResourceAssignment;
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
index e27d57a79..320f4369b 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,59 +34,59 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentPersistService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);
-
+
private ConfigResourceService configResourceService;
-
+
public ConfigAssignmentPersistService(ConfigResourceService configResourceService) {
this.configResourceService = configResourceService;
}
-
+
public void saveResourceMapping(org.onap.ccsdk.config.assignment.data.ResourceAssignmentData resourceAssignmentData,
String templateName, List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
try {
-
+
if (resourceAssignmentData == null) {
throw new SvcLogicException("Resource assignment data is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getRequestId())) {
logger.warn("Request Id ({}) is missing, may be getting request for resource update.",
resourceAssignmentData.getRequestId());
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {
throw new SvcLogicException("Resource Id is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {
throw new SvcLogicException("Resource type is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {
throw new SvcLogicException("Action name is missing");
}
-
+
if (StringUtils.isBlank(templateName)) {
throw new SvcLogicException("template name is missing");
}
-
+
StringBuilder builder = new StringBuilder();
builder.append("Resource Assignment for Template Name :");
builder.append(templateName);
builder.append("\n");
builder.append(TransformationUtils.getJson(resourceAssignments, true));
-
+
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
// Resource Data should be Regenerated based on the new Updates
String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);
-
+
List<ResourceAssignmentData> resourceAssignmentDataList =
ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments);
-
+
ConfigResource configResource = new ConfigResource();
configResource.setRequestId(resourceAssignmentData.getRequestId());
configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName());
@@ -95,14 +98,14 @@ public class ConfigAssignmentPersistService {
configResource.setTemplateName(templateName);
configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS);
configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);
-
+
if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) {
configResource.setResourceAssignments(resourceAssignmentDataList);
}
configResource = configResourceService.saveConfigResource(configResource);
logger.info("Resource data saved successfully for the template ({}) with resource id ({})", templateName,
configResource.getResourceId());
-
+
builder = new StringBuilder();
builder.append("Resource Data Template Name :");
builder.append(templateName);
@@ -110,11 +113,11 @@ public class ConfigAssignmentPersistService {
builder.append(resourceData);
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
} catch (Exception e) {
throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e);
}
-
+
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
index 81e76897e..85ff82db6 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentProcessService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -40,15 +43,15 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentProcessService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentProcessService.class);
-
+
private ComponentNodeService componentNodeService;
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigRestAdaptorService configRestAdaptorService;
private ConfigGeneratorService configGeneratorService;
-
+
public ConfigAssignmentProcessService(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {
@@ -58,19 +61,19 @@ public class ConfigAssignmentProcessService {
this.configRestAdaptorService = configRestAdaptorService;
this.configGeneratorService = configGeneratorService;
}
-
+
@SuppressWarnings("squid:S1141")
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
try {
validateInputParams(resourceAssignmentData);
-
+
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();
String actionName = resourceAssignmentData.getActionName();
String inputData = resourceAssignmentData.getInputData();
SvcLogicContext svcLogicContext = resourceAssignmentData.getSvcLogicContext();
List<String> templateNames = resourceAssignmentData.getTemplateNames();
-
+
if (resourceAssignmentData.isReloadModel()) {
Map<String, String> context = new HashMap<>();
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);
@@ -79,21 +82,21 @@ public class ConfigAssignmentProcessService {
context.forEach((key, value) -> svcLogicContext.setAttribute(key, value));
logger.info("List of Resources provided in input: {}", svcLogicContext.toProperties());
}
-
+
Map<String, Object> componentContext = resourceAssignmentData.getContext();
-
+
if (CollectionUtils.isNotEmpty(templateNames)) {
// Get the Resource Assignments for templates and Validate the mappings
ResourceModelService resourceModelService = new ResourceModelService(configModelService);
-
+
// Get the Resource Assignment
Map<String, List<ResourceAssignment>> templatesResourceAssignments =
resourceModelService.getTemplatesResourceAssignments(svcLogicContext, templateNames);
-
+
// Get the Template Contents
Map<String, String> templatesContents =
resourceModelService.getTemplatesContents(svcLogicContext, templateNames);
-
+
// Process each template
for (String templateName : templateNames) {
List<ResourceAssignment> resourceAssignments = templatesResourceAssignments.get(templateName);
@@ -106,67 +109,67 @@ public class ConfigAssignmentProcessService {
new ResourceDictionaryService(configRestAdaptorService);
Map<String, ResourceDefinition> dictionaries =
resourceDictionaryService.getDataDictionaryDefinitions(resourceAssignments);
-
+
processResourceAssignments(resourceAssignmentData, svcLogicContext, componentContext,
templateName, resourceAssignments, dictionaries);
-
+
logger.info("decrypting config data for templateName {}", templateName);
templateData =
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);
} finally {
saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);
}
-
+
logger.info("generating config preview for templateName {}", templateName);
ConfigPreviewService configPreviewService = new ConfigPreviewService(configResourceService,
configModelService, configGeneratorService);
String mashedData = configPreviewService.generatePreview(templateContent, templateData);
resourceAssignmentData.getTemplatesMashedContents().put(templateName, mashedData);
resourceAssignmentData.getTemplatesData().put(templateName, templateData);
-
+
} else {
// Do nothing for Mapping not found
logger.warn("No resource Assignment mappings to resolve for templateName {}", templateName);
}
}
}
-
+
} catch (Exception e) {
throw new SvcLogicException(e.getMessage(), e);
}
}
-
+
private void processResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,
Map<String, Object> componentContext, String templateName, List<ResourceAssignment> resourceAssignments,
Map<String, ResourceDefinition> dictionaries) throws SvcLogicException {
-
+
String recipeName = resourceAssignmentData.getActionName();
-
+
ResourceAssignmentProcessor resourceAssignmentProcessor =
new ResourceAssignmentProcessor(resourceAssignments, ctx);
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();
-
+
logger.debug("Resource dictionary Info ({})", dictionaries);
-
+
if (sequenceBatchResourceAssignment != null) {
componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName);
componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, templateName);
componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries);
for (List<ResourceAssignment> batchResourceAssignment : sequenceBatchResourceAssignment) {
-
+
processBatchResourceAssignments(resourceAssignmentData, ctx, componentContext, batchResourceAssignment);
-
+
logger.debug("Batch Resource data status ({})", TransformationUtils.getJson(batchResourceAssignment));
}
}
}
-
+
private void processBatchResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx,
Map<String, Object> componentContext, List<ResourceAssignment> batchResourceAssignment)
throws SvcLogicException {
-
+
if (CollectionUtils.isNotEmpty(batchResourceAssignment)) {
-
+
ResourceAssignment batchFirstResourceAssignment = batchResourceAssignment.get(0);
if (batchFirstResourceAssignment != null
&& StringUtils.isNotBlank(batchFirstResourceAssignment.getDictionarySource())) {
@@ -174,12 +177,12 @@ public class ConfigAssignmentProcessService {
// Processing their Source
logger.info("Processing source ({}) with batch ({}) ", source, batchResourceAssignment);
componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment);
-
+
ProcessorFactory factory =
new ProcessorFactory(configResourceService, configRestAdaptorService, componentNodeService);
-
+
ComponentNode processor = factory.getInstance(source);
-
+
Map<String, String> inParams = new HashMap<>();
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, resourceAssignmentData.getRequestId());
inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, resourceAssignmentData.getResourceId());
@@ -192,23 +195,23 @@ public class ConfigAssignmentProcessService {
}
}
}
-
+
private void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
if (resourceAssignmentData != null && StringUtils.isNotBlank(templateName)) {
-
+
ConfigAssignmentPersistService configAssignmentPersistService =
new ConfigAssignmentPersistService(configResourceService);
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName,
resourceAssignments);
}
}
-
+
private void validateInputParams(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
if (resourceAssignmentData == null) {
throw new SvcLogicException("Input parameters missing");
}
-
+
String requestId = resourceAssignmentData.getRequestId();
if (StringUtils.isBlank(requestId)) {
throw new SvcLogicException("Request id parameters missing");
@@ -225,11 +228,11 @@ public class ConfigAssignmentProcessService {
if (StringUtils.isBlank(actionName)) {
throw new SvcLogicException("Action name is parameter is missing");
}
-
+
List<String> templatesNames = resourceAssignmentData.getTemplateNames();
if (CollectionUtils.isEmpty(templatesNames)) {
throw new SvcLogicException("Template names parameter missing");
}
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
index e0fcc9175..4866f258b 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -20,13 +23,13 @@ import org.onap.ccsdk.config.model.data.ResourceAssignment;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public interface ConfigAssignmentService {
-
+
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException;
-
+
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException;
-
+
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException;
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
index 48e15b15a..9e2bdcf8d 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentServiceImpl.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -27,17 +30,17 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class);
-
+
private ComponentNodeService componentNodeService;
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigRestAdaptorService configRestAdaptorService;
private ConfigGeneratorService configGeneratorService;
-
+
private static final String CLASS_NAME = "ConfigAssignmentServiceImpl";
-
+
public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService,
ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService,
ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) {
@@ -48,7 +51,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
this.configRestAdaptorService = configRestAdaptorService;
this.configGeneratorService = configGeneratorService;
}
-
+
@Override
public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException {
ConfigAssignmentProcessService configAssignmentProcessService =
@@ -56,7 +59,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
componentNodeService, configGeneratorService);
configAssignmentProcessService.resolveResources(resourceAssignmentData);
}
-
+
@Override
public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName,
List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
@@ -64,7 +67,7 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
new ConfigAssignmentPersistService(configResourceService);
configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments);
}
-
+
@Override
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException {
@@ -72,5 +75,5 @@ public class ConfigAssignmentServiceImpl implements ConfigAssignmentService {
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);
return configPreviewService.generateTemplateResourceMash(resourceAssignmentData);
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
index 1f74b71ad..32adbe249 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentUtils.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -44,13 +47,13 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class ConfigAssignmentUtils {
-
+
private ConfigAssignmentUtils() {
-
+
}
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentUtils.class);
-
+
public static synchronized Object getContextKeyValue(SvcLogicContext context, String key) {
Object value = null;
if (context != null && key != null) {
@@ -65,7 +68,7 @@ public class ConfigAssignmentUtils {
}
return value;
}
-
+
/*
* Populate the Field property type for the Data type
*/
@@ -98,7 +101,7 @@ public class ConfigAssignmentUtils {
}
return type;
}
-
+
/*
* Populate the Field property type for the Data type
*/
@@ -126,7 +129,7 @@ public class ConfigAssignmentUtils {
}
return propertyDefinition;
}
-
+
public static synchronized ResourceDefinition getDictionaryDefinition(Map<String, ResourceDictionary> dictionaries,
String dictionaryName) {
ResourceDefinition resourceDefinition = null;
@@ -139,7 +142,7 @@ public class ConfigAssignmentUtils {
}
return resourceDefinition;
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized void populateValueForOutputMapping(SvcLogicContext ctx,
Map<String, Object> componentContext, ResourceAssignment resourceAssignment,
@@ -148,19 +151,19 @@ public class ConfigAssignmentUtils {
if (resourceAssignment == null) {
throw new SvcLogicException("resourceAssignment is null.");
}
-
+
if (ctx == null) {
throw new SvcLogicException("service logic context is null.");
}
-
+
if (componentContext == null) {
throw new SvcLogicException("component context is null.");
}
-
+
logger.info("populating value for output mapping ({}), from json ({})", outputKeyMapping, responseNode);
String dictionaryName = resourceAssignment.getDictionaryName();
String type = resourceAssignment.getProperty().getType();
-
+
String entrySchema = null;
if (ValidTypes.getPrimitivePropertType().contains(type)) {
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, responseNode);
@@ -169,7 +172,7 @@ public class ConfigAssignmentUtils {
if (resourceAssignment.getProperty().getEntrySchema() != null) {
entrySchema = resourceAssignment.getProperty().getEntrySchema().getType();
}
-
+
if (StringUtils.isNotBlank(entrySchema)) {
ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) {
@@ -181,7 +184,7 @@ public class ConfigAssignmentUtils {
ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode();
for (Map.Entry<String, String> mapping : outputKeyMapping.entrySet()) {
JsonNode responseKeyValue = responseSingleJsonNode.get(mapping.getKey());
-
+
String propertyTypeForDataType =
ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey());
logger.info("For List Type Resource: key ({}), value ({}), type ({})",
@@ -221,7 +224,7 @@ public class ConfigAssignmentUtils {
ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode);
}
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized List<ResourceAssignment> convertResoureAssignmentDataList(
List<ResourceAssignmentData> resourceAssignmentDataList) {
@@ -240,7 +243,7 @@ public class ConfigAssignmentUtils {
resourceAssignment.setMessage(resourceAssignmentData.getMessage());
PropertyDefinition property = new PropertyDefinition();
property.setType(resourceAssignmentData.getDataType());
-
+
if (StringUtils.isNotBlank(resourceAssignmentData.getResourceValue())) {
if (ValidTypes.getPrimitivePropertType().contains(resourceAssignmentData.getDataType())) {
property.setValue(resourceAssignmentData.getResourceValue());
@@ -261,11 +264,11 @@ public class ConfigAssignmentUtils {
assignments.add(resourceAssignment);
}
}
-
+
}
return assignments;
}
-
+
@SuppressWarnings("squid:S3776")
public static synchronized List<ResourceAssignmentData> convertResoureAssignmentList(
List<ResourceAssignment> assignments) {
@@ -298,5 +301,5 @@ public class ConfigAssignmentUtils {
}
return resourceAssignmentDataList;
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
index 7aa2d438a..ae5c01c88 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -35,14 +38,14 @@ public class ConfigPreviewService {
private ConfigResourceService configResourceService;
private ConfigModelService configModelService;
private ConfigGeneratorService configGeneratorService;
-
+
public ConfigPreviewService(ConfigResourceService configResourceService, ConfigModelService configModelService,
ConfigGeneratorService configGeneratorService) {
this.configResourceService = configResourceService;
this.configModelService = configModelService;
this.configGeneratorService = configGeneratorService;
}
-
+
public String generatePreview(String templateContent, String templateData) throws SvcLogicException {
String mashedData = "";
ConfigGeneratorInfo configGeneratorInfo =
@@ -52,7 +55,7 @@ public class ConfigPreviewService {
}
return mashedData;
}
-
+
public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData)
throws SvcLogicException {
if (resourceAssignmentData == null) {
@@ -73,25 +76,25 @@ public class ConfigPreviewService {
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {
throw new SvcLogicException("Action name is missing");
}
-
+
String serviceTemplateName = resourceAssignmentData.getServiceTemplateName();
String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion();
String actionName = resourceAssignmentData.getActionName();
String resourceId = resourceAssignmentData.getResourceId();
String resourceType = resourceAssignmentData.getResourceType();
String inputData = "{}";
-
+
Map<String, String> context = new HashMap<>();
context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName);
context = configModelService.prepareContext(context, inputData, serviceTemplateName, serviceTemplateVersion);
-
+
ConfigResource configResourceQuery = new ConfigResource();
configResourceQuery.setServiceTemplateVersion(serviceTemplateName);
configResourceQuery.setServiceTemplateVersion(serviceTemplateVersion);
configResourceQuery.setRecipeName(actionName);
configResourceQuery.setResourceId(resourceId);
configResourceQuery.setResourceType(resourceType);
-
+
List<ConfigResource> configResources = configResourceService.getConfigResource(configResourceQuery);
if (CollectionUtils.isNotEmpty(configResources)) {
for (ConfigResource cr : configResources) {
@@ -110,7 +113,7 @@ public class ConfigPreviewService {
serviceTemplateName, serviceTemplateVersion, actionName, resourceId, resourceType);
}
return resourceAssignmentData;
-
+
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
index 97a4dd45e..50562b0e8 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceDictionaryService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,14 +34,14 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ResourceDictionaryService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryService.class);
private ConfigRestAdaptorService configRestAdaptorService;
-
+
public ResourceDictionaryService(ConfigRestAdaptorService configRestAdaptorService) {
this.configRestAdaptorService = configRestAdaptorService;
}
-
+
@SuppressWarnings("squid:S3776")
public Map<String, ResourceDefinition> getDataDictionaryDefinitions(List<ResourceAssignment> resourceAssignments)
throws SvcLogicException {
@@ -48,11 +51,11 @@ public class ResourceDictionaryService {
List<String> names = new ArrayList<>();
for (ResourceAssignment resourceAssignment : resourceAssignments) {
if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) {
-
+
if (!names.contains(resourceAssignment.getDictionaryName())) {
names.add(resourceAssignment.getDictionaryName());
}
-
+
if (resourceAssignment.getDependencies() != null
&& !resourceAssignment.getDependencies().isEmpty()) {
List<String> dependencieNames = resourceAssignment.getDependencies();
@@ -70,18 +73,18 @@ public class ResourceDictionaryService {
} catch (Exception e) {
throw new SvcLogicException("Failed in getting resource data dictionary : " + e.getMessage());
}
-
+
}
-
+
@SuppressWarnings("squid:S3776")
private void queryResourceDictionaryDefinitions(Map<String, ResourceDefinition> dictionaries, List<String> names)
throws SvcLogicException, ConfigRestAdaptorException {
logger.info("Getting resource dictionary definition for the names ({})", names);
if (!names.isEmpty()) {
-
+
String dictionaryContents = configRestAdaptorService.postResource(
ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, "dictionarybynames", names, String.class);
-
+
if (StringUtils.isNotBlank(dictionaryContents)) {
List<ResourceDictionary> dataDictionaries =
TransformationUtils.getListfromJson(dictionaryContents, ResourceDictionary.class);
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
index 7eb21967d..9f3013b73 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ResourceModelService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -30,13 +33,13 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceModelService {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceModelService.class);
-
+
private ConfigModelService configModelService;
-
+
public ResourceModelService(ConfigModelService configModelService) {
this.configModelService = configModelService;
}
-
+
public Map<String, String> getTemplatesContents(SvcLogicContext ctx, List<String> templateNames)
throws SvcLogicException {
Map<String, String> templatesContents = new HashMap<>();
@@ -53,7 +56,7 @@ public class ResourceModelService {
}
return templatesContents;
}
-
+
public Map<String, List<ResourceAssignment>> getTemplatesResourceAssignments(SvcLogicContext ctx,
List<String> templateNames) throws SvcLogicException {
Map<String, List<ResourceAssignment>> templatesResourceAssignments = new HashMap<>();
@@ -63,12 +66,12 @@ public class ResourceModelService {
String resourceMappingContent = this.configModelService.getNodeTemplateMapping(ctx, templateName);
logger.info("Processing template ({}) with resource assignment content : {}", templateName,
resourceMappingContent);
-
+
if (StringUtils.isNotBlank(resourceMappingContent)) {
-
+
List<ResourceAssignment> resourceAssignments =
TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class);
-
+
if (resourceAssignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator =
new ResourceAssignmentValidator(resourceAssignments);
@@ -88,7 +91,7 @@ public class ResourceModelService {
} catch (Exception e) {
throw new SvcLogicException(e.getMessage());
}
-
+
return templatesResourceAssignments;
}
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index ebefd645c..c880c8d4f 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2017-2018 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
index 4696fd281..75b7f2e28 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigPreviewServiceTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -39,37 +42,37 @@ import com.att.eelf.configuration.EELFManager;
@RunWith(MockitoJUnitRunner.class)
public class ConfigPreviewServiceTest {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPreviewServiceTest.class);
-
+
@Rule
public ExpectedException thrown = ExpectedException.none();
-
+
@Mock
private ConfigResourceService configResourceService;
-
+
@Mock
private ConfigRestAdaptorService configRestAdaptorService;
-
+
private ConfigModelService configModelService;
private ConfigGeneratorService configGeneratorService;
-
+
@SuppressWarnings("unchecked")
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void testGenerateTemplateResourceMash() throws Exception {
-
+
ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService);
-
+
ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment");
-
+
ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService,
"assignments/empty-dictionary.json");
-
+
ConfigResource configResourceQuery = new ConfigResource();
configResourceQuery.setServiceTemplateVersion("sample-serviceTemplateName");
configResourceQuery.setServiceTemplateVersion("1.0.0");
@@ -80,28 +83,28 @@ public class ConfigPreviewServiceTest {
String inputContent = FileUtils.readFileToString(
new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset());
configResourceQuery.setResourceData(inputContent);
-
+
ConfigResourceAssignmentTestUtils.injectGetConfigResourceMock(configResourceService, configResourceQuery);
-
+
configModelService = new ConfigModelServiceImpl(configRestAdaptorService);
configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService);
-
+
ConfigPreviewService configPreviewService =
new ConfigPreviewService(configResourceService, configModelService, configGeneratorService);
-
+
ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData();
resourceAssignmentData.setResourceId("123-resourceId");
resourceAssignmentData.setResourceType("sample-resourceType");
resourceAssignmentData.setServiceTemplateName("sample-serviceTemplateName");
resourceAssignmentData.setServiceTemplateVersion("1.0.0");
resourceAssignmentData.setActionName("sample-action");
-
+
resourceAssignmentData = configPreviewService.generateTemplateResourceMash(resourceAssignmentData);
-
+
Assert.assertNotNull("Failed to get GenerateTemplateResourceMash response.", resourceAssignmentData);
Assert.assertNotNull("Failed to get template mashed contents.",
resourceAssignmentData.getTemplatesMashedContents());
-
+
Assert.assertNotNull("Failed to get base-config template mashed contents.",
resourceAssignmentData.getTemplatesMashedContents().get("base-config-template"));
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
index f4ee969fb..ee1c076ae 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ConfigResourceAssignmentTestUtils.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -44,9 +47,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ConfigResourceAssignmentTestUtils {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceAssignmentTestUtils.class);
-
+
public static void injectTransactionLogSaveMock(ConfigResourceService configResourceService) throws Exception {
Mockito.doAnswer(new Answer<Void>() {
@Override
@@ -59,10 +62,10 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).save(any(TransactionLog.class));
}
-
+
public static void injectConfigModelMock(ConfigRestAdaptorService configRestAdaptorService,
String serviceTemplateName) throws Exception {
-
+
Mockito.doAnswer(new Answer<ConfigModel>() {
@Override
public org.onap.ccsdk.config.model.domain.ConfigModel answer(InvocationOnMock invocationOnMock)
@@ -70,23 +73,23 @@ public class ConfigResourceAssignmentTestUtils {
Object[] args = invocationOnMock.getArguments();
org.onap.ccsdk.config.model.domain.ConfigModel serviceArtifact = null;
if (args != null && args.length == 3) {
-
+
logger.info("Artifact info " + Arrays.asList(args));
String modelContent = IOUtils.toString(
ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(
"service_templates/" + serviceTemplateName + "/" + serviceTemplateName + ".json"),
Charset.defaultCharset());
-
+
ConfigModelContent configModelContent = new ConfigModelContent();
configModelContent.setContent(modelContent);
configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON);
-
+
List<ConfigModelContent> configModelContents = new ArrayList<>();
configModelContents.add(configModelContent);
-
+
String velocityDir = ConfigResourceAssignmentTestUtils.class.getClassLoader()
.getResource("service_templates/" + serviceTemplateName + "/velocity").getPath();
-
+
Collection<File> templateFiles =
FileUtils.listFiles(new File(velocityDir), new String[] {"vtl"}, true);
logger.info("Template Files info " + templateFiles);
@@ -98,22 +101,22 @@ public class ConfigResourceAssignmentTestUtils {
configModelTemplateContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE);
configModelContents.add(configModelTemplateContent);
}
-
+
serviceArtifact = new org.onap.ccsdk.config.model.domain.ConfigModel();
serviceArtifact.setArtifactName(String.valueOf(args[0]));
serviceArtifact.setArtifactVersion(String.valueOf(args[1]));
serviceArtifact.setPublished("Y");
serviceArtifact.setConfigModelContents(configModelContents);
}
-
+
return serviceArtifact;
}
}).when(configRestAdaptorService).getResource(anyString(), anyString(), Matchers.any(Class.class));
}
-
+
public static void injectResourceDictionaryMock(ConfigRestAdaptorService configRestAdaptorService,
String dictionaryFileName) throws Exception {
-
+
Mockito.doAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocationOnMock) throws Throwable {
@@ -130,7 +133,7 @@ public class ConfigResourceAssignmentTestUtils {
}).when(configRestAdaptorService).postResource(Matchers.any(), Matchers.any(), Matchers.any(),
Matchers.any(Class.class));
}
-
+
public static void injectConfigResourceSaveMock(ConfigResourceService configResourceService) throws Exception {
Mockito.doAnswer(new Answer<ConfigResource>() {
@Override
@@ -146,7 +149,7 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).saveConfigResource(any(ConfigResource.class));
}
-
+
public static void injectGetConfigResourceMock(ConfigResourceService configResourceService,
ConfigResource configResource) throws Exception {
Mockito.doAnswer(new Answer<List<ConfigResource>>() {
@@ -161,12 +164,12 @@ public class ConfigResourceAssignmentTestUtils {
}
}).when(configResourceService).getConfigResource(any(ConfigResource.class));
}
-
+
public static String getFileContent(String filePath) throws Exception {
return IOUtils.toString(ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(filePath),
Charset.defaultCharset());
}
-
+
public static Map<String, ResourceDefinition> getMapfromJson(String content) {
try {
ObjectMapper mapper = new ObjectMapper();
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
index e979ea3d1..3dc7da7eb 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentGenerationTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,16 +34,16 @@ import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
public class ResourceAssignmentGenerationTest {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentGenerationTest.class);
-
+
@Test
public void testResourceDataSetting() {
try {
logger.info(" **************** testResourceDataSetting *****************");
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()
.getResourceAsStream("assignments/alltype-empty-value-mapping.json"), Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);
if (assignments != null) {
@@ -75,33 +78,33 @@ public class ResourceAssignmentGenerationTest {
}
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);
logger.trace("Generated Data " + generatedData);
-
+
Assert.assertNotNull("Failed to generate resource data", generatedData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
-
+
@Test
public void testGenerateResourceData() {
try {
logger.info(" **************** testGenerateResourceData *****************");
String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader()
.getResourceAsStream("assignments/alltype-mapping.json"), Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class);
if (assignments != null) {
-
+
String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments);
logger.trace("Generated Data " + generatedData);
-
+
Assert.assertNotNull("Failed to generate resource data", generatedData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
-
+
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
index 0bf74b4c0..d708404f5 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/ResourceAssignmentValidation.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -31,10 +34,10 @@ import com.att.eelf.configuration.EELFManager;
public class ResourceAssignmentValidation {
private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidation.class);
-
+
@Rule
public final ExpectedException exception = ExpectedException.none();
-
+
@Test
public void testValidateSuccess() {
try {
@@ -42,12 +45,12 @@ public class ResourceAssignmentValidation {
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/success.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
-
+
boolean result = resourceAssignmentValidator.validateResourceAssignment();
Assert.assertTrue("Failed to Validate", result);
}
@@ -55,37 +58,37 @@ public class ResourceAssignmentValidation {
e.printStackTrace();
}
}
-
+
@Test(expected = ConfigModelException.class)
public void testValidateDuplicate() throws IOException, ConfigModelException {
logger.info(" **************** testValidateDuplicate *****************");
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/duplicate.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
resourceAssignmentValidator.validateResourceAssignment();
}
-
+
}
-
+
@Test(expected = ConfigModelException.class)
public void testValidateCyclic() throws IOException, ConfigModelException {
logger.info(" **************** testValidateCyclic *****************");
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/cyclic.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments);
-
+
resourceAssignmentValidator.validateResourceAssignment();
}
-
+
}
}
diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
index 1b05e4b0e..e4b7f5dee 100644
--- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
+++ b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/config/assignment/service/TopologicalSortingTest.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.config.assignment.service;
@@ -28,7 +31,7 @@ import com.att.eelf.configuration.EELFManager;
public class TopologicalSortingTest {
private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class);
-
+
@Test
public void testBulkSequencingMapping() {
try {
@@ -36,7 +39,7 @@ public class TopologicalSortingTest {
String resourceMapping = IOUtils.toString(
TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"),
Charset.defaultCharset());
-
+
List<ResourceAssignment> assignments =
TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);
if (assignments != null) {
@@ -44,7 +47,7 @@ public class TopologicalSortingTest {
ResourceAssignmentProcessor resourceAssignmentProcessor =
new ResourceAssignmentProcessor(assignments, ctx);
List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();
-
+
Assert.assertNotNull("Failed to populate Sequence Bulk Mappings", sequenceBatchResourceAssignment);
Assert.assertNotEquals("Failed to populate Sequence Bulk Mappings size ",
(sequenceBatchResourceAssignment.size() > 0));
@@ -53,5 +56,5 @@ public class TopologicalSortingTest {
e.printStackTrace();
}
}
-
+
}