diff --git a/pom.xml b/pom.xml index f293ecf..2b199f6 100644 --- a/pom.xml +++ b/pom.xml @@ -13,10 +13,40 @@ 0.0.1-SNAPSHOT Project Planner Application for planning project time - - 1.8 - 1.4.31 - + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + maven-surefire-plugin + org.apache.maven.plugins + 2.22.1 + + + org.springframework.boot @@ -103,34 +133,10 @@ - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.springframework.boot - spring-boot-maven-plugin - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - -Xjsr305=strict - - - spring - - - - - org.jetbrains.kotlin - kotlin-maven-allopen - ${kotlin.version} - - - - - + + 1.8 + 1.4.31 + 5.6.0 + diff --git a/src/test/kotlin/uk/co/neviyn/projectplanner/HtmlControllerTest.kt b/src/test/kotlin/uk/co/neviyn/projectplanner/HtmlControllerTest.kt new file mode 100644 index 0000000..e1eb2eb --- /dev/null +++ b/src/test/kotlin/uk/co/neviyn/projectplanner/HtmlControllerTest.kt @@ -0,0 +1,52 @@ +package uk.co.neviyn.projectplanner + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.MediaType +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status + +@SpringBootTest +@AutoConfigureMockMvc +class HtmlControllerTest(@Autowired val mockMvc: MockMvc) { + + val textHtmlWithCharset = MediaType.parseMediaType("text/html;charset=UTF-8") + + @Test + fun getLandingPage() { + mockMvc.perform(get("/")) + .andExpect(status().isOk) + .andExpect(content().contentType(textHtmlWithCharset)) + } + + @Test + fun getLoginPage() { + mockMvc.perform(get("/login")) + .andExpect(status().isOk) + .andExpect(content().contentType(textHtmlWithCharset)) + } + + @Test + fun getRegistrationPage() { + mockMvc.perform(get("/register")) + .andExpect(status().isOk) + .andExpect(content().contentType(textHtmlWithCharset)) + } + + @Test + fun getProfileNotLoggedInt() { + mockMvc.perform(get("/profile")) + .andExpect(status().isUnauthorized) + } + + @Test + fun getProjectsNotLoggedIn() { + mockMvc.perform(get("/projects")) + .andExpect(status().isUnauthorized) + } +} \ No newline at end of file diff --git a/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTest.kt b/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTest.kt new file mode 100644 index 0000000..998c3cb --- /dev/null +++ b/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTest.kt @@ -0,0 +1,39 @@ +package uk.co.neviyn.projectplanner + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ProjectPlannerApplicationTest { + + @Autowired + private var controller: HtmlController? = null + + @Autowired + private var userRepository: UserRepository? = null + + @Autowired + private var projectRepository: ProjectRepository? = null + + @Autowired + private var eventRepository: EventRepository? = null + + @Autowired + private var tagRepository: TagRepository? = null + + @Autowired + private var commentRepository: CommentRepository? = null + + @Test + fun contextLoads() { + assertNotNull(controller) + assertNotNull(userRepository) + assertNotNull(projectRepository) + assertNotNull(eventRepository) + assertNotNull(tagRepository) + assertNotNull(commentRepository) + } + +} \ No newline at end of file diff --git a/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTests.kt b/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTests.kt deleted file mode 100644 index 748fb7d..0000000 --- a/src/test/kotlin/uk/co/neviyn/projectplanner/ProjectPlannerApplicationTests.kt +++ /dev/null @@ -1,13 +0,0 @@ -package uk.co.neviyn.projectplanner - -import org.junit.jupiter.api.Test -import org.springframework.boot.test.context.SpringBootTest - -@SpringBootTest -class ProjectPlannerApplicationTests { - - @Test - fun contextLoads() { - } - -}