azkaban-aplcache

Use TestUtils#createExecutableFlow in the QueuedExecutionsTest

9/18/2017 2:21:09 PM

Details

diff --git a/azkaban-common/src/test/java/azkaban/executor/QueuedExecutionsTest.java b/azkaban-common/src/test/java/azkaban/executor/QueuedExecutionsTest.java
index ce5b34c..f30a4fc 100644
--- a/azkaban-common/src/test/java/azkaban/executor/QueuedExecutionsTest.java
+++ b/azkaban-common/src/test/java/azkaban/executor/QueuedExecutionsTest.java
@@ -1,40 +1,38 @@
+/*
+ * Copyright 2017 LinkedIn Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
 package azkaban.executor;
 
-import azkaban.flow.Flow;
-import azkaban.project.Project;
-import azkaban.utils.JSONUtils;
 import azkaban.utils.Pair;
 import azkaban.utils.TestUtils;
-import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class QueuedExecutionsTest {
 
-  private File getFlowDir(final String flow) {
-    return TestUtils.getFlowDir("exectest1", flow);
-  }
-
   /*
    * Helper method to create an (ExecutionReference, ExecutableFlow) from
    * serialized description
    */
   private Pair<ExecutionReference, ExecutableFlow> createExecutablePair(
       final String flowName, final int execId) throws IOException {
-    final File jsonFlowFile = getFlowDir(flowName);
-    final HashMap<String, Object> flowObj =
-        (HashMap<String, Object>) JSONUtils.parseJSONFromFile(jsonFlowFile);
-
-    final Flow flow = Flow.flowFromObject(flowObj);
-    final Project project = new Project(1, "flow");
-    final HashMap<String, Flow> flowMap = new HashMap<>();
-    flowMap.put(flow.getId(), flow);
-    project.setFlows(flowMap);
-    final ExecutableFlow execFlow = new ExecutableFlow(project, flow);
+    final ExecutableFlow execFlow = TestUtils.createExecutableFlow("exectest1", flowName);
     execFlow.setExecutionId(execId);
     final ExecutionReference ref = new ExecutionReference(execId);
     return new Pair<>(ref, execFlow);
diff --git a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
index 6aae322..a16e5f6 100644
--- a/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
+++ b/azkaban-common/src/test/java/azkaban/utils/TestUtils.java
@@ -32,10 +32,6 @@ import java.util.HashMap;
  */
 public class TestUtils {
 
-  public static File getFlowDir(final String projectName, final String flow) {
-    return ExecutionsTestUtil.getFlowFile(projectName, flow + ".flow");
-  }
-
   public static User getTestUser() {
     return new User("testUser");
   }
@@ -43,7 +39,7 @@ public class TestUtils {
   /* Helper method to create an ExecutableFlow from serialized description */
   public static ExecutableFlow createExecutableFlow(final String projectName,
       final String flowName) throws IOException {
-    final File jsonFlowFile = getFlowDir(projectName, flowName);
+    final File jsonFlowFile = ExecutionsTestUtil.getFlowFile(projectName, flowName + ".flow");
     final HashMap<String, Object> flowObj =
         (HashMap<String, Object>) JSONUtils.parseJSONFromFile(jsonFlowFile);