package com.aif.language.sentence;

import com.aif.language.common.ISplitter;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.*;

public class OpenNLPSentenceSplitterTest {
    private static final String MODEL_RESOURCE_PATH = "/opennlp-models/en-sent.bin";

    @Test
    public void testSplit() throws IOException{
        final String inputString = " First sentence. Second sentence.";
        final List<String> expectedResult = Arrays.asList("First sentence.", "Second sentence.");

        ISplitter<String, String> splitter =
                new OpenNLPSentenceSplitter(ClassLoader.class.getResourceAsStream(MODEL_RESOURCE_PATH));

        List<String> actualResult = splitter.split(inputString);

        assertEquals(expectedResult, actualResult);
    }
}

@@ -123,16 +123,44 @@
 eption;%0A
+import java.io.InputStream;%0A
 import j
@@ -589,24 +589,130 @@
 ntence.%22);%0A%0A
+        try(InputStream modelResource = ClassLoader.class.getResourceAsStream(MODEL_RESOURCE_PATH)) %7B%0A    
         ISpl
@@ -744,16 +744,20 @@
 itter =%0A
+    
         
@@ -796,70 +796,29 @@
 ter(
-ClassLoader.class.getResourceAsStream(MODEL_RESOURCE_PATH));%0A%0A
+modelResource);%0A%0A    
     
@@ -887,16 +887,20 @@
         
+    
 assertEq
@@ -939,12 +939,23 @@
 t);%0A    
-%7D
+    %7D%0A    %7D%0A
 %0A%7D%0A

use try-with-resources for auto closing opened input stream