aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'cmso-service/src/test/java/org/onap')
-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=");
+
+ }
+
+}