last test

This commit is contained in:
Filip Izydorczyk 2021-01-18 13:38:24 +01:00
parent 77c3b9e3a5
commit c5f09a91ec
2 changed files with 39 additions and 28 deletions

View File

@ -0,0 +1,14 @@
package com.plannaplan.models;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
public class ExportDataTest {
@Test
public void shouldConvertDataToCSVRecord() {
final ExportData data = new ExportData("4234", "242352", "12");
assertTrue(data.convertToCSVRecord().equals("4234,242352,12"));
}
}

View File

@ -275,7 +275,7 @@ public class CommisionControllerTest extends AbstractControllerTest {
}
@Test
public void shouldExportData() throws Exception{
public void shouldExportData() throws Exception {
this.checkUsers();
final User admin = this.service.checkForUser(TEST_COMMISIONS_ADMIN_EMAIL, null);
final String token = this.service.login(admin).getToken();
@ -285,29 +285,26 @@ public class CommisionControllerTest extends AbstractControllerTest {
}
@Test
public void shouldNotExportDataDueToWrongPermision() throws Exception{
public void shouldNotExportDataDueToWrongPermision() throws Exception {
this.checkUsers();
final User student = this.service.checkForUser(TEST_COMMISIONS_STUDENT_EMAIL, null);
final String token = this.service.login(student).getToken();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
mockMvc.perform(get(EXPORT_DATA).header("Authorization", "Bearer " + token)).andExpect(status().is4xxClientError());
mockMvc.perform(get(EXPORT_DATA).header("Authorization", "Bearer " + token))
.andExpect(status().is4xxClientError());
}
@Test
public void shouldExportDataBeCsvFile() throws Exception{
public void shouldExportDataBeCsvFile() throws Exception {
this.checkUsers();
final User admin = this.service.checkForUser(TEST_COMMISIONS_ADMIN_EMAIL, null);
final String token = this.service.login(admin).getToken();
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
assertTrue(mockMvc.perform(get(EXPORT_DATA)
.header("Authorization", "Bearer " + token))
.andExpect(status().isOk())
.andReturn()
.getResponse()
.getContentAsString()
.contains("user_id, zaj_cykl_id, gr_nr"));
assertTrue(
mockMvc.perform(get(EXPORT_DATA).header("Authorization", "Bearer " + token)).andExpect(status().isOk())
.andReturn().getResponse().getContentAsString().contains("user_id, zaj_cykl_id, gr_nr"));
}
}