From e9ae1a0ed08463a42b84ca1a1d86094bae199200 Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Fri, 2 Oct 2020 16:51:49 +0200 Subject: [PATCH] Checkpoint: Added tests to impleement --- .../services/AssignmentServiceTest.java | 33 +++++++++++++++++ .../AssignmentsControllerTest.java | 27 ++++++++++++++ .../controllers/CommisionControllerTest.java | 36 +++++++++++++++++++ .../controllers/ConfigControllerTest.java | 8 ++++- 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100755 buisnesslogic/src/test/java/com/plannaplan/services/AssignmentServiceTest.java create mode 100755 restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java create mode 100755 restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/AssignmentServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/AssignmentServiceTest.java new file mode 100755 index 0000000..fe48067 --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/services/AssignmentServiceTest.java @@ -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); + } + +} diff --git a/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java new file mode 100755 index 0000000..77532f3 --- /dev/null +++ b/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java @@ -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); + } + +} diff --git a/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java new file mode 100755 index 0000000..19561ea --- /dev/null +++ b/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java @@ -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); + } +} diff --git a/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java index 760f8e2..2e2d644 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java @@ -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))