Skip to content

Commit

Permalink
Added test for status endpoint and added README
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmathew committed Jul 1, 2024
1 parent aafe220 commit a5c26a6
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .fleet/run.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "gradle",
"workingDir": "$PROJECT_DIR$",
"tasks": [
":server:build"
":admin-server:build"
],
"args": [
""
Expand Down
19 changes: 19 additions & 0 deletions admin-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Admin server

API
<br>
```/status``` - To check health status

<br>

To build
<br>
```./gradlew admin-server:build```

To run
<br>
```./gradlew admin-server:bootRun```

To run tests
<br>
```./gradlew admin-server:test```
8 changes: 6 additions & 2 deletions admin-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation(libs.springboot.actuator)
implementation(libs.springboot.web)
implementation(libs.kotlin.reflect)

testImplementation(libs.springboot.test)
runtimeOnly(libs.springboot.devtools)
}

Expand All @@ -30,5 +30,9 @@ kotlin {
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
setExceptionFormat("full")
events("started", "skipped", "passed", "failed")
showStandardStreams = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sphereon.oid.fed

import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class ApplicationTests {

@Test
fun contextLoads() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sphereon.oid.fed

import org.junit.jupiter.api.Test
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.web.servlet.MockMvc
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.*


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
class StatusEndpointTest {

@Autowired
private lateinit var mockMvc: MockMvc

@Test
fun testStatusEndpoint() {
mockMvc.perform(get("/status"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status").value("UP"))
}
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
springboot-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" }
springboot-web = { group = "org.springframework.boot", name = "spring-boot-starter-web" }
springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" }
springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down

0 comments on commit a5c26a6

Please sign in to comment.