// Path: bte-core/src/main/java/gr/ekt/bte/core/DataLoader.java
// public interface DataLoader {
//     /**
//      * Loads all the records from the data source and returns them as a
//      * {@link RecordSet}.
//      *
//      * @return A {@link RecordSet} containing all the data in the
//      * data source in the form of {@link Record}s.
//      *
//      * @throws EmptySourceException If the data source does not
//      * contain any data
//      */
//     public RecordSet getRecords() throws MalformedSourceException;
// 
//     /**
//      * Loads records from the data source based on criteria defined by
//      * the {@link DataLoadingSpec} given as argument.
//      * <br>
//      * <br>
//      * The idea is that it might be more efficient to perform some
//      * initial filtering of records at the source, than to define and
//      * run {@link AbstractFilter}s later, for the whole set of
//      * records, that could be big.
//      *
//      * @param spec The criteria on which the initial filtering is
//      * based
//      *
//      * @return A {@link RecordSet} containing data specified by the
//      * argument in the data source in the form of {@link Record}s.
//      *
//      * @throws EmptySourceException If the source does not contain any
//      * data
//      */
//     public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException;
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/core/Record.java
// public interface Record {
//     /**
//        Given the name of a field returns the list of values.
// 
//        @param field The name of the field
//        @return      The list of values of the specified field
//     */
//     public List<Value> getValues(String field);
// 
//     /**
//        Converts this record into a {@link MutableRecord}.
// 
//        @return a {@link MutableRecord} containing the exact same
//        values
//      */
//     public MutableRecord makeMutable();
// 
//     /**
//        Tests whether the record is mutable or not.
// 
//        @return <code>true</code> if the record is mutable
//      */
//     public boolean isMutable();
// 
//     public boolean hasField(String field);
// 
//     public Set<String> getFields();
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/core/RecordSet.java
// public class RecordSet implements Iterable<Record> {
//     private List<Record> records;
// 
//     public RecordSet() {
//         records = new ArrayList<Record>();
//     }
// 
//     public RecordSet(List<Record> records) {
//         records = new ArrayList<Record>(records);
//     }
// 
//     @Override
//     public Iterator<Record> iterator() {
//         return records.iterator();
//     }
// 
//     public void addRecord(Record rec) {
//         // After a talk with kstamatis we decided that records can be
//         // inserted multiple times, therefore there is no way for this
//         // method to fail.
//         records.add(rec);
//     }
// 
//     public List<Record> getRecords() {
//         return records;
//     }
// 
//     public void setRecords(List<Record> records) {
//         this.records = records;
//     }
// 
//     public int size() {
//         return records.size();
//     }
// 
//     public void addAll(RecordSet other_records) {
//         for (Record rec : other_records) {
//             records.add(rec);
//         }
//     }
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/exceptions/MalformedSourceException.java
// public class MalformedSourceException extends Exception {
// 
//     public MalformedSourceException(String message) {
//         super(message);
//     }
// 
//     private static final long serialVersionUID = 1L;
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import gr.ekt.bte.core.DataLoader;
import gr.ekt.bte.core.Record;
import gr.ekt.bte.core.RecordSet;
import gr.ekt.bte.exceptions.MalformedSourceException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
        try {
            DataLoader dl = new CSVDataLoader("src/test/resources/test_data.csv", fields);
            RecordSet recs = dl.getRecords();
            assertEquals(2, recs.size());
            Record rec = recs.getRecords().get(0);
            for (String fl : fields.values()) {
                assert(rec.hasField(fl));
            }
        } catch(MalformedSourceException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testBibTeXLoader() {
        Map<String, String> fields = new HashMap<String, String>();

        fields.put("abstract", "abstract");
        fields.put("acknowledgement", "acknowledgement");
        fields.put("address", "address");
        fields.put("adviser", "adviser");
        fields.put("affiliation", "affiliation");
        fields.put("alttitle", "alttitle");
        fields.put("annote", "annote");
        fields.put("author", "author");
        fields.put("bibdate", "bibdate");
        fields.put("bibsource", "bibsource");
        fields.put("classcodes", "classcodes");
        fields.put("classification", "classification");
        fields.put("CODEN", "CODEN");
// Path: bte-core/src/main/java/gr/ekt/bte/core/DataLoader.java
// public interface DataLoader {
//     /**
//      * Loads all the records from the data source and returns them as a
//      * {@link RecordSet}.
//      *
//      * @return A {@link RecordSet} containing all the data in the
//      * data source in the form of {@link Record}s.
//      *
//      * @throws EmptySourceException If the data source does not
//      * contain any data
//      */
//     public RecordSet getRecords() throws MalformedSourceException;
// 
//     /**
//      * Loads records from the data source based on criteria defined by
//      * the {@link DataLoadingSpec} given as argument.
//      * <br>
//      * <br>
//      * The idea is that it might be more efficient to perform some
//      * initial filtering of records at the source, than to define and
//      * run {@link AbstractFilter}s later, for the whole set of
//      * records, that could be big.
//      *
//      * @param spec The criteria on which the initial filtering is
//      * based
//      *
//      * @return A {@link RecordSet} containing data specified by the
//      * argument in the data source in the form of {@link Record}s.
//      *
//      * @throws EmptySourceException If the source does not contain any
//      * data
//      */
//     public RecordSet getRecords(DataLoadingSpec spec) throws MalformedSourceException;
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/core/Record.java
// public interface Record {
//     /**
//        Given the name of a field returns the list of values.
// 
//        @param field The name of the field
//        @return      The list of values of the specified field
//     */
//     public List<Value> getValues(String field);
// 
//     /**
//        Converts this record into a {@link MutableRecord}.
// 
//        @return a {@link MutableRecord} containing the exact same
//        values
//      */
//     public MutableRecord makeMutable();
// 
//     /**
//        Tests whether the record is mutable or not.
// 
//        @return <code>true</code> if the record is mutable
//      */
//     public boolean isMutable();
// 
//     public boolean hasField(String field);
// 
//     public Set<String> getFields();
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/core/RecordSet.java
// public class RecordSet implements Iterable<Record> {
//     private List<Record> records;
// 
//     public RecordSet() {
//         records = new ArrayList<Record>();
//     }
// 
//     public RecordSet(List<Record> records) {
//         records = new ArrayList<Record>(records);
//     }
// 
//     @Override
//     public Iterator<Record> iterator() {
//         return records.iterator();
//     }
// 
//     public void addRecord(Record rec) {
//         // After a talk with kstamatis we decided that records can be
//         // inserted multiple times, therefore there is no way for this
//         // method to fail.
//         records.add(rec);
//     }
// 
//     public List<Record> getRecords() {
//         return records;
//     }
// 
//     public void setRecords(List<Record> records) {
//         this.records = records;
//     }
// 
//     public int size() {
//         return records.size();
//     }
// 
//     public void addAll(RecordSet other_records) {
//         for (Record rec : other_records) {
//             records.add(rec);
//         }
//     }
// }
// 
// Path: bte-core/src/main/java/gr/ekt/bte/exceptions/MalformedSourceException.java
// public class MalformedSourceException extends Exception {
// 
//     public MalformedSourceException(String message) {
//         super(message);
//     }
// 
//     private static final long serialVersionUID = 1L;
// }


// Path: bte-io/src/test/java/gr/ekt/bteio/loaders/TestLoaders.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import gr.ekt.bte.core.DataLoader;
import gr.ekt.bte.core.Record;
import gr.ekt.bte.core.RecordSet;
import gr.ekt.bte.exceptions.MalformedSourceException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;

        try {
            DataLoader dl = new CSVDataLoader("src/test/resources/test_data.csv", fields);
            RecordSet recs = dl.getRecords();
            assertEquals(2, recs.size());
            Record rec = recs.getRecords().get(0);
            for (String fl : fields.values()) {
                assert(rec.hasField(fl));
            }
        } catch(MalformedSourceException e) {
            fail(e.getMessage());
        }
    }

    @Test
    public void testBibTeXLoader() {
        Map<String, String> fields = new HashMap<String, String>();

        fields.put("abstract", "abstract");
        fields.put("acknowledgement", "acknowledgement");
        fields.put("address", "address");
        fields.put("adviser", "adviser");
        fields.put("affiliation", "affiliation");
        fields.put("alttitle", "alttitle");
        fields.put("annote", "annote");
        fields.put("author", "author");
        fields.put("bibdate", "bibdate");
        fields.put("bibsource", "bibsource");
        fields.put("classcodes", "classcodes");
        fields.put("classification", "classification");
        fields.put("CODEN", "CODEN");
        fields.put("confdate", "confdate");