Fix order of arguments of assertEquals

This commit is contained in:
Alexander Sulfrian
2019-06-18 18:30:32 +02:00
parent 62de82fee0
commit 0679801945
6 changed files with 32 additions and 34 deletions

View File

@@ -46,25 +46,25 @@ public class IndexVersionTest {
// 4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51
// less than tests (return -1)
assertEquals(IndexVersion.compareSoftwareVersions("5", "6"), -1);
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "6"), -1);
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "4.4"), -1);
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "4.10"), -1);
assertEquals(IndexVersion.compareSoftwareVersions("4.4", "4.10"), -1);
assertEquals(IndexVersion.compareSoftwareVersions("4.4", "5.1"), -1);
assertEquals(-1, IndexVersion.compareSoftwareVersions("5", "6"));
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "6"));
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "4.4"));
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "4.10"));
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.4", "4.10"));
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.4", "5.1"));
// greater than tests (return 1)
assertEquals(IndexVersion.compareSoftwareVersions("6", "5"), 1);
assertEquals(IndexVersion.compareSoftwareVersions("6.10", "6.4"), 1);
assertEquals(IndexVersion.compareSoftwareVersions("6.10", "6.1"), 1);
assertEquals(IndexVersion.compareSoftwareVersions("5.3", "2.4"), 1);
assertEquals(1, IndexVersion.compareSoftwareVersions("6", "5"));
assertEquals(1, IndexVersion.compareSoftwareVersions("6.10", "6.4"));
assertEquals(1, IndexVersion.compareSoftwareVersions("6.10", "6.1"));
assertEquals(1, IndexVersion.compareSoftwareVersions("5.3", "2.4"));
// equality tests (return 0)
assertEquals(IndexVersion.compareSoftwareVersions("5", "5.0"), 0);
assertEquals(IndexVersion.compareSoftwareVersions("6", "6"), 0);
assertEquals(IndexVersion.compareSoftwareVersions("4.2", "4.2"), 0);
assertEquals(0, IndexVersion.compareSoftwareVersions("5", "5.0"));
assertEquals(0, IndexVersion.compareSoftwareVersions("6", "6"));
assertEquals(0, IndexVersion.compareSoftwareVersions("4.2", "4.2"));
// we ignore subminor versions, so these should be "equal"
assertEquals(IndexVersion.compareSoftwareVersions("4.2.1", "4.2"), 0);
assertEquals(0, IndexVersion.compareSoftwareVersions("4.2.1", "4.2"));
}
}

View File

@@ -127,17 +127,17 @@ public class ChecksumHistoryDAOImplTest
qry.setParameter("date", matchDate);
count = (Long) qry.getSingleResult();
assertEquals("Should find no row at matchDate", count, 0);
assertEquals("Should find no row at matchDate", 0, count);
// See if nonmatching old row is still present.
qry.setParameter("date", noMatchDate);
count = (Long) qry.getSingleResult();
assertEquals("Should find one row at noMatchDate", count, 1);
assertEquals("Should find one row at noMatchDate", 1, count);
// See if new row is still present.
qry.setParameter("date", futureDate);
count = (Long) qry.getSingleResult();
assertEquals("Should find one row at futureDate", count, 1);
assertEquals("Should find one row at futureDate", 1, count);
}
/**

View File

@@ -12,7 +12,6 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -169,7 +168,7 @@ public class BundleTest extends AbstractDSpaceObjectTest {
assertThat("testCreate 0", created, notNullValue());
assertTrue("testCreate 1", created.getID() != null);
assertTrue("testCreate 2", created.getBitstreams().size() == 0);
assertEquals("testCreate 3", created.getName(), "testCreateBundle");
assertThat("testCreate 3", created.getName(), equalTo("testCreateBundle"));
}
/**

View File

@@ -12,7 +12,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -752,7 +751,7 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
}};
//null by default
assertEquals("testGetParentCommunity 0", c.getParentCommunities().size(), 0);
assertThat("testGetParentCommunity 0", c.getParentCommunities().size(), equalTo(0));
//community with parent
Community son = communityService.create(c, context);

View File

@@ -7,8 +7,8 @@
*/
package org.dspace.eperson;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -143,7 +143,7 @@ public class GroupTest extends AbstractUnitTest {
topGroup.setName("new name");
groupService.update(context, topGroup);
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
assertEquals("setGroupName 2", topGroup.getName(), "new name");
assertThat("setGroupName 2", topGroup.getName(), equalTo("new name"));
}
@Test
@@ -153,7 +153,7 @@ public class GroupTest extends AbstractUnitTest {
topGroup.setName("new name");
groupService.update(context, topGroup);
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
assertEquals("setGroupName 2", topGroup.getName(), "topGroup");
assertThat("setGroupName 2", topGroup.getName(), equalTo("topGroup"));
topGroup.setPermanent(false);
groupService.update(context, topGroup);
@@ -164,7 +164,7 @@ public class GroupTest extends AbstractUnitTest {
Group group = groupService.findByName(context, "topGroup");
assertThat("findByName 1", group, notNullValue());
assertThat("findByName 2", group.getName(), notNullValue());
assertEquals("findByName 2", group.getName(), "topGroup");
assertThat("findByName 2", group.getName(), equalTo("topGroup"));
}
@Test
@@ -219,7 +219,7 @@ public class GroupTest extends AbstractUnitTest {
Collections.sort(sortedNames);
// Verify the sorted arraylist is still equal to the original (unsorted) one
assertEquals("findAllNameSort compareLists", sortedNames, names);
assertThat("findAllNameSort compareLists", names, equalTo(sortedNames));
}
@Test
@@ -227,14 +227,14 @@ public class GroupTest extends AbstractUnitTest {
//We can find 2 groups so attempt to retrieve with offset 0 and a max of one
List<Group> groups = groupService.search(context, "level", 0, 1);
assertThat("search 1", groups, notNullValue());
assertEquals("search 2", groups.size(), 1);
assertThat("search 2", groups.size(), equalTo(1));
String firstGroupName = groups.iterator().next().getName();
assertTrue("search 3", firstGroupName.equals("level1Group") || firstGroupName.equals("level2Group"));
//Retrieve the second group
groups = groupService.search(context, "level", 1, 2);
assertThat("search 1", groups, notNullValue());
assertEquals("search 2", groups.size(), 1);
assertThat("search 2", groups.size(), equalTo(1));
String secondGroupName = groups.iterator().next().getName();
assertTrue("search 3", secondGroupName.equals("level1Group") || secondGroupName.equals("level2Group"));
}
@@ -242,14 +242,14 @@ public class GroupTest extends AbstractUnitTest {
@Test
public void searchByID() throws SQLException {
List<Group> searchResult = groupService.search(context, String.valueOf(topGroup.getID()), 0, 10);
assertEquals("searchID 1", searchResult.size(), 1);
assertEquals("searchID 2", searchResult.iterator().next(), topGroup);
assertThat("searchID 1", searchResult.size(), equalTo(1));
assertThat("searchID 2", searchResult.iterator().next(), equalTo(topGroup));
}
@Test
public void searchResultCount() throws SQLException {
assertEquals("searchResultCount", groupService.searchResultCount(context, "level"), 2);
assertThat("searchResultCount", groupService.searchResultCount(context, "level"), equalTo(2));
}
@Test
@@ -259,7 +259,7 @@ public class GroupTest extends AbstractUnitTest {
ePerson = createEPersonAndAddToGroup("addMemberEPerson@dspace.org", topGroup);
groupService.update(context, topGroup);
assertEquals("addMemberEPerson 1", topGroup.getMembers().size(), 1);
assertThat("addMemberEPerson 1", topGroup.getMembers().size(), equalTo(1));
assertTrue("addMemberEPerson 2", topGroup.getMembers().contains(ePerson));
} finally {
if (ePerson != null) {
@@ -295,7 +295,7 @@ public class GroupTest extends AbstractUnitTest {
groupService.addMember(context, toDeleteGroup, ePerson);
groupService.update(context, toDeleteGroup);
groupService.delete(context, toDeleteGroup);
assertEquals("deleteGroupEPersonMembers", ePerson.getGroups().size(), 0);
assertThat("deleteGroupEPersonMembers", ePerson.getGroups().size(), equalTo(0));
} finally {
if (ePerson != null) {
ePersonService.delete(context, ePerson);

View File

@@ -30,7 +30,7 @@ public class TestLocationUtils extends AbstractDSpaceTest {
*/
@Test
public void testGetContinentCode() {
assertEquals(LocationUtils.getContinentCode("US"), "NA");
assertEquals("NA", LocationUtils.getContinentCode("US"));
assertTrue(LocationUtils.getContinentCode(null).length() > 2); // message
assertTrue(LocationUtils.getContinentCode("xyz").length() > 2); // message
}