aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service
diff options
context:
space:
mode:
authorJerry Flood <jflood@att.com>2019-03-25 12:29:03 -0400
committerJerry Flood <jflood@att.com>2019-03-26 10:18:37 -0400
commit4bd2300fa568d7f74de6a058daadf87277b139bf (patch)
tree49ff4fbd38beb39a24d63304583005bbe34ed2b9 /cmso-service
parentbe22b5c1a54a7875339758c5ef18e12bdb765277 (diff)
Commit 18 for Create Optimized Sched API
Multiple commits required due to commit size limitation. Change-Id: I54431d92b7685911a761800137a301ce9b2fc2f3 Issue-ID: OPTFRA-458 Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-service')
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java164
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/BuildCreateRequest.java95
-rw-r--r--cmso-service/src/main/resources/logmessages.properties1
-rw-r--r--cmso-service/src/test/java/org/onap/optf/cmso/JpaInit.java52
-rw-r--r--cmso-service/src/test/java/org/onap/optf/cmso/JtestHelper.java55
-rw-r--r--cmso-service/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java36
6 files changed, 301 insertions, 102 deletions
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
index e327acc..3d13b6f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
@@ -1,36 +1,34 @@
/*
- * 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
- *
- * 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
+ * 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
+ *
+ * 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 otherwise specified, all documentation contained herein is licensed under the Creative
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation 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 otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.optf.cmso.ticketmgt;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -38,7 +36,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-
import javax.transaction.Transactional;
import org.onap.optf.cmso.common.CMSStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
@@ -53,13 +50,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
@Component
public class TmStatusClient {
- private static EELFLogger log = EELFManager.getInstance().getLogger(TmStatusClient.class);
private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@@ -87,43 +80,48 @@ public class TmStatusClient {
Environment env;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDAO scheduleDao;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
+ ChangeManagementScheduleDAO cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDAO cmGroupDao;
@Autowired
TmClient tmClient;
+ /**
+ * Check status.
+ *
+ * @param id the id
+ */
@Transactional
public void checkStatus(String id) {
debug.debug("Entered checkStatus id=" + id);
try {
// Multiple cmso instance support - re-get the record with a Schedule lock
- UUID uuid = UUID.fromString(id);
- Schedule s = scheduleDAO.lockOne(uuid);
- if (!s.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {
- debug.debug(s.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()
- + " : it is " + s.getStatus());
+ UUID uuid = UUID.fromString(id);
+ Schedule sch = scheduleDao.lockOne(uuid);
+ if (!sch.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {
+ debug.debug(sch.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()
+ + " : it is " + sch.getStatus());
// Attempt at avoiding race condition in a load balance env. ?
return;
}
Map<GroupAuditStatus, List<ChangeManagementGroup>> groupStatus =
- new HashMap<GroupAuditStatus, List<ChangeManagementGroup>>();
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(uuid);
+ new HashMap<GroupAuditStatus, List<ChangeManagementGroup>>();
+ List<ChangeManagementGroup> groups = cmGroupDao.findBySchedulesID(uuid);
// Close tickets for completed VNFs
for (ChangeManagementGroup group : groups) {
- processGroup(s, group);
+ processGroup(sch, group);
}
// Check overall status of schedule.
//
for (ChangeManagementGroup group : groups) {
- GroupAuditStatus status = auditGroupStatus(s, group);
+ GroupAuditStatus status = auditGroupStatus(sch, group);
List<ChangeManagementGroup> list = groupStatus.get(status);
if (list == null) {
list = new ArrayList<ChangeManagementGroup>();
@@ -132,16 +130,17 @@ public class TmStatusClient {
list.add(group);
}
// In progress
- if (groupStatus.containsKey(GroupAuditStatus.InProgress))
+ if (groupStatus.containsKey(GroupAuditStatus.InProgress)) {
return;
+ }
//
if (groupStatus.containsKey(GroupAuditStatus.CompletedWithErrors)) {
- s.setStatus(CMSStatusEnum.CompletedWithError.toString());
+ sch.setStatus(CMSStatusEnum.CompletedWithError.toString());
}
if (groupStatus.containsKey(GroupAuditStatus.Completed)) {
- s.setStatus(CMSStatusEnum.Completed.toString());
+ sch.setStatus(CMSStatusEnum.Completed.toString());
}
- scheduleDAO.save(s);
+ scheduleDao.save(sch);
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -150,18 +149,17 @@ public class TmStatusClient {
}
}
- private void processGroup(Schedule s, ChangeManagementGroup group) throws CMSException {
- debug.debug("{Processing status of " + s.getScheduleId() + " group=" + group.getGroupId());
+ private void processGroup(Schedule sch, ChangeManagementGroup group) throws CMSException {
+ debug.debug("{Processing status of " + sch.getScheduleId() + " group=" + group.getGroupId());
// Get status of all VNFs within a ticket within the group (Tickets will not
// span groups)
Map<String, List<ChangeManagementSchedule>> failed = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> inProgress = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> completed = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> tmClosed = new HashMap<String, List<ChangeManagementSchedule>>();
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDao.findByChangeManagementGroupId(group.getUuid());
for (ChangeManagementSchedule cmSchedule : cmSchedules) {
String status = cmSchedule.getStatus();
- String changeId = cmSchedule.getTmChangeId();
String tmStatus = cmSchedule.getTmStatus();
CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status);
switch (cmsStatus) {
@@ -186,43 +184,47 @@ public class TmStatusClient {
case ScheduledImmediate:
default:
errors.applicationEvent(
- "Unexpected Change Management schedule event status {0} encountered after notification : scheduleId={1} vnfName={2}",
- status, s.getScheduleId(), cmSchedule.getVnfName());
+ "Unexpected Change Management schedule event status {0} encountered "
+ + "after notification : scheduleId={1} vnfName={2}",
+ status, sch.getScheduleId(), cmSchedule.getVnfName());
break;
}
- if (tmStatus != null && tmStatus.equals("Closed"))
+ if (tmStatus != null && tmStatus.equals("Closed")) {
addTo(tmClosed, cmSchedule);
+ }
}
- debug.debug("{Status of " + s.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="
- + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="
- + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());
+ debug.debug("{Status of " + sch.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="
+ + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="
+ + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());
// Remove all tickets from completed where there are still 'Triggered' VNFs
- for (String changeId : inProgress.keySet())
+ for (String changeId : inProgress.keySet()) {
completed.remove(changeId);
+ }
// Remove all tickets from completed where the ticket is already closed.
- for (String changeId : tmClosed.keySet())
+ for (String changeId : tmClosed.keySet()) {
completed.remove(changeId);
+ }
// Do not know what to do with failed
for (String changeId : failed.keySet()) {
completed.remove(changeId);
- closeTheTicket(s, group, changeId, failed.get(changeId), ClosureCode.Unsuccessful,
- "Change management request failed for one or more VNFs");
+ closeTheTicket(sch, group, changeId, failed.get(changeId), ClosureCode.Unsuccessful,
+ "Change management request failed for one or more VNFs");
}
// Remaining completed tickets should be closed
- debug.debug("{Final status of " + s.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="
- + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="
- + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());
+ debug.debug("{Final status of " + sch.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="
+ + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="
+ + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());
for (String changeId : completed.keySet()) {
- closeTheTicket(s, group, changeId, completed.get(changeId), ClosureCode.Successful,
- ClosureCode.Successful.toString());
+ closeTheTicket(sch, group, changeId, completed.get(changeId), ClosureCode.Successful,
+ ClosureCode.Successful.toString());
}
}
- private GroupAuditStatus auditGroupStatus(Schedule s, ChangeManagementGroup group) {
+ private GroupAuditStatus auditGroupStatus(Schedule sch, ChangeManagementGroup group) {
// Determine group status and synchronize VNF status with Ticket status.
Map<String, List<ChangeManagementSchedule>> failed = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> inProgress = new HashMap<String, List<ChangeManagementSchedule>>();
@@ -232,8 +234,7 @@ public class TmStatusClient {
Set<String> allNames = new HashSet<String>();
Set<String> failedNames = new HashSet<String>();
Set<String> completedNames = new HashSet<String>();
- Long startDate = group.getStartTimeMillis();
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDao.findByChangeManagementGroupId(group.getUuid());
for (ChangeManagementSchedule cmSchedule : cmSchedules) {
String vnfName = cmSchedule.getVnfName();
vnfNames.add(vnfName);
@@ -265,17 +266,20 @@ public class TmStatusClient {
case ScheduledImmediate:
default:
errors.applicationEvent(
- "Unexpected Change Management schedule event status {0} encountered after notification : scheduleId={1} vnfName={2}",
- status, s.getScheduleId(), cmSchedule.getVnfName());
+ "Unexpected Change Management schedule event status {0} encountered"
+ + " after notification : scheduleId={1} vnfName={2}",
+ status, sch.getScheduleId(), cmSchedule.getVnfName());
break;
}
- if (tmStatus != null && tmStatus.equals("Closed"))
+ if (tmStatus != null && tmStatus.equals("Closed")) {
addTo(tmClosed, cmSchedule);
+ }
}
// We have at least 1 ticket with VNFs in progress. Leave schedule status as is.
- if (inProgress.size() > 0)
+ if (inProgress.size() > 0) {
return GroupAuditStatus.InProgress;
+ }
// All VNFs are either failed or completed (or there is a bug.)
@@ -291,7 +295,6 @@ public class TmStatusClient {
}
private void addTo(Map<String, List<ChangeManagementSchedule>> map, ChangeManagementSchedule cmSchedule) {
- String status = cmSchedule.getStatus();
String changeId = cmSchedule.getTmChangeId();
List<ChangeManagementSchedule> list = map.get(changeId);
if (list == null) {
@@ -302,14 +305,15 @@ public class TmStatusClient {
}
- private void closeTheTicket(Schedule s, ChangeManagementGroup group, String changeId,
- List<ChangeManagementSchedule> list, ClosureCode closureCode, String closingComments) throws CMSException {
+ private void closeTheTicket(Schedule sch, ChangeManagementGroup group, String changeId,
+ List<ChangeManagementSchedule> list, ClosureCode closureCode, String closingComments)
+ throws CMSException {
debug.debug("Closing ticket " + changeId + ":" + closureCode);
try {
- tmClient.closeTicket(s, group, list, changeId, closureCode, closingComments);
+ tmClient.closeTicket(sch, group, list, changeId, closureCode, closingComments);
for (ChangeManagementSchedule cms : list) {
cms.setTmStatus("Closed");
- cmScheduleDAO.save(cms);
+ cmScheduleDao.save(cms);
}
} catch (CMSException e) {
throw e;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/BuildCreateRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/BuildCreateRequest.java
index 0b7c319..8c8cd6f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/BuildCreateRequest.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/BuildCreateRequest.java
@@ -1,27 +1,27 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * 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
- *
+ *
* 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 otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://creativecommons.org/licenses/by/4.0/
- *
+ *
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,13 @@
package org.onap.optf.cmso.ticketmgt.bean;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.io.File;
import java.util.Iterator;
import java.util.List;
@@ -40,14 +47,10 @@ import org.onap.optf.cmso.common.LogMessages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.node.TextNode;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+/**
+ * The Class BuildCreateRequest.
+ */
@Component
public class BuildCreateRequest {
@@ -58,6 +61,9 @@ public class BuildCreateRequest {
// This is for example purposes only ans every provider
// will have unique requirements.
// This assumes multiple VNFs can appear on a single ticket
+ /**
+ * The Enum Variables.
+ */
//
public enum Variables {
vnfList(168), requesterId(50), plannedStartDate(15), plannedEndDate(15), validationStartTime(
@@ -71,19 +77,30 @@ public class BuildCreateRequest {
this.maxLength = max;
}
+ /**
+ * Gets the max length.
+ *
+ * @return the max length
+ */
public int getMaxLength() {
return maxLength;
}
}
- private static EELFLogger log = EELFManager.getInstance().getLogger(BuildCreateRequest.class);
- private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
Environment env;
+ /**
+ * Creates the change record request.
+ *
+ * @param variables the variables
+ * @param assetList the asset list
+ * @param workflowName the workflow name
+ * @return the json node
+ */
public JsonNode createChangeRecordRequest(Map<String, Object> variables, List<TmAsset> assetList,
String workflowName) {
JsonNode rawjson = getYaml("CreateChangeTicket");
@@ -91,24 +108,48 @@ public class BuildCreateRequest {
return json;
}
+ /**
+ * Creates the close cancel change record.
+ *
+ * @param variables the variables
+ * @return the json node
+ */
public JsonNode createCloseCancelChangeRecord(Map<String, Object> variables) {
JsonNode rawjson = getYaml("CloseCancelChangeRecord");
JsonNode json = substituteJson(rawjson, variables);
return json;
}
+ /**
+ * Creates the cancel change record.
+ *
+ * @param variables the variables
+ * @return the json node
+ */
public JsonNode createCancelChangeRecord(Map<String, Object> variables) {
JsonNode rawjson = getYaml("CancelChangeRecord");
JsonNode json = substituteJson(rawjson, variables);
return json;
}
+ /**
+ * Creates the update change record.
+ *
+ * @param variables the variables
+ * @return the json node
+ */
public JsonNode createUpdateChangeRecord(Map<String, Object> variables) {
JsonNode rawjson = getYaml("UpdateChangeRecord");
JsonNode json = substituteJson(rawjson, variables);
return json;
}
+ /**
+ * Creates the get change record.
+ *
+ * @param variables the variables
+ * @return the json node
+ */
public JsonNode createGetChangeRecord(Map<String, Object> variables) {
JsonNode rawjson = getYaml("GetChangeRecord");
JsonNode json = substituteJson(rawjson, variables);
@@ -171,17 +212,27 @@ public class BuildCreateRequest {
}
private boolean isInteger(String name) {
- if (name.equals(Variables.plannedEndDate.toString()))
+ if (name.equals(Variables.plannedEndDate.toString())) {
return true;
- if (name.equals(Variables.plannedStartDate.toString()))
+ }
+ if (name.equals(Variables.plannedStartDate.toString())) {
return true;
- if (name.equals(Variables.actualStartDate.toString()))
+ }
+ if (name.equals(Variables.actualStartDate.toString())) {
return true;
- if (name.equals(Variables.actualEndDate.toString()))
+ }
+ if (name.equals(Variables.actualEndDate.toString())) {
return true;
+ }
return false;
}
+ /**
+ * Gets the yaml.
+ *
+ * @param workflowName the workflow name
+ * @return the yaml
+ */
public JsonNode getYaml(String workflowName) {
JsonNode json = null;
// Get the YAML file for this workflow
diff --git a/cmso-service/src/main/resources/logmessages.properties b/cmso-service/src/main/resources/logmessages.properties
index e339117..cd85191 100644
--- a/cmso-service/src/main/resources/logmessages.properties
+++ b/cmso-service/src/main/resources/logmessages.properties
@@ -57,3 +57,4 @@ UNAUTHORIZED UNAUTHORIZED|Authorization failed.|No resolution needed|No action i
UNAUTHENTICATED UNAUTHENTICATED|Authentication failed.|No resolution needed|No action is required
UNRECOGNIZED_MSO_STATUS UNRECOGNIZED_MSO_STATUS|Unrecognized status returned by MSO {0}|No resolution needed|No action is required
UNABLE_TO_PARSE_MSO_RESPONSE UNABLE_TO_PARSE_MSO_RESPONSE|Unable to parse status message from MSO {0} : {1}|No resolution needed|No action is required
+MISSING_VALID_GROUP_FOR_ELEMENT MISSING_VALID_GROUP_FOR_ELEMENT|Element {0} returned by optimizer has invalid group id|No resolution needed|No action is required
diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/JpaInit.java b/cmso-service/src/test/java/org/onap/optf/cmso/JpaInit.java
new file mode 100644
index 0000000..08d110e
--- /dev/null
+++ b/cmso-service/src/test/java/org/onap/optf/cmso/JpaInit.java
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * ===================================================================
+ * 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.optf.cmso;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.onap.optf.cmso.model.ApprovalType;
+import org.onap.optf.cmso.model.Domain;
+import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
+
+/**
+ * The Class JpaInit.
+ */
+public class JpaInit {
+
+ private static AtomicBoolean initialized = new AtomicBoolean(false);
+
+ /**
+ * Inits the.
+ *
+ * @param entityManager the entity manager
+ */
+ public static void init(TestEntityManager entityManager) {
+ if (initialized.compareAndSet(true, true)) {
+ return;
+ }
+ Domain dom = new Domain();
+ dom.setDomain("ChangeManagement");
+ entityManager.persist(dom);
+ ApprovalType at = new ApprovalType();
+ at.setApprovalCount(1);
+ at.setDomain("ChangeManagement");
+ at.setApprovalType("Tier 2");
+ entityManager.persist(at);
+ entityManager.flush();
+
+ }
+}
diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/JtestHelper.java b/cmso-service/src/test/java/org/onap/optf/cmso/JtestHelper.java
new file mode 100644
index 0000000..f83cd88
--- /dev/null
+++ b/cmso-service/src/test/java/org/onap/optf/cmso/JtestHelper.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START=======================================================================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * ===================================================================
+ * 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.optf.cmso;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Map;
+import java.util.Scanner;
+import org.apache.commons.text.StrSubstitutor;
+
+public class JtestHelper {
+ private static String templatefolder = "src/test/templates" + File.separator;
+
+ /**
+ * Template.
+ *
+ * @param filename the filename
+ * @param values the values
+ * @return the string
+ */
+ public static String template(String filename, Map<String, String> values) {
+ String data = "";
+ Scanner sc = null;
+ try {
+ File tfld = new File(templatefolder + filename);
+ sc = new Scanner(tfld);
+ sc.useDelimiter("\\Z");
+ data = sc.next();
+ StrSubstitutor ss = new StrSubstitutor(values);
+ data = ss.replace(data);
+ } catch (FileNotFoundException e) {
+ data = "";
+ } finally {
+ if (sc != null) {
+ sc.close();
+ }
+ }
+ return data;
+ }
+}
diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java b/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java
new file mode 100644
index 0000000..8070e41
--- /dev/null
+++ b/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * ===================================================================
+ * 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.optf.cmso.service.rs;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class MockHttpServletRequest {
+ public StringBuffer url = new StringBuffer("http://localhost:8089/cmso/v1/ChangeManagement/schedules/");
+ public HttpServletRequest request = mock(HttpServletRequest.class);
+
+ MockHttpServletRequest() {
+
+ when(request.getRequestURL()).thenReturn(url);
+ when(request.getHeader("Authorization")).thenReturn("BasicbTEzODc3OnNjaGVkdWxlci1SMTgwMiE=");
+
+ }
+
+}