Checkpoint: Added tests to impleement

This commit is contained in:
Filip Izydorczyk 2020-10-02 16:51:49 +02:00
parent bb9ea7529f
commit e9ae1a0ed0
4 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,33 @@
package com.plannaplan.services;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class AssignmentServiceTest {
// @Autowired
// private AssignmentService service;
// @Autowired
// private UserService userService;
@Test
public void shouldSaveAssignment() {
assertTrue("Not implemented", false);
}
@Test
public void shouldGetCommisionAssignments() {
assertTrue("Not implemented", false);
}
}

View File

@ -0,0 +1,27 @@
package com.plannaplan.controllers;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class AssignmentsControllerTest {
@Test
public void shouldReturn4xx() {
assertTrue(false);
}
@Test
public void shouldReturnOk() {
assertTrue(false);
}
}

View File

@ -0,0 +1,36 @@
package com.plannaplan.controllers;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class CommisionControllerTest {
@Test
public void shouldReturn4xxAddingCommision() {
assertTrue(false);
}
@Test
public void shouldReturnOkAddingCommision() {
assertTrue(false);
}
@Test
public void shouldReturn4xxGettingAllCommisions() {
assertTrue(false);
}
@Test
public void shouldReturnOkGettingAllCommisions() {
assertTrue(false);
}
}

View File

@ -6,7 +6,9 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv
import java.io.InputStream;
import com.plannaplan.entities.User;
import com.plannaplan.services.UserService;
import com.plannaplan.types.UserRoles;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,6 +29,7 @@ public class ConfigControllerTest {
private static final String FILE_NAME = "Zajecia.xlsx";
private static final String CONFIG_ENDPOINT = "/api/v1/configurator/config";
private static final String TEST_MAIL = "notexisting@mail.domain";
@Autowired
private WebApplicationContext webApplicationContext;
@ -56,9 +59,12 @@ public class ConfigControllerTest {
@Test
public void shouldReturnOKAuthorized() throws Exception {
final User usr = new User(null, null, TEST_MAIL, UserRoles.TEST_USER);
this.service.save(usr);
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
final MockMultipartFile file = new MockMultipartFile("file", inputStream);
final String token = this.service.login("notexisting@mail.comain");
final String token = this.service.login(TEST_MAIL);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file).header("Bearer ", token))