Back to Repositories

Validating Workflow Definition Task Properties in Conductor-OSS

A comprehensive test suite for validating workflow definition task configurations in the Conductor OSS framework. These tests focus on verifying task properties like start delay and optional execution settings, ensuring proper initialization and configuration of workflow tasks.

Test Coverage Overview

The test suite provides targeted coverage for workflow definition task properties and configurations.

Key areas tested include:
  • Task start delay configuration and validation
  • Optional task execution settings
  • Task reference name and identifier mappings
  • Workflow task property synchronization

Implementation Analysis

The implementation utilizes JUnit Jupiter for unit testing, following a clear and concise testing pattern. Each test case isolates specific task configuration aspects, using SimpleTask implementations to verify property settings and their propagation to WorkflowTask definitions.

Testing patterns include:
  • Direct property comparison testing
  • Task configuration validation
  • Property synchronization verification

Technical Details

Testing infrastructure includes:
  • JUnit Jupiter test framework
  • Conductor SDK workflow definitions
  • WorkflowExecutor initialization
  • SimpleTask and WorkflowTask implementations
  • Static initialization of task implementations

Best Practices Demonstrated

The test suite exemplifies several testing best practices:

  • Clear test method naming conventions
  • Isolated test cases for specific functionality
  • Proper test setup and initialization
  • Direct assertion of expected outcomes
  • Focused scope for each test case

conductor-oss/conductor

conductor-clients/java/conductor-java-sdk/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.SimpleTask;
import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor;

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

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());
    }
}