package com.flicklib.service.movie.porthu;

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

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.flicklib.domain.MoviePage;
import com.flicklib.domain.MovieSearchResult;
import com.flicklib.service.HttpSourceLoader;
import com.flicklib.service.SourceLoader;

/**
 * @author zsombor
 * 
 */
public class PorthuLiveFetcherTest {
    SourceLoader loader;
    PorthuFetcher fetcher;

    
    @Before
    public void setUp() throws Exception {
        loader = new HttpSourceLoader(60000);
        fetcher = new PorthuFetcher(loader);
    }
    
    @Test
    public void testPerfectTitleMatch() {
        try {
            List<MovieSearchResult> list = fetcher.search("Indiana Jones and the Kingdom of the Crystal Skull");
            Assert.assertEquals("search result size", 1, list.size());
            MovieSearchResult searchResult = list.get(0);
            Assert.assertNotNull("search result not null", searchResult);
            Assert.assertTrue("search result is an extended search result", searchResult instanceof MoviePage);
            
            MoviePage moviePage = (MoviePage) searchResult;
            
            Assert.assertEquals("title", "Indiana Jones és a kristálykoponya királysága", moviePage.getTitle());
            Assert.assertEquals("alternate title", "Indiana Jones and the Kingdom of the Crystal Skull", moviePage.getAlternateTitle());
            Assert.assertEquals("year", Integer.valueOf(2008), moviePage.getYear());
            Assert.assertNotNull("has plot", moviePage.getPlot());

            
            
            
        } catch (IOException e) {
            e.printStackTrace();
            Assert.fail(e.getMessage());
        }
        
    }
    
    
}

@@ -36,16 +36,646 @@
 porthu;%0A
+/*%0A * This file is part of Flicklib.%0A * %0A * Copyright (C) Zsombor Gegesy%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */
 %0Aimport 
@@ -2236,47 +2236,8 @@
 );%0A%0A
-            %0A            %0A            %0A
     
@@ -2358,23 +2358,9 @@
     
-    %0A    %7D%0A    
+%7D
 %0A   

add licence