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

com.chutneytesting.action.domain.ActionTemplate Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: 2017-2024 Enedis
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 */

package com.chutneytesting.action.domain;

import com.chutneytesting.action.domain.parameter.Parameter;
import com.chutneytesting.action.domain.parameter.ParameterResolver;
import com.chutneytesting.action.spi.Action;
import java.util.List;
import java.util.Set;

/**
 * Template for creating {@link Action} instances.
* This object exposes all parameters (names and types) needed by a {@link Action} */ public interface ActionTemplate { /** * @return an identifier to link action description in a scenario and its implementation */ String identifier(); /** * @return the class parsed into the current {@link ActionTemplate}. May not be a {@link Action} if adaptation is made to comply to the current SPI. */ Class implementationClass(); /** * @return {@link Parameter}s needed to create an instance of {@link Action} */ Set parameters(); Action create(List parameterResolvers) throws UnresolvableActionParameterException, ActionInstantiationFailureException; default T resolveParameter(List parameterResolvers, Parameter parameter) { return (T) parameterResolvers .stream() .filter(pr -> pr.canResolve(parameter)) .findFirst() .orElseThrow(() -> new UnresolvableActionParameterException(identifier(), parameter)) .resolve(parameter); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy