Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Fixing errors in start workflow due to npe on priority Integer autobo…
Browse files Browse the repository at this point in the history
…xing introduced in v2.29.1; (#1886)
  • Loading branch information
kishorebanala authored Sep 24, 2020
1 parent c995fc9 commit 155a66e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public String startWorkflow(
Workflow workflow = new Workflow();
workflow.setWorkflowId(workflowId);
workflow.setCorrelationId(correlationId);
workflow.setPriority(priority);
workflow.setPriority(priority == null ? 0 : priority);
workflow.setWorkflowDefinition(workflowDefinition);
workflow.setStatus(WorkflowStatus.RUNNING);
workflow.setParentWorkflowId(parentWorkflowId);
Expand Down Expand Up @@ -1555,7 +1555,7 @@ private boolean rerunWF(String workflowId, String taskId, Map<String, Object> ta
}

// If not found look into sub workflows
if(rerunFromTask == null) {
if(rerunFromTask == null) {
for (Task task : workflow.getTasks()) {
if (task.getTaskType().equalsIgnoreCase(SubWorkflow.NAME)) {
String subWorkflowId = task.getSubWorkflowId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,13 @@
*/
package com.netflix.conductor.core.execution;

import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.maxBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.util.concurrent.Uninterruptibles;
import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.tasks.PollData;
import com.netflix.conductor.common.metadata.tasks.Task;
import com.netflix.conductor.common.metadata.tasks.Task.Status;
import com.netflix.conductor.common.metadata.tasks.TaskDef;
import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.TaskType;
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
import com.netflix.conductor.common.metadata.workflow.WorkflowTask;
Expand Down Expand Up @@ -71,6 +48,11 @@
import com.netflix.conductor.dao.MetadataDAO;
import com.netflix.conductor.dao.QueueDAO;
import com.netflix.conductor.service.ExecutionLockService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.stubbing.Answer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -85,10 +67,29 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.stubbing.Answer;

import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.maxBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
* @author Viren
Expand Down Expand Up @@ -1441,6 +1442,33 @@ public void testUpdateParentWorkflowTask() {
assertEquals(workflowId, argumentCaptor.getAllValues().get(0).getSubWorkflowId());
}

@Test
public void testStartWorkflow() {
WorkflowDef def = new WorkflowDef();
def.setName("test");

Map<String, Object> workflowInput = new HashMap<>();
String externalInputPayloadStoragePath = null;
String correlationId = null;
Integer priority = null;
String parentWorkflowId = null;
String parentWorkflowTaskId = null;
String event = null;
Map<String, String> taskToDomain = null;

workflowExecutor.startWorkflow(def,
workflowInput,
externalInputPayloadStoragePath,
correlationId,
priority,
parentWorkflowId,
parentWorkflowTaskId,
event,
taskToDomain);

verify(executionDAOFacade, times(1)).createWorkflow(any(Workflow.class));
}

private Workflow generateSampleWorkflow() {
//setup
Workflow workflow = new Workflow();
Expand Down

0 comments on commit 155a66e

Please sign in to comment.