обновление теста DAO
This commit is contained in:
@@ -85,8 +85,6 @@ public class TestDAO {
|
||||
@Test(expected = DuplicateKeyException.class)
|
||||
public void testInsertDuplicateKey() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
playerDAO.insert(player);
|
||||
}
|
||||
|
||||
@@ -133,6 +131,17 @@ public class TestDAO {
|
||||
assertEquals(player, queryPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetByNonExistsName() throws SQLException {
|
||||
playerDAO.insert(this.player);
|
||||
|
||||
H2Player player = new H2Player();
|
||||
player.setName("NON_EXISTS_NAME");
|
||||
|
||||
boolean result = playerDAO.getByName(player);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetById() throws SQLException {
|
||||
playerDAO.insert(this.player);
|
||||
@@ -146,17 +155,6 @@ public class TestDAO {
|
||||
assertEquals(player, queryPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetByNonExistsName() throws SQLException {
|
||||
playerDAO.insert(this.player);
|
||||
|
||||
H2Player player = new H2Player();
|
||||
player.setName("NON_EXISTS_NAME");
|
||||
|
||||
boolean result = playerDAO.getByName(player);
|
||||
assertFalse(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetByNonExistsId() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
@@ -172,7 +170,6 @@ public class TestDAO {
|
||||
@Test
|
||||
public void testUpdate() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setName("UNKNOWN_PLAYER");
|
||||
playerDAO.update(player);
|
||||
@@ -183,7 +180,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateEmptyName() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setName("");
|
||||
playerDAO.update(player);
|
||||
@@ -192,7 +188,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateNullName() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setName(null);
|
||||
playerDAO.update(player);
|
||||
@@ -201,7 +196,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateNullUuid() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setUuid(null);
|
||||
playerDAO.update(player);
|
||||
@@ -210,7 +204,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateNullLocation() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setLocation(null);
|
||||
playerDAO.update(player);
|
||||
@@ -219,7 +212,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateNullWorld() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setWorld(null);
|
||||
playerDAO.update(player);
|
||||
@@ -228,7 +220,6 @@ public class TestDAO {
|
||||
@Test
|
||||
public void testUpdateLocation() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
final String origName = player.getName();
|
||||
player.setName("UNKNOWN_PLAYER");
|
||||
@@ -254,7 +245,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUpdateLocationNull() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setLocation(null);
|
||||
playerDAO.updateLocation(player);
|
||||
@@ -263,7 +253,6 @@ public class TestDAO {
|
||||
@Test
|
||||
public void testRemove() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
final int origId = player.getId();
|
||||
playerDAO.remove(player);
|
||||
@@ -278,7 +267,6 @@ public class TestDAO {
|
||||
@Test(expected = SQLException.class)
|
||||
public void testRemoveNonExistsId() throws SQLException {
|
||||
playerDAO.insert(player);
|
||||
assertNotEquals(0, player.getId());
|
||||
|
||||
player.setId(999);
|
||||
playerDAO.remove(player);
|
||||
|
||||
Reference in New Issue
Block a user