Add tests for server
This commit is contained in:
16
src/Server/src/test/java/ApplicationTest.java
Normal file
16
src/Server/src/test/java/ApplicationTest.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import gogreen.server.Application;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ApplicationTest {
|
||||
@Test
|
||||
public void applicationContextLoaded() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationContextTest() {
|
||||
Application.main(new String[] {});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
package gogreen.server.rest;
|
||||
|
||||
import gogreen.common.UserDTO;
|
||||
import gogreen.server.Application;
|
||||
import org.junit.Assert;
|
||||
42
src/Server/src/test/java/UserTest.java
Normal file
42
src/Server/src/test/java/UserTest.java
Normal file
@@ -0,0 +1,42 @@
|
||||
import gogreen.server.data.model.User;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class UserTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
User user = new User(1L, "greenify", "password");
|
||||
User testUser = new User();
|
||||
testUser.setId(1L);
|
||||
testUser.setName("greenify");
|
||||
testUser.setPassword("password");
|
||||
assertTrue(user.getId().equals(1L));
|
||||
assertEquals(user.getName(), "greenify");
|
||||
assertEquals(user.getPassword(), "password");
|
||||
assertEquals(user, testUser);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringTest() {
|
||||
User user = new User(1L, "greenify", "password");
|
||||
assertEquals("User(id=1, name=greenify, password=password)", user.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
User first = new User(1L, "greenify", "password");
|
||||
User second = new User(1L, "greenify", "password");
|
||||
assertEquals(first.getId(), second.getId());
|
||||
assertEquals(first.getName(), second.getName());
|
||||
assertEquals(first.getPassword(), second.getPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hashCodeTest() {
|
||||
User first = new User(1L, "greenify", "password");
|
||||
User second = new User(1L, "greenify", "password");
|
||||
assertTrue(first.equals(second) && second.equals(first));
|
||||
assertTrue(first.hashCode() == second.hashCode());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user