package edu.mit.civic.clavin;

import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.List;

import org.junit.Test;

import com.berico.clavin.resolver.ResolvedLocation;
import com.berico.clavin.util.TextUtils;

import edu.mit.civic.clavin.server.ParseManager;

/**
 */
public class ArticleTest {
 
    @Test
    public void testMinnesotaExample() throws Exception {
        File inputFile = new File("src/test/resources/sample-docs/minnesota.txt");
        String inputString = TextUtils.fileToString(inputFile);
        List<ResolvedLocation> results = ParseManager.locateRaw(inputString);
        assertTrue(resultsContainsPlaceId(results, 5037779));   // has Minnesota
    }

    @Test
    public void testUsExample() throws Exception {
        File inputFile = new File("src/test/resources/sample-docs/speech.txt");
        String inputString = TextUtils.fileToString(inputFile);
        List<ResolvedLocation> results = ParseManager.locateRaw(inputString);
        assertTrue(resultsContainsPlaceId(results, 5037779));   // has Minnesota
        assertTrue(resultsContainsPlaceId(results, 1816670));   // has city of Beijing
    }

    @Test
    public void testCountryExample() throws Exception {
        File inputFile = new File("src/test/resources/sample-docs/multi-country.txt");
        String inputString = TextUtils.fileToString(inputFile);
        List<ResolvedLocation> results = ParseManager.locateRaw(inputString);
        assertTrue(resultsContainsPlaceId(results, 1814991));   // country of China
        assertTrue(resultsContainsPlaceId(results, 1269750));   // country of India
        assertTrue(resultsContainsPlaceId(results, 2077456));   // country of Australia
    }

    private boolean resultsContainsPlaceId(List<ResolvedLocation> results, int placeId){
        for(ResolvedLocation location: results){
            if(location.getPlace().getId()==placeId){
                return true;
            }
        }
        return false;
    }
    
}
@@ -318,16 +318,308 @@
 est %7B%0A %0A
+    private static final int STATUE_OF_MINNESOTA = 5037779;%0A    private static final int CITY_OF_BEIJING = 1816670;%0A    private static final int COUNTRY_OF_CHINA = 1814991;%0A    private static final int COUNTRY_OF_INDIA = 1269750;%0A    private static final int COUNTRY_OF_AUSTRALIA = 2077456;%0A%0A
     @Tes
@@ -612,32 +612,32 @@
 456;%0A%0A    @Test%0A
-
     public void 
@@ -958,37 +958,30 @@
 ts, 
-5037779));   // has Minnesota
+STATUE_OF_MINNESOTA));
 %0A   
@@ -1322,37 +1322,30 @@
 ts, 
-5037779));   // has Minnesota
+STATUE_OF_MINNESOTA));
 %0A   
@@ -1396,43 +1396,26 @@
 ts, 
-1816670));   // has city of Beijing
+CITY_OF_BEIJING));
 %0A   
@@ -1768,40 +1768,27 @@
 ts, 
-1814991));   // country of China
+COUNTRY_OF_CHINA));
 %0A   
@@ -1839,40 +1839,27 @@
 ts, 
-1269750));   // country of India
+COUNTRY_OF_INDIA));
 %0A   
@@ -1910,44 +1910,31 @@
 ts, 
-2077456));   // country of Australia
+COUNTRY_OF_AUSTRALIA));
 %0A   

use constants in test case