package net.sf.jabref.model.database;

import net.sf.jabref.model.entry.BibLatexEntryTypes;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.BibtexEntryTypes;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.*;

public class BibDatabaseTypeDetectionTest {
    @Test
    public void detectBiblatexOnly() {
        Collection<BibEntry> entries = Arrays.asList(new BibEntry("someid", BibLatexEntryTypes.MVBOOK));

        assertEquals(BibDatabaseType.BIBLATEX, BibDatabaseTypeDetection.inferType(entries));
    }

    @Test
    public void detectBiblatexFieldBased() {
        BibEntry entry = new BibEntry("someid", BibtexEntryTypes.ARTICLE);
        entry.setField("translator", "Stefan Kolb");
        Collection<BibEntry> entries = Arrays.asList(entry);

        assertEquals(BibDatabaseType.BIBLATEX, BibDatabaseTypeDetection.inferType(entries));
    }

    @Test
    public void detectBibtexFieldBased() {
        BibEntry entry = new BibEntry("someid", BibtexEntryTypes.ARTICLE);
        entry.setField("journal", "IEEE Trans. Services Computing");
        Collection<BibEntry> entries = Arrays.asList(entry);

        assertEquals(BibDatabaseType.BIBTEX, BibDatabaseTypeDetection.inferType(entries));
    }

    @Test
    public void detectUndistinguishableAsBibtex() {
        BibEntry entry = new BibEntry("someid", BibtexEntryTypes.ARTICLE);
        entry.setField("title", "My cool paper");
        Collection<BibEntry> entries = Arrays.asList(entry);

        assertEquals(BibDatabaseType.BIBTEX, BibDatabaseTypeDetection.inferType(entries));
    }
}
@@ -190,24 +190,102 @@
 ort 
-org.junit.Test;%0A
+net.sf.jabref.model.entry.CustomEntryType;%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayList;
 %0Aimp
@@ -1613,32 +1613,373 @@
 asList(entry);%0A%0A
+        assertEquals(BibDatabaseType.BIBTEX, BibDatabaseTypeDetection.inferType(entries));%0A    %7D%0A%0A    @Test%0A    public void detectUnknownTypeAsBibtex() %7B%0A        BibEntry entry = new BibEntry(%22someid%22, new CustomEntryType(%22unknowntype%22, new ArrayList%3C%3E(0), new ArrayList%3C%3E(0)));%0A        Collection%3CBibEntry%3E entries = Arrays.asList(entry);%0A%0A
         assertEq

Add test for unknown custom entry types