aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db-repositories/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-requests-db-repositories/src')
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java33
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OrchestrationTaskTest.java75
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql13
3 files changed, 120 insertions, 1 deletions
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java
new file mode 100644
index 0000000000..1093c79638
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.db.request.data.repository;
+
+import org.onap.so.db.request.beans.OrchestrationTask;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+import java.util.List;
+
+@RepositoryRestResource(collectionResourceRel = "orchestrationTask", path = "orchestrationTask")
+public interface OrchestrationTaskRepository extends JpaRepository<OrchestrationTask, String> {
+
+ public List<OrchestrationTask> findByStatus(@Param("status") String status);
+}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OrchestrationTaskTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OrchestrationTaskTest.java
new file mode 100644
index 0000000000..0b2aae6730
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OrchestrationTaskTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.db.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.request.beans.OrchestrationTask;
+import org.onap.so.db.request.data.repository.OrchestrationTaskRepository;
+import org.onap.so.db.request.exceptions.NoEntityFoundException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import javax.transaction.Transactional;
+import java.util.Date;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class OrchestrationTaskTest {
+
+ @Autowired
+ private OrchestrationTaskRepository repository;
+
+ @Test
+ @Transactional
+ public void timeStampCreated() throws NoEntityFoundException {
+
+ final String testTaskId = "test-task-id";
+ final String testRequestId = "test-request-id";
+ final String testTaskName = "test-task-name";
+ final String testTaskStatus = "test-task-status";
+ final String testIsManual = "test-is-manual";
+ OrchestrationTask task = new OrchestrationTask();
+
+ task.setTaskId(testTaskId);
+ task.setRequestId(testRequestId);
+ task.setName(testTaskName);
+ task.setStatus(testTaskStatus);
+ task.setIsManual(testIsManual);
+ repository.saveAndFlush(task);
+
+ OrchestrationTask found =
+ repository.findById(testTaskId).orElseThrow(() -> new NoEntityFoundException("Cannot Find Task"));
+
+ Date createdTime = found.getCreatedTime();
+ assertNotNull(createdTime);
+ assertEquals(testTaskId, found.getTaskId());
+ assertEquals(testRequestId, found.getRequestId());
+ assertEquals(testTaskName, found.getName());
+ assertEquals(testTaskStatus, found.getStatus());
+ assertEquals(testIsManual, found.getIsManual());
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
index d2b3a71cad..4f6c19f4d0 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
@@ -253,4 +253,15 @@ ALTER TABLE PUBLIC.SITE_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_C PRIMARY KEY(SI
ALTER TABLE PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_7 PRIMARY KEY(DISTRIBUTION_ID);
ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_D PRIMARY KEY(DISTRIBUTION_ID, COMPONENT_NAME);
ALTER TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP ADD CONSTRAINT PUBLIC.CONSTRAINT_6 PRIMARY KEY(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID);
-ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_DE FOREIGN KEY(DISTRIBUTION_ID) REFERENCES PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID) NOCHECK; \ No newline at end of file
+ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_DE FOREIGN KEY(DISTRIBUTION_ID) REFERENCES PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID) NOCHECK;
+
+CREATE TABLE `orchestration_task` (
+ `TASK_ID` varchar(200) NOT NULL,
+ `REQUEST_ID` varchar(200) NOT NULL,
+ `NAME` varchar(200) NOT NULL,
+ `CREATED_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `STATUS` varchar(200) NOT NULL,
+ `IS_MANUAL` varchar(20) NOT NULL,
+ `PARAMS` varchar(20000) DEFAULT NULL,
+ PRIMARY KEY (`TASK_ID`)
+);