org.pragmaticminds.crunch.api.EvalFunctionTestTool Maven / Gradle / Ivy
Show all versions of crunch-api Show documentation
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.pragmaticminds.crunch.api;
import org.pragmaticminds.crunch.api.events.GenericEventHandler;
import org.pragmaticminds.crunch.api.values.dates.Value;
import org.pragmaticminds.crunch.events.GenericEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* This class is used to test {@link EvalFunction} classes for their functionality
*
* Created by Erwin Wagasow on 22.06.2017.
*
* @deprecated Part of the old API
*/
@Deprecated
@SuppressWarnings("squid:S1612") // Use Lambdas for Handler, no method references
public class EvalFunctionTestTool {
private GenericEventHandler eventHandler;
private EvaluationTestToolEvents events;
private EvalFunction evalFunction;
/**
* Constructor which works with {@link EvalFunction} class
*
* @param evalFunctionClass class of the {@link EvalFunction}
* @throws IllegalAccessException occurs on access to private members
* @throws InstantiationException occurs on failing of creation of new instances of the given class
*/
public EvalFunctionTestTool(Class extends EvalFunction> evalFunctionClass) throws IllegalAccessException,
InstantiationException {
this.eventHandler = event -> events.addEvent(event);
// create instance of the evaluation class
evalFunction = evalFunctionClass.newInstance();
}
public EvalFunctionTestTool(EvalFunction evalFunction) {
this.eventHandler = event -> events.addEvent(event);
// create instance of the evaluation class
this.evalFunction = evalFunction;
}
/**
* By calling this method the evaluation is started with the given parameters
*
* @param literals constant values of the evaluation function
* @param channels time stream values of the evaluation function
* @param timestamps time indices of the time stream (channels) values
* @return an Object containing all outputs and results of the execution
*/
public EvaluationTestToolEvents execute(Map literals, List