package mpei.bkm.converters.text2ls;

import junit.framework.TestCase;
import mpei.bkm.converters.UnconvertableException;
import mpei.bkm.model.logic.LSOntology;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

public class Text2LSOntologyTest {

    @Test
    public void testReadOnlyLogicalSentences() throws Exception {
        LSOntology o = loadOntology("steamroller.ls");
        TestCase.assertNotNull(o);
        TestCase.assertEquals(o.getStatements().size(), 20);
    }

    @Test
    public void testReadOnlyDeclarations() throws Exception {
        LSOntology o = loadOntology("Student.ss");
        TestCase.assertNotNull(o);
        TestCase.assertEquals(o.getStatements().size(), 0);
        TestCase.assertEquals(o.getClasses().size(), 5);
        TestCase.assertEquals(o.getBinaryLinks().size(), 7);
    }

    @Test
    public void testReadFullOntology() throws Exception {
        LSOntology o = loadOntology("robots.ls");
        TestCase.assertNotNull(o);
        TestCase.assertEquals(o.getClassesTerms().size(), 8);
        TestCase.assertEquals(o.getBinaryLinksTerms().size(), 1);
        TestCase.assertEquals(o.getStatements().size(), 12);
    }

    @Test
    public void testIncorrectOntology() throws Exception {
        try {
            loadOntology("duplicated_and_undeclared.ss");
        }
        catch (UnconvertableException e) {
            return;
        }
        Assert.fail("Should fail with undeclared and duplicated declarations");
    }

    protected LSOntology loadOntology(String fileName) throws UnconvertableException, IOException {
        String s = FileUtils.readFileToString(
                new File(ClassLoader.getSystemResource(fileName).getFile())
        );
        Text2LSOntology converter = new Text2LSOntology();

        return converter.convert(s);

    }
}

@@ -35,41 +35,8 @@
 s;%0A%0A
-import junit.framework.TestCase;%0A
 impo
@@ -432,32 +432,30 @@
 %22);%0A        
-TestCase
+Assert
 .assertNotNu
@@ -465,32 +465,30 @@
 o);%0A        
-TestCase
+Assert
 .assertEqual
@@ -654,32 +654,30 @@
 %22);%0A        
-TestCase
+Assert
 .assertNotNu
@@ -687,32 +687,30 @@
 o);%0A        
-TestCase
+Assert
 .assertEqual
@@ -745,32 +745,30 @@
 0);%0A        
-TestCase
+Assert
 .assertEqual
@@ -800,32 +800,30 @@
 5);%0A        
-TestCase
+Assert
 .assertEqual
@@ -984,32 +984,30 @@
 %22);%0A        
-TestCase
+Assert
 .assertNotNu
@@ -1017,32 +1017,30 @@
 o);%0A        
-TestCase
+Assert
 .assertEqual
@@ -1077,32 +1077,30 @@
 8);%0A        
-TestCase
+Assert
 .assertEqual
@@ -1149,16 +1149,14 @@
     
-TestCase
+Assert
 .ass

Substitute TestCase for Assert in tests