package org.jabref.logic.importer.fetcher;

import java.util.Collections;
import java.util.List;

import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.testutils.category.FetcherTest;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@FetcherTest
class CiteSeerTest {

    CiteSeer fetcher;

    @BeforeEach
    void setUp() throws Exception {
        fetcher = new CiteSeer();
    }

    @Test
    void searchByQueryFindsEntry() throws Exception {
        BibEntry expected = new BibEntry();
        expected.setType(StandardEntryType.Misc);
        expected.setField(StandardField.AUTHOR, "Wang Wei and Zhang Pingwen and Zhang Zhifei");
        expected.setField(StandardField.TITLE, "Rigorous Derivation from Landau-de Gennes Theory to Eericksen-leslie Theory");
        expected.setField(StandardField.DOI, "10.1.1.744.5780");

        List<BibEntry> fetchedEntries = fetcher.performSearch("title:Ericksen-Leslie AND venue:q AND ncites:[10 TO 15000]");
        assertEquals(Collections.singletonList(expected), fetchedEntries);
    }

    @Test
    void searchByQueryFindsEntry2() throws Exception {
        BibEntry expected = new BibEntry();
        expected.setType(StandardEntryType.Misc);
        expected.setField(StandardField.AUTHOR, "Lazarus Richard S.");
        expected.setField(StandardField.TITLE, "Coping Theory and Research: Past Present and Future");
        expected.setField(StandardField.DOI, "10.1.1.115.9665");
        expected.setField(StandardField.YEAR, "1993");
        expected.setField(StandardField.JOURNALTITLE, "PSYCHOSOMATIC MEDICINE");

        List<BibEntry> fetchedEntries = fetcher.performSearch("JabRef");
        assertEquals(expected, fetchedEntries.get(4));
    }
}

@@ -687,36 +687,8 @@
 try(
-);%0A        expected.setType(
 Stan
@@ -698,33 +698,32 @@
 dEntryType.Misc)
-;
 %0A        expecte
@@ -711,36 +711,37 @@
 sc)%0A        
-expected.set
+        .with
 Field(Standa
@@ -802,17 +802,16 @@
 Zhifei%22)
-;
 %0A       
@@ -807,36 +807,37 @@
 i%22)%0A        
-expected.set
+        .with
 Field(Standa
@@ -929,17 +929,16 @@
 Theory%22)
-;
 %0A       
@@ -934,36 +934,37 @@
 y%22)%0A        
-expected.set
+        .with
 Field(Standa
@@ -1314,36 +1314,8 @@
 try(
-);%0A        expected.setType(
 Stan
@@ -1333,17 +1333,16 @@
 pe.Misc)
-;
 %0A       
@@ -1338,36 +1338,37 @@
 sc)%0A        
-expected.set
+        .with
 Field(Standa
@@ -1404,26 +1404,26 @@
 ard S.%22)
-;
 %0A
+ 
         
 expected
@@ -1410,36 +1410,36 @@
 %22)%0A         
-expected.set
+       .with
 Field(Standa
@@ -1507,17 +1507,16 @@
 Future%22)
-;
 %0A       
@@ -1512,36 +1512,37 @@
 e%22)%0A        
-expected.set
+        .with
 Field(Standa
@@ -1572,17 +1572,16 @@
 5.9665%22)
-;
 %0A       
@@ -1577,36 +1577,37 @@
 5%22)%0A        
-expected.set
+        .with
 Field(Standa
@@ -1627,17 +1627,16 @@
  %221993%22)
-;
 %0A       
@@ -1640,20 +1640,21 @@
     
-expected.set
+        .with
 Fiel
@@ -1778,14 +1778,27 @@
 ch(%22
-JabRef
+doi:10.1.1.115.9665
 %22);%0A
@@ -1818,24 +1818,50 @@
 tEquals(
+Collections.singletonList(
 expected
 , fetche
@@ -1852,16 +1852,17 @@
 expected
+)
 , fetche
@@ -1873,15 +1873,8 @@
 ries
-.get(4)
 );%0A 

Fix fetcher test: CiteSeerTest