package com.github.arteam.dropwizard.testing.jdbi;

import com.github.arteam.dropwizard.testing.jdbi.annotations.DataSet;

import java.lang.reflect.Method;

/**
 * Date: 2/1/15
 * Time: 3:24 PM
 *
 * @author Artem Prigoda
 */
public class DataSetInjector {

    private DataMigration dataMigration;

    public DataSetInjector(DataMigration dataMigration) {
        this.dataMigration = dataMigration;
    }

    public void injectData(Method method) {
        DataSet classLevelDataSet = method.getDeclaringClass().getAnnotation(DataSet.class);
        DataSet methodDataSet = method.getAnnotation(DataSet.class);
        DataSet actualDataSet = methodDataSet != null ? methodDataSet : classLevelDataSet;
        if (actualDataSet != null) {
            String scriptLocation = actualDataSet.value();
            dataMigration.executeScript(scriptLocation);
        }
    }

}

@@ -193,220 +193,712 @@
 M%0A *
-%0A * @author Artem Prigoda%0A */%0Apublic class DataSetInjector %7B%0A%0A    private DataMigration dataMigration;%0A%0A    public DataSetInjector(DataMigration dataMigration) %7B%0A        this.dataMigration = dataMigration;%0A    %7D%0A
+ %3Cp/%3E%0A * Component that responsible for injecting test data to methods.%0A * It analyzes test method and classes for %7B@link DataSet%7D annotation%0A * and dispatches locations of the data to %7B@link DataMigration%7D%0A * component.%0A *%0A * @author Artem Prigoda%0A */%0Apublic class DataSetInjector %7B%0A%0A    private DataMigration dataMigration;%0A%0A    public DataSetInjector(DataMigration dataMigration) %7B%0A        this.dataMigration = dataMigration;%0A    %7D%0A%0A    /**%0A     * Inject test data to a method.%0A     *%0A     * If the method or class has %7B@link%7D DataSet annotation, data%0A     * from script from the location specified in the annotation%0A     * will be injected to the DB%0A     *%0A     * @param method current method%0A     */
 %0A   

Add documentation to DataSetInjector