Added some basic sanity tests
This commit is contained in:
parent
1d95b6fb00
commit
b11e273d7e
72
pom.xml
72
pom.xml
@ -13,10 +13,40 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>Project Planner</name>
|
<name>Project Planner</name>
|
||||||
<description>Application for planning project time</description>
|
<description>Application for planning project time</description>
|
||||||
<properties>
|
<build>
|
||||||
<java.version>1.8</java.version>
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
<kotlin.version>1.4.31</kotlin.version>
|
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||||
</properties>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<args>
|
||||||
|
<arg>-Xjsr305=strict</arg>
|
||||||
|
</args>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>spring</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-allopen</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -103,34 +133,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<properties>
|
||||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
<java.version>1.8</java.version>
|
||||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
<kotlin.version>1.4.31</kotlin.version>
|
||||||
<plugins>
|
<junit-jupiter.version>5.6.0</junit-jupiter.version>
|
||||||
<plugin>
|
</properties>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<args>
|
|
||||||
<arg>-Xjsr305=strict</arg>
|
|
||||||
</args>
|
|
||||||
<compilerPlugins>
|
|
||||||
<plugin>spring</plugin>
|
|
||||||
</compilerPlugins>
|
|
||||||
</configuration>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-maven-allopen</artifactId>
|
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user