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

org.specrunner.objects.IObjectSelector Maven / Gradle / Ivy

The newest version!
/*
    SpecRunner - Acceptance Test Driven Development Tool
    Copyright (C) 2011-2013  Thiago Santos

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see 
 */
package org.specrunner.objects;

import java.util.List;

import org.specrunner.context.IContext;
import org.specrunner.result.IResultSet;
import org.specrunner.util.xom.RowAdapter;

/**
 * Perform object searches.
 * 
 * @author Thiago Santos
 * @param 
 *            The source of selection.
 */
public interface IObjectSelector {

    /**
     * The source for object selection.
     * 
     * @param plugin
     *            The plugin.
     * @param context
     *            The testing context.
     * @return The source.
     * @throws Exception
     *             On selection errors.
     */
    T getSource(AbstractPluginObject plugin, IContext context) throws Exception;

    /**
     * Performs a select on object repository to compare with the reference.
     * 
     * @param plugin
     *            The object plugin information.
     * @param context
     *            The test context.
     * @param instance
     *            The object to be compared with repository version.
     * @param row
     *            The row which was the source for object creation.
     * @param result
     *            The result set.
     * @return The corresponding objects from repository.
     * @throws Exception
     *             On selection errors.
     */
    List select(AbstractPluginObject plugin, IContext context, Object instance, RowAdapter row, IResultSet result) throws Exception;

    /**
     * Release comparison resources. i.e. For Hibernate repositories free
     * sessions in use for comparison.
     * 
     * @throws Exception
     *             On release errors.
     */
    void release() throws Exception;
}