Merge "Reorder modifiers"
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / BPMNUtil.java
index c476c65..0bb5186 100644 (file)
@@ -1,6 +1,29 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
 package org.openecomp.mso.bpmn.common;\r
 \r
 import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.assertNull;\r
+import static org.junit.Assert.assertTrue;\r
 import static org.junit.Assert.fail;\r
 import static org.mockito.Matchers.any;\r
 import static org.mockito.Mockito.doAnswer;\r
@@ -45,7 +68,7 @@ public class BPMNUtil {
        }\r
 \r
        @SuppressWarnings("unchecked")\r
-       public static <T extends Object> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {\r
+       public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {\r
                String pID = getProcessInstanceId(processEngineServices,\r
                                processDefinitionID);\r
                assertProcessInstanceFinished(processEngineServices, pID);\r
@@ -56,7 +79,18 @@ public class BPMNUtil {
                            .getValue();\r
                return (T) responseData;\r
        }\r
+\r
+       \r
+       public static void assertAnyProcessInstanceFinished(ProcessEngineServices processEngineServices, String processDefinitionID) {\r
+               String pID = getProcessInstanceId(processEngineServices,\r
+                               processDefinitionID);\r
+               assertNotNull(pID);\r
+           assertTrue(processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count() > 0);\r
+       }\r
        \r
+       public static void assertNoProcessInstance(ProcessEngineServices processEngineServices, String processDefinitionID) {\r
+               assertNull(getProcessInstanceId(processEngineServices, processDefinitionID));\r
+       }\r
        \r
        public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {\r
            assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());\r
@@ -87,7 +121,7 @@ public class BPMNUtil {
 \r
        \r
        private static void buildVariable(String key, String value, Map<String,Object> variableValueType) {\r
-               Map<String, Object> host = new HashMap<String, Object>();\r
+               Map<String, Object> host = new HashMap<>();\r
                host.put("value", value);\r
                host.put("type", "String");\r
                variableValueType.put(key, host);\r
@@ -97,7 +131,7 @@ public class BPMNUtil {
                WorkflowResource workflowResource = new WorkflowResource();\r
                VariableMapImpl variableMap = new VariableMapImpl();\r
 \r
-               Map<String, Object> variableValueType = new HashMap<String, Object>();\r
+               Map<String, Object> variableValueType = new HashMap<>();\r
                for (String key : variables.keySet()) {\r
                        buildVariable(key, variables.get(key), variableValueType);\r
                }\r
@@ -169,7 +203,7 @@ public class BPMNUtil {
                WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();\r
                VariableMapImpl variableMap = new VariableMapImpl();\r
 \r
-               Map<String, Object> variableValueType = new HashMap<String, Object>();\r
+               Map<String, Object> variableValueType = new HashMap<>();\r
                for (String key : variables.keySet()) {\r
                        buildVariable(key, variables.get(key), variableValueType);\r
                }\r