All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chutneytesting.design.infra.storage.scenario.compose.ExecutableComposedStepMapper Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.chutneytesting.design.infra.storage.scenario.compose;

import com.chutneytesting.design.domain.scenario.compose.ComposableStep;
import com.chutneytesting.execution.domain.scenario.composed.ExecutableComposedStep;
import com.chutneytesting.execution.domain.scenario.composed.StepImplementation;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.stereotype.Component;

@Component
public class ExecutableComposedStepMapper {

    private final RawImplementationMapper rawImplementationMapper;

    public ExecutableComposedStepMapper(RawImplementationMapper rawImplementationMapper) {
        this.rawImplementationMapper = rawImplementationMapper;
    }

    List composableToExecutable(List composableSteps) {
        return composableSteps.stream()
            .map(this::composableToExecutable)
            .collect(Collectors.toList());
    }

    ExecutableComposedStep composableToExecutable(ComposableStep fs) {
        return ExecutableComposedStep.builder()
            .withName(fs.name)
            .withStrategy(fs.strategy)
            .withSteps(composableToExecutable(fs.steps))
            .withImplementation(toStepImplementation(fs.implementation))
            .withParameters(fs.defaultParameters)
            .withExecutionParameters(fs.executionParameters)
            .build();
    }

    private Optional toStepImplementation(Optional rawImplementation) {
        return rawImplementation.map(rawImplementationMapper::deserialize);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy