summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow')
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/controllers/WorkflowControllerTest.java193
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImplTest.java168
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/domain/WorkflowScheduleTest.java87
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowLiteTest.java110
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowTest.java110
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJobTest.java63
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistryTest.java99
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImplTest.java115
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowServiceImplTest.java92
9 files changed, 1037 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/controllers/WorkflowControllerTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/controllers/WorkflowControllerTest.java
new file mode 100644
index 00000000..65b2554b
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/controllers/WorkflowControllerTest.java
@@ -0,0 +1,193 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.controllers;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.workflow.models.Workflow;
+import org.onap.portalsdk.workflow.models.WorkflowLite;
+import org.onap.portalsdk.workflow.services.WorkflowService;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+@RunWith(PowerMockRunner.class)
+public class WorkflowControllerTest {
+
+ @InjectMocks
+ private WorkflowController workflowController;
+
+ @Mock
+ private WorkflowService workflowService;
+
+ @Test
+ public void saveCronJob() throws Exception {
+ MockHttpServletRequest request = new MockHttpServletRequest();
+
+ HttpServletResponse response = new MockHttpServletResponse();
+
+ workflowController.saveCronJob(request, response);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void getWorkflowListTest() {
+
+ List<Workflow> workflows = new ArrayList<>();
+ Workflow wfl = new Workflow();
+
+ wfl.setId(123L);
+ wfl.setName("Test");
+ wfl.setDescription("Testing");
+ wfl.setActive(Boolean.TRUE);
+ wfl.setCreated(new Date());
+ User user = new User();
+ user.setFirstName("FNAME");
+ user.setLastName("LNAME");
+
+ wfl.setCreatedBy(user);
+ wfl.setModifiedBy(user);
+ wfl.setLastUpdated(new Date());
+ wfl.setWorkflowKey("KEY");
+ wfl.setRunLink("RLINK");
+ wfl.setSuspendLink("SLINK");
+
+ workflows.add(wfl);
+ Mockito.when(workflowService.getAllWorkflows()).thenReturn(workflows);
+
+ String respone = workflowController.getWorkflowList();
+ Assert.assertNotNull(respone);
+ }
+
+ @Test
+ public void getWorkflowListEmptyTest() {
+
+ List<Workflow> workflows = new ArrayList<>();
+ Workflow wfl = new Workflow();
+
+ wfl.setId(123L);
+ wfl.setName("Test");
+ wfl.setDescription("Testing");
+ wfl.setActive(Boolean.TRUE);
+ wfl.setCreated(new Date());
+
+ wfl.setCreatedBy(null);
+ wfl.setModifiedBy(null);
+ wfl.setLastUpdated(null);
+ wfl.setWorkflowKey("KEY");
+ wfl.setRunLink("RLINK");
+ wfl.setSuspendLink("SLINK");
+
+ workflows.add(wfl);
+ Mockito.when(workflowService.getAllWorkflows()).thenReturn(workflows);
+
+ String respone = workflowController.getWorkflowList();
+ Assert.assertNotNull(respone);
+ }
+
+ @Test
+ public void getWorkflowListNullTest() {
+ Mockito.when(workflowService.getAllWorkflows()).thenReturn(null);
+ String respone = workflowController.getWorkflowList();
+ Assert.assertNotNull(respone);
+ }
+
+ @Test
+ public void addWorkflowTest() {
+ Workflow workflow = new Workflow();
+ HttpServletRequest request = PowerMockito.mock(HttpServletRequest.class);
+ HttpSession mockSession = PowerMockito.mock(HttpSession.class);
+ Mockito.when(request.getSession()).thenReturn(mockSession);
+
+ User user = new User();
+ user.setLoginId("123");
+ Mockito.when(mockSession.getAttribute("user")).thenReturn(user);
+
+ workflowController.addWorkflow(workflow, request);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void editWorkflowTest() {
+ WorkflowLite workflow = new WorkflowLite();
+ HttpServletRequest request = PowerMockito.mock(HttpServletRequest.class);
+ HttpSession mockSession = PowerMockito.mock(HttpSession.class);
+ Mockito.when(request.getSession()).thenReturn(mockSession);
+
+ User user = new User();
+ user.setLoginId("123");
+ Mockito.when(mockSession.getAttribute("user")).thenReturn(user);
+
+ workflowController.editWorkflow(workflow, request);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void removeWorkflowTest() {
+ Long workflowId = 123L;
+ HttpServletRequest request = new MockHttpServletRequest();
+ HttpServletResponse response = new MockHttpServletResponse();
+ workflowController.removeWorkflow(workflowId, request, response);
+ Assert.assertTrue(true);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeAllWorkflows() {
+ workflowController.removeAllWorkflows();
+ }
+
+ @Test
+ public void getWorkflowPartialPageTest(){
+ workflowController.getWorkflowPartialPage();
+ Assert.assertTrue(true);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImplTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImplTest.java
new file mode 100644
index 00000000..2dfa14c2
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/dao/WorkflowDAOImplTest.java
@@ -0,0 +1,168 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.workflow.models.Workflow;
+import org.onap.portalsdk.workflow.models.WorkflowLite;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class WorkflowDAOImplTest {
+
+ @InjectMocks
+ private WorkflowDAOImpl workflowDAOImpl;
+
+ @Mock
+ private SessionFactory sessionFactory;
+
+ @Test
+ public void saveTest() {
+ Workflow workflow = new Workflow();
+ String creatorId = "123";
+ Session session = PowerMockito.mock(Session.class);
+ Mockito.when(sessionFactory.openSession()).thenReturn(session);
+ Transaction tx = PowerMockito.mock(Transaction.class);
+ Mockito.when(session.beginTransaction()).thenReturn(tx);
+
+ Query query = PowerMockito.mock(Query.class);
+ Mockito.when(session.createQuery("from User where loginId =:loginId")).thenReturn(query);
+ User user = new User();
+ List<User> list = new ArrayList<>();
+ list.add(user);
+ Mockito.when(query.list()).thenReturn(list);
+
+ Mockito.when(session.save(workflow)).thenReturn(1L);
+ Mockito.when(session.get(Workflow.class, 1l)).thenReturn(workflow);
+
+ Workflow savedWorkflow = workflowDAOImpl.save(workflow, creatorId);
+
+ Assert.assertNotNull(savedWorkflow);
+ }
+
+ @Test
+ public void saveTestException() {
+ Workflow workflow = new Workflow();
+ String creatorId = "123";
+ Session session = PowerMockito.mock(Session.class);
+ Mockito.when(sessionFactory.openSession()).thenReturn(session);
+ Transaction tx = PowerMockito.mock(Transaction.class);
+ Mockito.when(session.beginTransaction()).thenReturn(tx);
+
+ Query query = PowerMockito.mock(Query.class);
+ Mockito.when(session.createQuery("from User where loginId =:loginId")).thenReturn(query);
+ List<User> list = new ArrayList<>();
+ Mockito.when(query.list()).thenReturn(list);
+
+ Mockito.when(session.save(workflow)).thenReturn(1L);
+ Mockito.when(session.get(Workflow.class, 1l)).thenReturn(workflow);
+
+ Workflow savedWorkflow = workflowDAOImpl.save(workflow, creatorId);
+
+ Assert.assertNotNull(savedWorkflow);
+ }
+
+ @Test
+ public void getWorkflowsTest() {
+
+ Session session = PowerMockito.mock(Session.class);
+ Mockito.when(sessionFactory.openSession()).thenReturn(session);
+
+ List<Workflow> workflows = new ArrayList<>();
+ Workflow workflow = new Workflow();
+ workflow.setId(1L);
+ workflows.add(workflow);
+
+ Query query = PowerMockito.mock(Query.class);
+ Mockito.when(session.createQuery("from Workflow")).thenReturn(query);
+ Mockito.when(query.list()).thenReturn(workflows);
+
+ List<Workflow> list = workflowDAOImpl.getWorkflows();
+ Assert.assertTrue(!list.isEmpty());
+ }
+
+ @Test
+ public void deleteTest() {
+ Long workflowId = 1L;
+ Session session = PowerMockito.mock(Session.class);
+ Mockito.when(sessionFactory.openSession()).thenReturn(session);
+ Transaction tx = PowerMockito.mock(Transaction.class);
+ Mockito.when(session.beginTransaction()).thenReturn(tx);
+ Query query = PowerMockito.mock(Query.class);
+ Mockito.when(session.createQuery("delete from Workflow where id =:id")).thenReturn(query);
+ workflowDAOImpl.delete(workflowId);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void editTest() {
+ WorkflowLite workflowLight = new WorkflowLite();
+ String creatorId = "1234";
+
+ Session session = PowerMockito.mock(Session.class);
+ Mockito.when(sessionFactory.openSession()).thenReturn(session);
+ Transaction tx = PowerMockito.mock(Transaction.class);
+ Mockito.when(session.beginTransaction()).thenReturn(tx);
+ Query query = PowerMockito.mock(Query.class);
+ Mockito.when(session.createQuery("from User where loginId =:loginId")).thenReturn(query);
+
+ User user = new User();
+ List<User> list = new ArrayList<>();
+ list.add(user);
+ Mockito.when(query.list()).thenReturn(list);
+
+ Mockito.when(session.get(Workflow.class, workflowLight.getId())).thenReturn(new Workflow());
+
+ Workflow savedWorkflow = workflowDAOImpl.edit(workflowLight, creatorId);
+ Assert.assertNotNull(savedWorkflow);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/domain/WorkflowScheduleTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/domain/WorkflowScheduleTest.java
new file mode 100644
index 00000000..4ff0f4fc
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/domain/WorkflowScheduleTest.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.domain;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class WorkflowScheduleTest {
+
+ public WorkflowSchedule mockWorkflowSchedule(){
+ WorkflowSchedule workflowSchedule = new WorkflowSchedule();
+
+ workflowSchedule.setId((long) 1);
+ workflowSchedule.setServerUrl("test");
+ workflowSchedule.setWorkflowKey("test");
+ workflowSchedule.setArguments("test");
+ workflowSchedule.setCronDetails("test");
+ workflowSchedule.setEndDateTime(null);
+ workflowSchedule.setStartDateTime(null);
+ workflowSchedule.setRecurrence("test");
+
+ return workflowSchedule;
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void workflowScheduleTest(){
+ WorkflowSchedule workflowSchedule1 = mockWorkflowSchedule();
+
+ WorkflowSchedule workflowSchedule = new WorkflowSchedule();
+ workflowSchedule.setId((long) 1);
+ workflowSchedule.setServerUrl("test");
+ workflowSchedule.setWorkflowKey("test");
+ workflowSchedule.setArguments("test");
+ workflowSchedule.setCronDetails("test");
+ workflowSchedule.setEndDateTime(null);
+ workflowSchedule.setStartDateTime(null);
+ workflowSchedule.setRecurrence("test");
+
+
+ assertEquals(workflowSchedule.getId(), workflowSchedule1.getId());
+ assertEquals(workflowSchedule.getServerUrl(), workflowSchedule1.getServerUrl());
+ assertEquals(workflowSchedule.getWorkflowKey(), workflowSchedule1.getWorkflowKey());
+ assertEquals(workflowSchedule.getArguments(), workflowSchedule1.getArguments());
+ assertEquals(workflowSchedule.getCronDetails(), workflowSchedule1.getCronDetails());
+ assertEquals(workflowSchedule.getEndDateTime(), workflowSchedule1.getEndDateTime());
+ assertEquals(workflowSchedule.getStartDateTime(), workflowSchedule1.getStartDateTime());
+ assertEquals(workflowSchedule.getRecurrence(), workflowSchedule1.getRecurrence());
+ assertEquals(workflowSchedule.getSerialversionuid(), workflowSchedule1.getSerialversionuid());
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowLiteTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowLiteTest.java
new file mode 100644
index 00000000..e8d3667e
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowLiteTest.java
@@ -0,0 +1,110 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.models;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class WorkflowLiteTest {
+
+ public WorkflowLite mockWorkflowLite(){
+ WorkflowLite workflowLite = new WorkflowLite();
+
+ workflowLite.setId((long) 1);
+ workflowLite.setName("test");
+ workflowLite.setWorkflowKey("test");
+ workflowLite.setDescription("test");
+ workflowLite.setCreated("test");
+ workflowLite.setCreatedBy("test");
+ workflowLite.setModifiedBy("test");
+ workflowLite.setLastUpdated("test");
+ workflowLite.setActive("test");
+ workflowLite.setRunLink("test");
+ workflowLite.setSuspendLink("test");
+ workflowLite.setModifiedLink("test");
+
+ return workflowLite;
+ }
+
+ @Test
+ public void workflowLiteTest(){
+ WorkflowLite workflowLite1 = mockWorkflowLite();
+
+ WorkflowLite workflowLite = new WorkflowLite();
+
+ workflowLite.setId((long) 1);
+ workflowLite.setName("test");
+ workflowLite.setWorkflowKey("test");
+ workflowLite.setDescription("test");
+ workflowLite.setCreated("test");
+ workflowLite.setCreatedBy("test");
+ workflowLite.setModifiedBy("test");
+ workflowLite.setLastUpdated("test");
+ workflowLite.setActive("test");
+ workflowLite.setRunLink("test");
+ workflowLite.setSuspendLink("test");
+ workflowLite.setModifiedLink("test");
+
+ assertEquals(workflowLite.getId(), workflowLite1.getId());
+ assertEquals(workflowLite.getName(), workflowLite1.getName());
+ assertEquals(workflowLite.getWorkflowKey(), workflowLite1.getWorkflowKey());
+ assertEquals(workflowLite.getDescription(), workflowLite1.getDescription());
+ assertEquals(workflowLite.getCreated(), workflowLite1.getCreated());
+ assertEquals(workflowLite.getCreatedBy(), workflowLite1.getCreatedBy());
+ assertEquals(workflowLite.getModifiedBy(), workflowLite1.getModifiedBy());
+ assertEquals(workflowLite.getLastUpdated(), workflowLite1.getLastUpdated());
+ assertEquals(workflowLite.getActive(), workflowLite1.getActive());
+ assertEquals(workflowLite.getRunLink(), workflowLite1.getRunLink());
+ assertEquals(workflowLite.getSuspendLink(), workflowLite1.getSuspendLink());
+ assertEquals(workflowLite.getModifiedLink(), workflowLite1.getModifiedLink());
+ }
+
+ @Test
+ public void hashCodeTest(){
+ WorkflowLite workflowLite = mockWorkflowLite();
+ assertNotNull(workflowLite.hashCode());
+ }
+
+ @Test
+ public void equalsTest(){
+ WorkflowLite workflowLite = mockWorkflowLite();
+ WorkflowLite workflowLite1 = new WorkflowLite();
+ assertEquals(false, workflowLite.equals(workflowLite1));
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowTest.java
new file mode 100644
index 00000000..c0e988e1
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/models/WorkflowTest.java
@@ -0,0 +1,110 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.models;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.NameValueId;
+
+public class WorkflowTest {
+
+ public Workflow mockWorkflow(){
+ Workflow workflow = new Workflow();
+
+ workflow.setId((long) 1);
+ workflow.setName("test");
+ workflow.setWorkflowKey("test");
+ workflow.setDescription("test");
+ workflow.setCreated(null);
+ workflow.setCreatedBy(null);
+ workflow.setLastUpdated(null);
+ workflow.setModifiedBy(null);
+ workflow.setActive(false);
+ workflow.setRunLink("test");
+ workflow.setSuspendLink("test");
+ workflow.setModifiedLink("test");
+
+ return workflow;
+ }
+
+ @Test
+ public void workflowTest(){
+ Workflow workflow1 = mockWorkflow();
+
+ Workflow workflow = new Workflow();
+ workflow.setId((long) 1);
+ workflow.setName("test");
+ workflow.setWorkflowKey("test");
+ workflow.setDescription("test");
+ workflow.setCreated(null);
+ workflow.setCreatedBy(null);
+ workflow.setLastUpdated(null);
+ workflow.setModifiedBy(null);
+ workflow.setActive(false);
+ workflow.setRunLink("test");
+ workflow.setSuspendLink("test");
+ workflow.setModifiedLink("test");
+
+ assertEquals(workflow.getId(), workflow1.getId());
+ assertEquals(workflow.getName(), workflow1.getName());
+ assertEquals(workflow.getWorkflowKey(), workflow1.getWorkflowKey());
+ assertEquals(workflow.getDescription(), workflow1.getDescription());
+ assertEquals(workflow.getCreated(), workflow1.getCreated());
+ assertEquals(workflow.getCreatedBy(), workflow1.getCreatedBy());
+ assertEquals(workflow.getLastUpdated(), workflow1.getLastUpdated());
+ assertEquals(workflow.getModifiedBy(), workflow1.getModifiedBy());
+ assertEquals(workflow.getActive(), workflow1.getActive());
+ assertEquals(workflow.getRunLink(), workflow1.getRunLink());
+ assertEquals(workflow.getSuspendLink(), workflow1.getSuspendLink());
+ assertEquals(workflow.getModifiedLink(), workflow1.getModifiedLink());
+ }
+
+ @Test
+ public void hashCodeTest(){
+ Workflow workflow1 = mockWorkflow();
+ assertNotNull(workflow1.hashCode());
+ }
+
+ @Test
+ public void equalsTest(){
+ Workflow workflow1 = mockWorkflow();
+ Workflow workflow = new Workflow();
+ assertEquals(false, workflow.equals(workflow1));
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJobTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJobTest.java
new file mode 100644
index 00000000..2bcd4235
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleJobTest.java
@@ -0,0 +1,63 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.scheduler;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+
+@RunWith(PowerMockRunner.class)
+public class WorkFlowScheduleJobTest {
+
+ @InjectMocks
+ private WorkFlowScheduleJob workFlowScheduleJob;
+
+ @Test(expected = RuntimeException.class)
+ public void executeInternalTest() throws Exception {
+ JobExecutionContext context = Mockito.mock(JobExecutionContext.class);
+ JobDataMap jobMap = Mockito.mock(JobDataMap.class);
+ Mockito.when(context.getMergedJobDataMap()).thenReturn(jobMap);
+ Mockito.when(jobMap.get("serverUrl")).thenReturn("URL");
+ Mockito.when(jobMap.get("workflowKey")).thenReturn("Workflow");
+ workFlowScheduleJob.executeInternal(context);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistryTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistryTest.java
new file mode 100644
index 00000000..8a33aec3
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/scheduler/WorkFlowScheduleRegistryTest.java
@@ -0,0 +1,99 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.scheduler;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.quartz.JobDetail;
+import org.quartz.JobKey;
+import org.springframework.scheduling.quartz.JobDetailFactoryBean;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({JobKey.class})
+public class WorkFlowScheduleRegistryTest {
+
+ @InjectMocks
+ private WorkFlowScheduleRegistry workFlowScheduleRegistry;
+
+ @Test
+ public void jobDetailFactoryBeanTest() {
+ Map<String, ?> contextInfoMap = new HashMap<>();
+ JobDetailFactoryBean jobDetailFactory = workFlowScheduleRegistry.jobDetailFactoryBean(contextInfoMap);
+ Assert.assertNotNull(jobDetailFactory);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void cronTriggerFactoryBeanTest() throws Exception {
+ JobDetailFactoryBean jobDetailFactory = PowerMockito.mock(JobDetailFactoryBean.class);
+ JobDetail mockObj = PowerMockito.mock(JobDetail.class);
+ JobKey keyObj = PowerMockito.mock(JobKey.class);
+
+ Mockito.when(jobDetailFactory.getObject()).thenReturn(mockObj);
+ Mockito.when(mockObj.getKey()).thenReturn(keyObj);
+ Mockito.when(keyObj.getName()).thenReturn("Test");
+ Long id = 123L;
+ String cronExpression = "0 * * * * ? *";
+ Date startDateTime = new Date();
+ Date enddatetime = new Date();
+
+ workFlowScheduleRegistry.cronTriggerFactoryBean(jobDetailFactory, id, cronExpression, startDateTime, enddatetime);
+ }
+
+ @Test(expected = ParseException.class)
+ public void setUpTriggerTest() throws Exception {
+ Long wfId = 123L;
+ String serverUrl = "URL";
+ String workflowKey = "Key";
+ String arguments ="";
+ String startdatetimecron = "today";
+ Date startDateTime = new Date();
+ Date enddatetime = new Date();
+ workFlowScheduleRegistry.setUpTrigger(wfId, serverUrl, workflowKey, arguments, startdatetimecron, startDateTime, enddatetime);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImplTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImplTest.java
new file mode 100644
index 00000000..846a994b
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImplTest.java
@@ -0,0 +1,115 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.SessionFactory;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.workflow.dao.WorkflowDAO;
+import org.onap.portalsdk.workflow.domain.WorkflowSchedule;
+import org.onap.portalsdk.workflow.scheduler.WorkFlowScheduleRegistry;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.context.ApplicationContext;
+
+
+@RunWith(PowerMockRunner.class)
+public class WorkflowScheduleServiceImplTest {
+
+ @Mock
+ private SessionFactory sessionFactory;
+
+ @Mock
+ private WorkflowDAO workflowDAO;
+
+ @Mock
+ private WorkflowScheduleService workflowScheduleService;
+
+ @Mock
+ private WorkFlowScheduleRegistry workflowRegistry;
+
+ @Mock
+ private ApplicationContext appContext;
+
+ @Mock
+ private DataAccessService dataAccessService;
+
+ @InjectMocks
+ private WorkflowScheduleServiceImpl workflowScheduleServiceImpl;
+
+ @Test
+ public void findAllTest(){
+ workflowScheduleServiceImpl.findAll();
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void saveWorkflowScheduleTest(){
+ WorkflowSchedule ws = new WorkflowSchedule();
+ workflowScheduleServiceImpl.saveWorkflowSchedule(ws);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void triggerWorkflowSchedulingTest() {
+ WorkflowSchedule ws = new WorkflowSchedule();
+
+ List<WorkflowSchedule> allWorkflows = new ArrayList<>();
+ allWorkflows.add(ws);
+ Mockito.when(dataAccessService.executeQuery(Mockito.anyString(), Mockito.anyMap())).thenReturn(allWorkflows);
+
+ workflowScheduleServiceImpl.triggerWorkflowScheduling();
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void getWorkflowScheduleByKey() {
+ Long key = 123L;
+ WorkflowSchedule ws = new WorkflowSchedule();
+ Mockito.when(dataAccessService.getDomainObject(WorkflowSchedule.class, key, null)).thenReturn(ws);
+ WorkflowSchedule workflowSchedule = workflowScheduleServiceImpl.getWorkflowScheduleByKey(key);
+ Assert.assertNotNull(workflowSchedule);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowServiceImplTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowServiceImplTest.java
new file mode 100644
index 00000000..ce884d90
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/workflow/services/WorkflowServiceImplTest.java
@@ -0,0 +1,92 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.workflow.services;
+
+import org.hibernate.SessionFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.portalsdk.workflow.dao.WorkflowDAO;
+import org.onap.portalsdk.workflow.domain.WorkflowSchedule;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class WorkflowServiceImplTest {
+
+ @Mock
+ private SessionFactory sessionFactory;
+
+ @Mock
+ private WorkflowDAO workflowDAO;
+
+ @Mock
+ private WorkflowScheduleService workflowScheduleService;
+
+ @InjectMocks
+ private WorkflowServiceImpl workflowServiceImpl;
+
+ @Test
+ public void saveCronJobTest(){
+ WorkflowSchedule workflowSchedule = new WorkflowSchedule();
+ // mockedSession = Mockito.mock(Session.class);
+ // Mockito.when(sessionFactory.getCurrentSession()).thenReturn(mockedSession);
+ // Mockito.when(mockedSession.get(DomainVo.class, id)).thenReturn(domainVo);
+ workflowServiceImpl.saveCronJob(workflowSchedule);
+ }
+
+ @Test
+ public void addWorkflowTest(){
+ workflowServiceImpl.addWorkflow(null, null);
+ }
+
+ @Test
+ public void editWorkflowTest(){
+ workflowServiceImpl.editWorkflow(null, null);
+ }
+
+ @Test
+ public void deleteWorkflowTest(){
+ workflowServiceImpl.deleteWorkflow(null);
+ }
+
+ @Test
+ public void getAllWorkflowsTest(){
+ workflowServiceImpl.getAllWorkflows();
+ }
+}