aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service/src/test
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/src/test
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/src/test')
-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
3 files changed, 143 insertions, 0 deletions
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=");
+
+ }
+
+}