package net.sf.jabref.model.entry;


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

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.importer.fileformat.BibtexParser;

import java.util.ArrayList;
import java.util.List;

public class BibtexEntryTests {

    private BibtexEntry entry;


    @Before
    public void setup() {
        Globals.prefs = JabRefPreferences.getInstance();
    }

    @Test
    public void testDefaultConstructor() {
        entry = new BibtexEntry();
    }

    @Test
    public void testGetPublicationDate() {

        Assert.assertEquals("2003-02",
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, year = {2003}, month = #FEB# }"))
                        .getPublicationDate());

        Assert.assertEquals("2003-03",
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, year = {2003}, month = 3 }")).getPublicationDate());

        Assert.assertEquals("2003",
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, year = {2003}}")).getPublicationDate());

        Assert.assertEquals(null,
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, month = 3 }")).getPublicationDate());

        Assert.assertEquals(null,
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, author={bla}}")).getPublicationDate());

        Assert.assertEquals("2003-12",
                (BibtexParser.singleFromString("@ARTICLE{HipKro03, year = {03}, month = #DEC# }"))
                        .getPublicationDate());

    }

    @Test
    public void testAllFieldsPresentDefault() {
        BibtexEntry e = new BibtexEntry("id", BibtexEntryTypes.ARTICLE);
        e.setField("author", "abc");
        e.setField("title", "abc");
        e.setField("journal", "abc");
        List<String> requiredFields = new ArrayList<>();

        requiredFields.add("author");
        requiredFields.add("title");
        Assert.assertTrue(e.allFieldsPresent(requiredFields, null));

        requiredFields.add("year");
        Assert.assertFalse(e.allFieldsPresent(requiredFields, null));
    }

    @Test
    public void testAllFieldsPresentOr() {
        BibtexEntry e = new BibtexEntry("id", BibtexEntryTypes.ARTICLE);
        e.setField("author", "abc");
        e.setField("title", "abc");
        e.setField("journal", "abc");
        List<String> requiredFields = new ArrayList<>();

        // XOR required
        requiredFields.add("journal/year");
        Assert.assertTrue(e.allFieldsPresent(requiredFields, null));

        requiredFields.add("year/address");
        Assert.assertFalse(e.allFieldsPresent(requiredFields, null));
    }

    @Test
    public void testhasAllRequiredFields() {
        BibtexEntry e = new BibtexEntry("id", BibtexEntryTypes.ARTICLE);
        e.setField("author", "abc");
        e.setField("title", "abc");
        e.setField("journal", "abc");

        Assert.assertFalse(e.hasAllRequiredFields(null));

        e.setField("year", "2015");
        Assert.assertTrue(e.hasAllRequiredFields(null));
    }
}

@@ -317,42 +317,8 @@
 ts %7B
-%0A%0A    private BibtexEntry entry;%0A%0A
 %0A   
@@ -477,16 +477,28 @@
         
+BibtexEntry 
 entry = 
@@ -576,17 +576,16 @@
 ate() %7B%0A
-%0A
         
@@ -1534,25 +1534,24 @@
 ionDate());%0A
-%0A
     %7D%0A%0A    @
@@ -1563,37 +1563,33 @@
     public void 
-testA
+a
 llFieldsPresentD
@@ -2129,13 +2129,9 @@
 oid 
-testA
+a
 llFi
@@ -2651,32 +2651,32 @@
    %7D%0A%0A    @Test%0A
+
     public void 
@@ -2675,20 +2675,16 @@
 ic void 
-test
 hasAllRe

Rename test methods