Fixed old tests

This commit is contained in:
Filip Izydorczyk 2020-10-24 16:43:42 +02:00
parent 4b07793849
commit c003198aa1
2 changed files with 3 additions and 18 deletions

View File

@ -11,7 +11,6 @@ import com.plannaplan.entities.User;
import com.plannaplan.exceptions.UserNotFoundException; import com.plannaplan.exceptions.UserNotFoundException;
import com.plannaplan.types.UserRoles; import com.plannaplan.types.UserRoles;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
@ -29,14 +28,10 @@ public class UserServiceTest {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Before
public void initialize() {
User testUser = new User(TEST_USER_NAME, TEST_USER_SUERNAME, TEST_USER_MAIL, UserRoles.TEST_USER);
this.userService.save(testUser);
}
@Test @Test
public void shouldReturnToken() { public void shouldReturnToken() {
final User testUser = new User(TEST_USER_NAME, TEST_USER_SUERNAME, TEST_USER_MAIL, UserRoles.TEST_USER);
this.userService.save(testUser);
try { try {
final String token = this.userService.login(TEST_USER_MAIL); final String token = this.userService.login(TEST_USER_MAIL);
System.out.println("Returned token: " + token); System.out.println("Returned token: " + token);

View File

@ -37,16 +37,6 @@ public class ConfigControllerTest {
@Autowired @Autowired
private UserService service; private UserService service;
@Test
public void shouldReturnOK() throws Exception {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
final MockMultipartFile file = new MockMultipartFile("file", inputStream);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file)).andExpect(status().isOk());
}
@Test @Test
public void shouldReturnNoAuthorized() throws Exception { public void shouldReturnNoAuthorized() throws Exception {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME); final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
@ -59,7 +49,7 @@ public class ConfigControllerTest {
@Test @Test
public void shouldReturnOKAuthorized() throws Exception { public void shouldReturnOKAuthorized() throws Exception {
final User usr = new User(null, null, TEST_MAIL, UserRoles.TEST_USER); final User usr = new User(null, null, TEST_MAIL, UserRoles.ADMIN);
this.service.save(usr); this.service.save(usr);
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME); final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);