summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-workflow/src/test/java
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2018-02-20 12:00:10 -0500
committerst782s <statta@research.att.com>2018-02-20 12:00:10 -0500
commit724ff8f8b22d6503ce5070ebc13f6f5fbc48c8cf (patch)
tree063414ae8d035fe9957cba3833661a915c1f8eff /ecomp-sdk/epsdk-workflow/src/test/java
parent20602aa99841048e65a36dc26d8bfc4d6a11fcc9 (diff)
Increase JUNIT Coverage
Issue-ID: PORTAL-136 Change-Id: I2223003924f36043753bef401ed1d8ee87f4a65e Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src/test/java')
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalapp/framework/MockitoTestSuite.java89
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookControllerTest.java66
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestControllerTest.java66
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookControllerTest.java100
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEControllerTest.java187
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentialsTest.java85
-rw-r--r--ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImplTest.java141
-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
16 files changed, 1771 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalapp/framework/MockitoTestSuite.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalapp/framework/MockitoTestSuite.java
new file mode 100644
index 00000000..baac323e
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalapp/framework/MockitoTestSuite.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 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.portalapp.framework;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MockitoTestSuite {
+
+
+ public MockHttpServletRequestWrapper mockedRequest = new MockHttpServletRequestWrapper(
+ Mockito.mock(HttpServletRequest.class));
+ public HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class);
+
+ public MockHttpServletRequestWrapper getMockedRequest() {
+ return mockedRequest;
+ }
+
+ public HttpServletResponse getMockedResponse() {
+ return mockedResponse;
+ }
+
+ public class MockHttpServletRequestWrapper extends HttpServletRequestWrapper {
+
+ HttpSession session = Mockito.mock(HttpSession.class);
+
+ public MockHttpServletRequestWrapper(HttpServletRequest request) {
+ super(request);
+
+ }
+
+ @Override
+ public HttpSession getSession() {
+
+ return session;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create) {
+
+ return session;
+ }
+
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookControllerTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookControllerTest.java
new file mode 100644
index 00000000..bd70a321
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * ============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.rnotebookintegration.controller;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.springframework.web.servlet.ModelAndView;
+
+public class NotebookControllerTest {
+
+ @InjectMocks
+ NotebookController notebookController = new NotebookController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void noteBookTest(){
+ ModelAndView actualModelAndView = new ModelAndView();
+ ModelAndView expectedModelAndView = notebookController.noteBook();
+ assertEquals(expectedModelAndView.getViewName(), actualModelAndView.getViewName());
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestControllerTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestControllerTest.java
new file mode 100644
index 00000000..6045ec75
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/NotebookTestControllerTest.java
@@ -0,0 +1,66 @@
+/*
+ * ============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.rnotebookintegration.controller;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.MockitoAnnotations;
+import org.springframework.web.servlet.ModelAndView;
+
+public class NotebookTestControllerTest {
+
+ @InjectMocks
+ NotebookTestController notebookTestController = new NotebookTestController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void noteBookTest(){
+ ModelAndView actualModelAndView = new ModelAndView();
+ ModelAndView expectedModelAndView = notebookTestController.noteBook();
+ assertEquals(expectedModelAndView.getViewName(), actualModelAndView.getViewName());
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookControllerTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookControllerTest.java
new file mode 100644
index 00000000..62051457
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookControllerTest.java
@@ -0,0 +1,100 @@
+/*
+ * ============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.rnotebookintegration.controller;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+import org.onap.portalsdk.rnotebookintegration.service.RNoteBookIntegrationService;
+
+public class RNoteBookControllerTest {
+
+ @InjectMocks
+ RNoteBookController rNoteBookController = new RNoteBookController();
+
+ @Mock
+ private RNoteBookIntegrationService rNoteBookIntegrationService;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void getrNoteBookIntegrationServiceTest(){
+ RNoteBookIntegrationService actualRNoteBookIntegrationService = rNoteBookIntegrationService;
+ RNoteBookIntegrationService expectedRNoteBookIntegrationService = rNoteBookController.getrNoteBookIntegrationService();
+ rNoteBookController.setrNoteBookIntegrationService(null);
+ assertEquals(actualRNoteBookIntegrationService, expectedRNoteBookIntegrationService);
+ }
+
+ @Test
+ public void getRNotebookCredentialsTokenTest(){
+ rNoteBookController.getRNotebookCredentials(null);
+ }
+
+ @Test
+ public void getRNotebookCredentialsExceptionTest() throws RNotebookIntegrationException{
+ Mockito.when(rNoteBookIntegrationService.getRNotebookCredentials(null));
+ rNoteBookController.getRNotebookCredentials(null);
+ }
+
+ @Test
+ public void getRNotebookCredentialsNotebookExceptionTest() throws RNotebookIntegrationException{
+ RNotebookIntegrationException excp = new RNotebookIntegrationException(RNotebookIntegrationException.ERROR_CODE_TOKEN_EXPIRED);
+ Mockito.when(rNoteBookIntegrationService.getRNotebookCredentials("test")).thenThrow(excp);
+ rNoteBookController.getRNotebookCredentials("test");
+ assertTrue(true);
+ }
+
+ @Test
+ public void getRNotebookCredentialsNotebookExceptionWithoutCodeTest() throws RNotebookIntegrationException{
+ RNotebookIntegrationException excp = new RNotebookIntegrationException("Test");
+ Mockito.when(rNoteBookIntegrationService.getRNotebookCredentials("test")).thenThrow(excp);
+ rNoteBookController.getRNotebookCredentials("test");
+ assertTrue(true);
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEControllerTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEControllerTest.java
new file mode 100644
index 00000000..611f41f1
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/controller/RNoteBookFEControllerTest.java
@@ -0,0 +1,187 @@
+/*
+ * ============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.rnotebookintegration.controller;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hibernate.SessionFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.framework.MockitoTestSuite;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.service.DataAccessServiceImpl;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+import org.onap.portalsdk.rnotebookintegration.service.RNoteBookIntegrationService;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({UserUtils.class, SystemProperties.class})
+public class RNoteBookFEControllerTest {
+
+ @InjectMocks
+ RNoteBookFEController rNoteBookFEController = new RNoteBookFEController();
+
+ @Mock
+ private RNoteBookIntegrationService rNoteBookIntegrationService;
+
+ @Mock
+ private SessionFactory sessionFactory;
+ @InjectMocks
+ private DataAccessServiceImpl dataAccessServiceImpl;
+
+ @Mock
+ private DataAccessService dataAccessService;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ User user = new User();
+
+ @Mock
+ UserUtils userUtils = new UserUtils();
+
+ @Test
+ public void getrNoteBookIntegrationServiceTest() {
+ RNoteBookIntegrationService actualRNoteBookIntegrationService = rNoteBookIntegrationService;
+ RNoteBookIntegrationService expectedRNoteBookIntegrationService = rNoteBookFEController
+ .getrNoteBookIntegrationService();
+ rNoteBookFEController.setrNoteBookIntegrationService(null);
+ assertEquals(actualRNoteBookIntegrationService, expectedRNoteBookIntegrationService);
+ }
+
+ @Test
+ public void saveRNotebookCredentialsExceptionTest() {
+
+ String notebookId = "123";
+ HttpServletRequest request = PowerMockito.mock(HttpServletRequest.class);
+ String value = " { \"key\" : \"value\" }" ;
+
+ Mockito.when(request.getParameter("qparams")).thenReturn(value);
+
+ HttpServletResponse response = new MockHttpServletResponse();
+
+ PowerMockito.mockStatic(UserUtils.class);
+ User user = new User();
+ Mockito.when(UserUtils.getUserSession(request)).thenReturn(user);
+ Mockito.when(dataAccessService.getDomainObject(User.class, user.getId(), null)).thenReturn(user);
+ EcompUser ecUser = new EcompUser();
+ Mockito.when(UserUtils.convertToEcompUser(user)).thenReturn(ecUser);
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.containsProperty(Mockito.anyString())).thenReturn(false);
+
+ rNoteBookFEController.saveRNotebookCredentials(notebookId, request, response);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void saveRNotebookCredentialsTest() {
+
+ String notebookId = "123";
+ HttpServletRequest request = PowerMockito.mock(HttpServletRequest.class);
+ String value = " { \"key\" : \"value\" }" ;
+
+ Mockito.when(request.getParameter("qparams")).thenReturn(value);
+
+ HttpServletResponse response = new MockHttpServletResponse();
+
+ PowerMockito.mockStatic(UserUtils.class);
+ User user = new User();
+ Mockito.when(UserUtils.getUserSession(request)).thenReturn(user);
+ Mockito.when(dataAccessService.getDomainObject(User.class, user.getId(), null)).thenReturn(user);
+ EcompUser ecUser = new EcompUser();
+ Mockito.when(UserUtils.convertToEcompUser(user)).thenReturn(ecUser);
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.containsProperty(Mockito.anyString())).thenReturn(true);
+
+ rNoteBookFEController.saveRNotebookCredentials(notebookId, request, response);
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void saveRNotebookCredentialsCustExceptionTest() {
+
+ String notebookId = "123";
+ HttpServletRequest request = PowerMockito.mock(HttpServletRequest.class);
+ String value = " { \"key\" : \"value\" }" ;
+
+ Mockito.when(request.getParameter("qparams")).thenReturn(value);
+
+ HttpServletResponse response = new MockHttpServletResponse();
+
+ PowerMockito.mockStatic(UserUtils.class);
+ User user = new User();
+ Mockito.when(UserUtils.getUserSession(request)).thenThrow(RNotebookIntegrationException.class);
+ Mockito.when(dataAccessService.getDomainObject(User.class, user.getId(), null)).thenReturn(user);
+ EcompUser ecUser = new EcompUser();
+ Mockito.when(UserUtils.convertToEcompUser(user)).thenReturn(ecUser);
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.containsProperty(Mockito.anyString())).thenReturn(true);
+
+ rNoteBookFEController.saveRNotebookCredentials(notebookId, request, response);
+ Assert.assertTrue(true);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentialsTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentialsTest.java
new file mode 100644
index 00000000..12dc1e69
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/domain/RNoteBookCredentialsTest.java
@@ -0,0 +1,85 @@
+/*
+ * ============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.rnotebookintegration.domain;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class RNoteBookCredentialsTest {
+
+ public RNoteBookCredentials mockRNoteBookCredentials(){
+ RNoteBookCredentials rNoteBookCredentials = new RNoteBookCredentials();
+
+ rNoteBookCredentials.setUserInfo(null);
+ rNoteBookCredentials.setToken("test");
+ rNoteBookCredentials.setCreated(null);
+ rNoteBookCredentials.setCreatedDate(null);
+ rNoteBookCredentials.setNotebookID("test");
+ rNoteBookCredentials.setParameters(null);
+ rNoteBookCredentials.setTokenReadDate(null);
+ rNoteBookCredentials.setUserString("test");
+ rNoteBookCredentials.setParametersString("test");
+
+ return rNoteBookCredentials;
+ }
+
+ @Test
+ public void rNoteBookCredentialsTest(){
+ RNoteBookCredentials rNoteBookCredentials1 = mockRNoteBookCredentials();
+
+ RNoteBookCredentials rNoteBookCredentials = new RNoteBookCredentials();
+ rNoteBookCredentials.setUserInfo(null);
+ rNoteBookCredentials.setToken("test");
+ rNoteBookCredentials.setCreated(null);
+ rNoteBookCredentials.setNotebookID("test");
+ rNoteBookCredentials.setParameters(null);
+ rNoteBookCredentials.setTokenReadDate(null);
+ rNoteBookCredentials.setUserString("test");
+ rNoteBookCredentials.setParametersString("test");
+
+ Assert.assertEquals(rNoteBookCredentials.getUserInfo(), rNoteBookCredentials1.getUserInfo());
+ Assert.assertEquals(rNoteBookCredentials.getToken(), rNoteBookCredentials1.getToken());
+ Assert.assertEquals(rNoteBookCredentials.getCreated(), rNoteBookCredentials1.getCreated());
+ Assert.assertEquals(rNoteBookCredentials.getCreatedDate(), rNoteBookCredentials1.getCreatedDate());
+ Assert.assertEquals(rNoteBookCredentials.getNotebookID(), rNoteBookCredentials1.getNotebookID());
+ Assert.assertEquals(rNoteBookCredentials.getParameters(), rNoteBookCredentials1.getParameters());
+ Assert.assertEquals(rNoteBookCredentials.getTokenReadDate(), rNoteBookCredentials1.getTokenReadDate());
+ Assert.assertEquals(rNoteBookCredentials.getUserString(), rNoteBookCredentials1.getUserString());
+ Assert.assertEquals(rNoteBookCredentials.getParametersString(), rNoteBookCredentials1.getParametersString());
+ }
+}
diff --git a/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImplTest.java b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImplTest.java
new file mode 100644
index 00000000..2a2cfed0
--- /dev/null
+++ b/ecomp-sdk/epsdk-workflow/src/test/java/org/onap/portalsdk/rnotebookintegration/service/RNoteBookIntegrationServiceImplTest.java
@@ -0,0 +1,141 @@
+/*
+ * ============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.rnotebookintegration.service;
+
+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.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.rnotebookintegration.domain.RNoteBookCredentials;
+import org.onap.portalsdk.rnotebookintegration.exception.RNotebookIntegrationException;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class RNoteBookIntegrationServiceImplTest {
+
+ @InjectMocks
+ private RNoteBookIntegrationServiceImpl rnoteBookIntgrServiceImpl;
+
+ @Mock
+ private DataAccessService dataAccessService;
+
+ @Test(expected = RNotebookIntegrationException.class)
+ public void getRNotebookCredentialsNullTokenTest() throws Exception {
+ String token = "Token";
+ RNoteBookCredentials rnoteBookCredentials = new RNoteBookCredentials();
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(rnoteBookCredentials);
+ rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ }
+
+ @Test(expected = RNotebookIntegrationException.class)
+ public void getRNotebookCredentialsEmptyTokenTest() throws Exception {
+ String token = "Token";
+ RNoteBookCredentials rnoteBookCredentials = new RNoteBookCredentials();
+ rnoteBookCredentials.setToken("");
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(rnoteBookCredentials);
+ rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ }
+
+ @Test(expected = RNotebookIntegrationException.class)
+ public void getRNotebookCredentialsDateTest() throws Exception {
+ String token = "Token";
+ RNoteBookCredentials rnoteBookCredentials = new RNoteBookCredentials();
+ rnoteBookCredentials.setToken("123");
+ rnoteBookCredentials.setCreatedDate(new Date());
+ rnoteBookCredentials.setTokenReadDate(new Date());
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(rnoteBookCredentials);
+ rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ }
+
+ @Test
+ public void getRNotebookCredentialsTest() throws Exception {
+ String token = "Token";
+ RNoteBookCredentials rnoteBookCredentials = new RNoteBookCredentials();
+ String json = " { \"managerId\": \"123\", \"firstName\": \"FNAME\" }";
+ rnoteBookCredentials.setToken("123");
+ rnoteBookCredentials.setCreatedDate(new Date());
+ rnoteBookCredentials.setUserString(json);
+
+ String mapJson = " { \"managerId\": \"123\", \"firstName\": \"FNAME\" }";
+ rnoteBookCredentials.setParametersString(mapJson);
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(rnoteBookCredentials);
+ String response = rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ Assert.assertNotNull(response);
+ }
+
+ @Test
+ public void getRNotebookCredentialsJsonTest() throws Exception {
+ String token = "Token";
+ RNoteBookCredentials rnoteBookCredentials = new RNoteBookCredentials();
+ String json = " { \"managerId\": \"123\", test }";
+ rnoteBookCredentials.setToken("123");
+ rnoteBookCredentials.setCreatedDate(new Date());
+ rnoteBookCredentials.setUserString(json);
+
+ rnoteBookCredentials.setParametersString(json);
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(rnoteBookCredentials);
+ String response = rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ Assert.assertNotNull(response);
+ }
+
+ @Test(expected = RNotebookIntegrationException.class)
+ public void getRNotebookCredentialsExpTest() throws Exception {
+ String token = "Token";
+ Mockito.when(dataAccessService.getDomainObject(RNoteBookCredentials.class, token, new HashMap<String, String>())).thenReturn(null);
+ rnoteBookIntgrServiceImpl.getRNotebookCredentials(token);
+ }
+
+ @Test
+ public void saveRNotebookCredentialsTest() throws Exception {
+ String notebookId = "123";
+ EcompUser user = new EcompUser();
+ Map<String, String> params = new HashMap<>();
+ params.put("Key","VALUE");
+ String token = rnoteBookIntgrServiceImpl.saveRNotebookCredentials(notebookId, user, params);
+ Assert.assertNotNull(token);
+ }
+
+}
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();
+ }
+}