package uk.ac.ebi.quickgo.ff.loader.ontology;

import uk.ac.ebi.quickgo.ff.files.ontology.GOSourceFiles;
import uk.ac.ebi.quickgo.model.ontology.go.GOTerm;
import uk.ac.ebi.quickgo.model.ontology.go.GeneOntology;

import java.io.File;
import java.util.Optional;
import org.junit.Ignore;
import org.junit.Test;

import static junit.framework.TestCase.assertEquals;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * TODO: *HAVE* to enable creating a GOSourceFiles instance without depending on the 50+ source files currently used.
 *
 * For now, this test simply checks one can successfully load
 * a {@link GeneOntology} instance from a directory containing the
 * source files.
 *
 * Created by edd on 11/12/2015.
 */
public class GOLoaderIT {

    //private static final String SOURCE_FILE_DIR = "/home/eddturner/working/quickgo-local/quickgo-data/ff";
    private static final String SOURCE_FILE_DIR = "C:\\Users\\twardell\\Projects\\QuickGo\\data_ontology";

    /**
     * Ignored because it's not portable. Depends on hard-coded path.
     */
    @Ignore @Test
    public void canLoadGOInstance() {
        GOSourceFiles sourceFiles = new GOSourceFiles(new File(SOURCE_FILE_DIR));
        GOLoader goLoader = new GOLoader(sourceFiles);
        Optional<GeneOntology> geneOntologyOptional = goLoader.load();
        assertThat(geneOntologyOptional.isPresent(), is(true));

        //Highly input data specific
        assertEquals(((GOTerm)geneOntologyOptional.get().getTerm("GO:0003774")).getBlacklist().get(0).getMethodId(), "IPR001609|IPR002928");
    }

}

@@ -388,18 +388,118 @@
 est.
-core.Is.is
+Matchers.nullValue;%0Aimport static org.hamcrest.core.Is.is;%0Aimport static org.hamcrest.core.IsNull.notNullValue
 ;%0Aim
@@ -1386,17 +1386,8 @@
     
-Optional%3C
 Gene
@@ -1398,9 +1398,8 @@
 logy
-%3E
  gen
@@ -1407,24 +1407,56 @@
 Ontology
-Optional
+;%0A        try %7B%0A            geneOntology
  = goLoa
@@ -1467,16 +1467,20 @@
 load();%0A
+    
         
@@ -1506,42 +1506,36 @@
 logy
-Optional.isPresent(), is(true
+, is(notNullValue()
 ));%0A%0A
+    
     
@@ -1571,24 +1571,28 @@
 fic%0A        
+ 
+   
 assertEquals
@@ -1617,22 +1617,8 @@
 logy
-Optional.get()
 .get
@@ -1677,32 +1677,146 @@
 d(),
- %22IPR001609%7CIPR002928%22);
+%0A                         %22IPR001609%7CIPR002928%22);%0A        %7D catch (Exception e) %7B%0A            assertThat(e, is(nullValue()));%0A        %7D%0A%0A%0A
 %0A   

Remove use of optional from Ontology file handling.