package org.intermine.bio.dataconversion;

/*
 * Copyright (C) 2002-2010 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import java.io.File;
import java.io.StringReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Set;

import org.apache.commons.io.IOUtils;
import org.intermine.dataconversion.ItemsTestCase;
import org.intermine.dataconversion.MockItemWriter;
import org.intermine.metadata.Model;


public class BioPAXConverterTest extends ItemsTestCase
{
    private BioPAXConverter converter;
    private MockItemWriter itemWriter;
    private String TEST_FILE = "Bos taurus.owl";
    private String TAXON_ID = "9913";
    private boolean processDmel = false;
    public BioPAXConverterTest(String arg) {
        super(arg);
    }

    public void testProcess() throws Exception {
        if (processDmel) {
            TEST_FILE = "Drosophila melanogaster.owl";
            TAXON_ID = "7227";
        }

        itemWriter = new MockItemWriter(new HashMap());
        converter = new BioPAXConverter(itemWriter, Model.getInstanceByName("genomic"));

        ClassLoader loader = getClass().getClassLoader();
        String input = IOUtils.toString(loader.getResourceAsStream(TEST_FILE));

        File currentFile = new File(getClass().getClassLoader().getResource(TEST_FILE).toURI());
        converter.setBiopaxDatasourcename("Reactome");
        converter.setBiopaxDatasetname("Reactome data set");
        converter.setCurrentFile(currentFile);
        converter.setBiopaxOrganisms(TAXON_ID);
        converter.process(new StringReader(input));
        converter.close();

        // uncomment to write out a new target items file
        //writeItemsFile(itemWriter.getItems(), "BioPAX-tgt-items.xml");

        Set expected = readItemSet("BioPAXConverterTest_tgt.xml");

        assertEquals(expected, itemWriter.getItems());
    }
}

@@ -388,38 +388,8 @@
 er;%0A
-import java.util.Collections;%0A
 impo
@@ -475,59 +475,8 @@
 ls;%0A
-import org.intermine.dataconversion.ItemsTestCase;%0A
 impo
@@ -519,24 +519,79 @@
 ItemWriter;%0A
+import org.intermine.dataconversion.MockItemsTestCase;%0A
 import org.i
@@ -658,16 +658,20 @@
 extends 
+Mock
 ItemsTes

test fix.