Skip to content

Commit

Permalink
Make test for journaltitle and location more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Dec 13, 2016
1 parent d38bd97 commit 7b77d29
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.sf.jabref.logic.integrity;

import java.util.Objects;

import net.sf.jabref.model.entry.BibEntry;
import org.apache.commons.lang3.builder.EqualsBuilder;

public class IntegrityMessage implements Cloneable {
public final class IntegrityMessage implements Cloneable {

private final BibEntry entry;
private final String fieldName;
Expand Down Expand Up @@ -35,4 +38,25 @@ public String getFieldName() {
public Object clone() {
return new IntegrityMessage(message, entry, fieldName);
}

@Override
public boolean equals(Object obj) {
if (obj == null) { return false; }
if (obj == this) { return true; }
if (obj.getClass() != getClass()) {
return false;
}
IntegrityMessage rhs = (IntegrityMessage) obj;
return new EqualsBuilder()
.append(entry, rhs.entry)
.append(fieldName, rhs.fieldName)
.append(message, rhs.message)
.isEquals();
}

@Override
public int hashCode() {
return Objects.hash(entry, fieldName, message);
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package net.sf.jabref.logic.integrity;

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

import net.sf.jabref.model.entry.BibEntry;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;


public class NoBibTexFieldCheckerTest {
Expand All @@ -32,14 +31,18 @@ public void journalIsNotRecognizedAsBibLaTeXOnlyField() {
public void journaltitleIsRecognizedAsBibLaTeXOnlyField() {
BibEntry entry = new BibEntry();
entry.setField("journaltitle", "test");
assertNotEquals(Collections.emptyList(), checker.check(entry));
IntegrityMessage message = new IntegrityMessage("BibLaTeX field only", entry, "journaltitle");
List<IntegrityMessage> messages = checker.check(entry);
assertEquals(messages, Collections.singletonList(message));
}

@Test
public void locationIsRecognizedAsBibLaTeXOnlyField() {
BibEntry entry = new BibEntry();
entry.setField("location", "test");
assertNotEquals(Collections.emptyList(), checker.check(entry));
IntegrityMessage message = new IntegrityMessage("BibLaTeX field only", entry, "location");
List<IntegrityMessage> messages = checker.check(entry);
assertEquals(messages, Collections.singletonList(message));
}

}

0 comments on commit 7b77d29

Please sign in to comment.