mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 16:03:07 +00:00
Fix order of arguments of assertEquals
This commit is contained in:
@@ -46,25 +46,25 @@ public class IndexVersionTest {
|
|||||||
// 4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51
|
// 4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51
|
||||||
|
|
||||||
// less than tests (return -1)
|
// less than tests (return -1)
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("5", "6"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("5", "6"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "6"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "6"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "4.4"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "4.4"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.1", "4.10"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.1", "4.10"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.4", "4.10"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.4", "4.10"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.4", "5.1"), -1);
|
assertEquals(-1, IndexVersion.compareSoftwareVersions("4.4", "5.1"));
|
||||||
|
|
||||||
// greater than tests (return 1)
|
// greater than tests (return 1)
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("6", "5"), 1);
|
assertEquals(1, IndexVersion.compareSoftwareVersions("6", "5"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("6.10", "6.4"), 1);
|
assertEquals(1, IndexVersion.compareSoftwareVersions("6.10", "6.4"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("6.10", "6.1"), 1);
|
assertEquals(1, IndexVersion.compareSoftwareVersions("6.10", "6.1"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("5.3", "2.4"), 1);
|
assertEquals(1, IndexVersion.compareSoftwareVersions("5.3", "2.4"));
|
||||||
|
|
||||||
// equality tests (return 0)
|
// equality tests (return 0)
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("5", "5.0"), 0);
|
assertEquals(0, IndexVersion.compareSoftwareVersions("5", "5.0"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("6", "6"), 0);
|
assertEquals(0, IndexVersion.compareSoftwareVersions("6", "6"));
|
||||||
assertEquals(IndexVersion.compareSoftwareVersions("4.2", "4.2"), 0);
|
assertEquals(0, IndexVersion.compareSoftwareVersions("4.2", "4.2"));
|
||||||
// we ignore subminor versions, so these should be "equal"
|
// 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -127,17 +127,17 @@ public class ChecksumHistoryDAOImplTest
|
|||||||
|
|
||||||
qry.setParameter("date", matchDate);
|
qry.setParameter("date", matchDate);
|
||||||
count = (Long) qry.getSingleResult();
|
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.
|
// See if nonmatching old row is still present.
|
||||||
qry.setParameter("date", noMatchDate);
|
qry.setParameter("date", noMatchDate);
|
||||||
count = (Long) qry.getSingleResult();
|
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.
|
// See if new row is still present.
|
||||||
qry.setParameter("date", futureDate);
|
qry.setParameter("date", futureDate);
|
||||||
count = (Long) qry.getSingleResult();
|
count = (Long) qry.getSingleResult();
|
||||||
assertEquals("Should find one row at futureDate", count, 1);
|
assertEquals("Should find one row at futureDate", 1, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,7 +12,6 @@ import static org.hamcrest.CoreMatchers.instanceOf;
|
|||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
@@ -169,7 +168,7 @@ public class BundleTest extends AbstractDSpaceObjectTest {
|
|||||||
assertThat("testCreate 0", created, notNullValue());
|
assertThat("testCreate 0", created, notNullValue());
|
||||||
assertTrue("testCreate 1", created.getID() != null);
|
assertTrue("testCreate 1", created.getID() != null);
|
||||||
assertTrue("testCreate 2", created.getBitstreams().size() == 0);
|
assertTrue("testCreate 2", created.getBitstreams().size() == 0);
|
||||||
assertEquals("testCreate 3", created.getName(), "testCreateBundle");
|
assertThat("testCreate 3", created.getName(), equalTo("testCreateBundle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,7 +12,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
|||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -752,7 +751,7 @@ public class CommunityTest extends AbstractDSpaceObjectTest {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
//null by default
|
//null by default
|
||||||
assertEquals("testGetParentCommunity 0", c.getParentCommunities().size(), 0);
|
assertThat("testGetParentCommunity 0", c.getParentCommunities().size(), equalTo(0));
|
||||||
|
|
||||||
//community with parent
|
//community with parent
|
||||||
Community son = communityService.create(c, context);
|
Community son = communityService.create(c, context);
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.eperson;
|
package org.dspace.eperson;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -143,7 +143,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
topGroup.setName("new name");
|
topGroup.setName("new name");
|
||||||
groupService.update(context, topGroup);
|
groupService.update(context, topGroup);
|
||||||
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
||||||
assertEquals("setGroupName 2", topGroup.getName(), "new name");
|
assertThat("setGroupName 2", topGroup.getName(), equalTo("new name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -153,7 +153,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
topGroup.setName("new name");
|
topGroup.setName("new name");
|
||||||
groupService.update(context, topGroup);
|
groupService.update(context, topGroup);
|
||||||
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
assertThat("setGroupName 1", topGroup.getName(), notNullValue());
|
||||||
assertEquals("setGroupName 2", topGroup.getName(), "topGroup");
|
assertThat("setGroupName 2", topGroup.getName(), equalTo("topGroup"));
|
||||||
|
|
||||||
topGroup.setPermanent(false);
|
topGroup.setPermanent(false);
|
||||||
groupService.update(context, topGroup);
|
groupService.update(context, topGroup);
|
||||||
@@ -164,7 +164,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
Group group = groupService.findByName(context, "topGroup");
|
Group group = groupService.findByName(context, "topGroup");
|
||||||
assertThat("findByName 1", group, notNullValue());
|
assertThat("findByName 1", group, notNullValue());
|
||||||
assertThat("findByName 2", group.getName(), notNullValue());
|
assertThat("findByName 2", group.getName(), notNullValue());
|
||||||
assertEquals("findByName 2", group.getName(), "topGroup");
|
assertThat("findByName 2", group.getName(), equalTo("topGroup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -219,7 +219,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
Collections.sort(sortedNames);
|
Collections.sort(sortedNames);
|
||||||
|
|
||||||
// Verify the sorted arraylist is still equal to the original (unsorted) one
|
// Verify the sorted arraylist is still equal to the original (unsorted) one
|
||||||
assertEquals("findAllNameSort compareLists", sortedNames, names);
|
assertThat("findAllNameSort compareLists", names, equalTo(sortedNames));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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
|
//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);
|
List<Group> groups = groupService.search(context, "level", 0, 1);
|
||||||
assertThat("search 1", groups, notNullValue());
|
assertThat("search 1", groups, notNullValue());
|
||||||
assertEquals("search 2", groups.size(), 1);
|
assertThat("search 2", groups.size(), equalTo(1));
|
||||||
String firstGroupName = groups.iterator().next().getName();
|
String firstGroupName = groups.iterator().next().getName();
|
||||||
assertTrue("search 3", firstGroupName.equals("level1Group") || firstGroupName.equals("level2Group"));
|
assertTrue("search 3", firstGroupName.equals("level1Group") || firstGroupName.equals("level2Group"));
|
||||||
|
|
||||||
//Retrieve the second group
|
//Retrieve the second group
|
||||||
groups = groupService.search(context, "level", 1, 2);
|
groups = groupService.search(context, "level", 1, 2);
|
||||||
assertThat("search 1", groups, notNullValue());
|
assertThat("search 1", groups, notNullValue());
|
||||||
assertEquals("search 2", groups.size(), 1);
|
assertThat("search 2", groups.size(), equalTo(1));
|
||||||
String secondGroupName = groups.iterator().next().getName();
|
String secondGroupName = groups.iterator().next().getName();
|
||||||
assertTrue("search 3", secondGroupName.equals("level1Group") || secondGroupName.equals("level2Group"));
|
assertTrue("search 3", secondGroupName.equals("level1Group") || secondGroupName.equals("level2Group"));
|
||||||
}
|
}
|
||||||
@@ -242,14 +242,14 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void searchByID() throws SQLException {
|
public void searchByID() throws SQLException {
|
||||||
List<Group> searchResult = groupService.search(context, String.valueOf(topGroup.getID()), 0, 10);
|
List<Group> searchResult = groupService.search(context, String.valueOf(topGroup.getID()), 0, 10);
|
||||||
assertEquals("searchID 1", searchResult.size(), 1);
|
assertThat("searchID 1", searchResult.size(), equalTo(1));
|
||||||
assertEquals("searchID 2", searchResult.iterator().next(), topGroup);
|
assertThat("searchID 2", searchResult.iterator().next(), equalTo(topGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchResultCount() throws SQLException {
|
public void searchResultCount() throws SQLException {
|
||||||
assertEquals("searchResultCount", groupService.searchResultCount(context, "level"), 2);
|
assertThat("searchResultCount", groupService.searchResultCount(context, "level"), equalTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -259,7 +259,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
ePerson = createEPersonAndAddToGroup("addMemberEPerson@dspace.org", topGroup);
|
ePerson = createEPersonAndAddToGroup("addMemberEPerson@dspace.org", topGroup);
|
||||||
groupService.update(context, 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));
|
assertTrue("addMemberEPerson 2", topGroup.getMembers().contains(ePerson));
|
||||||
} finally {
|
} finally {
|
||||||
if (ePerson != null) {
|
if (ePerson != null) {
|
||||||
@@ -295,7 +295,7 @@ public class GroupTest extends AbstractUnitTest {
|
|||||||
groupService.addMember(context, toDeleteGroup, ePerson);
|
groupService.addMember(context, toDeleteGroup, ePerson);
|
||||||
groupService.update(context, toDeleteGroup);
|
groupService.update(context, toDeleteGroup);
|
||||||
groupService.delete(context, toDeleteGroup);
|
groupService.delete(context, toDeleteGroup);
|
||||||
assertEquals("deleteGroupEPersonMembers", ePerson.getGroups().size(), 0);
|
assertThat("deleteGroupEPersonMembers", ePerson.getGroups().size(), equalTo(0));
|
||||||
} finally {
|
} finally {
|
||||||
if (ePerson != null) {
|
if (ePerson != null) {
|
||||||
ePersonService.delete(context, ePerson);
|
ePersonService.delete(context, ePerson);
|
||||||
|
@@ -30,7 +30,7 @@ public class TestLocationUtils extends AbstractDSpaceTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetContinentCode() {
|
public void testGetContinentCode() {
|
||||||
assertEquals(LocationUtils.getContinentCode("US"), "NA");
|
assertEquals("NA", LocationUtils.getContinentCode("US"));
|
||||||
assertTrue(LocationUtils.getContinentCode(null).length() > 2); // message
|
assertTrue(LocationUtils.getContinentCode(null).length() > 2); // message
|
||||||
assertTrue(LocationUtils.getContinentCode("xyz").length() > 2); // message
|
assertTrue(LocationUtils.getContinentCode("xyz").length() > 2); // message
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user