Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016-2022 chronicle.software
*
* https://chronicle.software
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 net.openhft.chronicle.wire.utils;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.io.IORuntimeException;
import net.openhft.chronicle.core.io.IOTools;
import net.openhft.chronicle.core.onoes.ExceptionHandler;
import net.openhft.chronicle.core.util.ThrowingFunction;
import net.openhft.chronicle.wire.TextMethodTester;
import net.openhft.chronicle.wire.YamlMethodTester;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* The YamlTesterParametersBuilder class facilitates the configuration of parameters for YAML-based testing.
* This class leverages the builder pattern, enabling a fluent and intuitive setup of testing parameters.
* Each method within this class is designed to either set a specific configuration or retrieve a particular value,
* enhancing clarity and simplifying the process of parameter setup.
*/
@Deprecated(/* to be moved in x.27 */)
public class YamlTesterParametersBuilder {
// A function responsible for constructing the test component
private final ThrowingFunction builder;
// Specifies the expected output type for the test
private final Class outClass;
// List of paths indicating where the YAML files are located
private final List paths;
// Additional output classes provided for advanced testing scenarios
private final Set> additionalOutputClasses = new LinkedHashSet<>();
// Array of agitators used to modify or adjust the test parameters
private YamlAgitator[] agitators = {};
// A function that provides a customized exception handling mechanism
private Function exceptionHandlerFunction;
// Flag to determine whether the exception handler function should log the exception or not
private boolean exceptionHandlerFunctionAndLog;
// Predicate to filter which tests to execute
private Predicate testFilter = new ContainsDifferentMessageFilter();
// A function to process and possibly modify the test input
private Function inputFunction;
/**
* Constructor that initializes the builder with a given component builder, output class, and paths specified as a comma-separated string.
*
* @param builder A function responsible for constructing the test component.
* @param outClass Expected output type for the test.
* @param paths Comma-separated string indicating locations of YAML files.
*/
public YamlTesterParametersBuilder(ThrowingFunction builder, Class outClass, String paths) {
this(builder, outClass, Arrays.asList(paths.split(" *, *")));
}
/**
* Constructor that initializes the builder with a given component builder, output class, and list of paths.
*
* @param builder A function responsible for constructing the test component.
* @param outClass Expected output type for the test.
* @param paths List indicating locations of YAML files.
*/
public YamlTesterParametersBuilder(ThrowingFunction builder, Class outClass, List paths) {
this.builder = builder;
this.outClass = outClass;
this.paths = paths;
}
/**
* Sets the agitators used for modifying test parameters.
* This method follows the builder pattern and returns the current instance.
*
* @param agitators Array of YamlAgitator objects.
* @return The current instance of YamlTesterParametersBuilder.
*/
public YamlTesterParametersBuilder agitators(YamlAgitator... agitators) {
this.agitators = agitators;
return this;
}
/**
* Specifies a custom exception handler function for the test.
* This method follows the builder pattern and returns the current instance.
*
* @param exceptionHandlerFunction A function providing custom exception handling.
* @return The current instance of YamlTesterParametersBuilder.
*/
public YamlTesterParametersBuilder exceptionHandlerFunction(Function exceptionHandlerFunction) {
this.exceptionHandlerFunction = exceptionHandlerFunction;
return this;
}
/**
* Constructs and returns a list of test parameters based on YAML configurations.
* This method reads YAML configurations from specified paths, processes them based on various configurations, and
* returns them as test parameters. It also takes into account any defined agitators and combinations.
*
* @return A list of test parameters with each entry containing a path and its associated YamlTester.
*/
public List