Back to Repositories

Validating Workflow Task Configuration Properties in conductor-oss

This test suite validates core task configuration functionality in the Conductor OSS workflow definition system. It focuses on verifying task properties like start delays and optional execution flags, ensuring proper initialization and property synchronization.

Test Coverage Overview

The test suite provides targeted coverage for workflow task configuration properties.

Key areas tested include:
  • Start delay configuration and verification
  • Optional task flag settings and validation
  • Task property synchronization between SimpleTask and WorkflowTask objects

Implementation Analysis

The testing approach uses JUnit Jupiter to validate task configuration behavior. Tests employ a clear arrange-act-assert pattern, creating SimpleTask instances, modifying properties, and verifying both direct and transformed WorkflowTask representations maintain consistency.

Framework features utilized include:
  • Static initialization blocks for test setup
  • JUnit 5 assertions for verification
  • Isolated test methods for specific properties

Technical Details

Testing infrastructure includes:
  • JUnit Jupiter test framework
  • Conductor SDK workflow definition classes
  • WorkflowExecutor initialization
  • Task implementation registration

Best Practices Demonstrated

The test suite exemplifies several testing best practices:

  • Single responsibility principle in test methods
  • Clear test naming conventions
  • Proper test isolation
  • Explicit assertion messages
  • Comprehensive property verification

conductor-oss/conductor

java-sdk/src/test/java/com/netflix/conductor/sdk/workflow/def/WorkflowDefTaskTests.java

            
/*
 * Copyright 2022 Conductor Authors.
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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 com.netflix.conductor.sdk.workflow.def;

import org.junit.jupiter.api.Test;

import com.netflix.conductor.common.metadata.workflow.WorkflowTask;
import com.netflix.conductor.sdk.workflow.def.tasks.*;
import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor;

import static org.junit.jupiter.api.Assertions.*;

public class WorkflowDefTaskTests {

    static {
        WorkflowExecutor.initTaskImplementations();
    }

    @Test
    public void testWorkflowDefTaskWithStartDelay() {
        SimpleTask simpleTask = new SimpleTask("task_name", "task_ref_name");
        int startDelay = 5;

        simpleTask.setStartDelay(startDelay);

        WorkflowTask workflowTask = simpleTask.getWorkflowDefTasks().get(0);

        assertEquals(simpleTask.getStartDelay(), workflowTask.getStartDelay());
        assertEquals(startDelay, simpleTask.getStartDelay());
        assertEquals(startDelay, workflowTask.getStartDelay());
    }

    @Test
    public void testWorkflowDefTaskWithOptionalEnabled() {
        SimpleTask simpleTask = new SimpleTask("task_name", "task_ref_name");

        simpleTask.setOptional(true);

        WorkflowTask workflowTask = simpleTask.getWorkflowDefTasks().get(0);

        assertEquals(simpleTask.getStartDelay(), workflowTask.getStartDelay());
        assertEquals(true, simpleTask.isOptional());
        assertEquals(true, workflowTask.isOptional());
    }
}