-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22e5f49
commit 78f9c69
Showing
9 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
lapis2/src/main/kotlin/org/genspectrum/lapis/controller/InfoController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.genspectrum.lapis.controller | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import org.genspectrum.lapis.model.SiloQueryModel | ||
import org.genspectrum.lapis.request.LapisInfo | ||
import org.springframework.http.MediaType | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
const val INFO_ROUTE = "/info" | ||
|
||
@RestController | ||
class InfoController(private val siloQueryModel: SiloQueryModel) { | ||
@GetMapping(INFO_ROUTE, produces = [MediaType.APPLICATION_JSON_VALUE]) | ||
@Operation(description = INFO_ENDPOINT_DESCRIPTION) | ||
fun getInfo(): LapisInfo { | ||
val siloInfo = siloQueryModel.getInfo() | ||
return LapisInfo(siloInfo.dataVersion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
lapis2/src/test/kotlin/org/genspectrum/lapis/controller/InfoControllerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.genspectrum.lapis.controller | ||
|
||
import com.ninjasquad.springmockk.MockkBean | ||
import io.mockk.every | ||
import org.genspectrum.lapis.model.SiloQueryModel | ||
import org.genspectrum.lapis.response.InfoData | ||
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.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
class InfoControllerTest( | ||
@Autowired val mockMvc: MockMvc, | ||
) { | ||
@MockkBean | ||
lateinit var siloQueryModelMock: SiloQueryModel | ||
|
||
@Test | ||
fun `GET info`() { | ||
every { | ||
siloQueryModelMock.getInfo() | ||
} returns InfoData("1234") | ||
|
||
mockMvc.perform(MockMvcRequestBuilders.get(INFO_ROUTE)) | ||
.andExpect(MockMvcResultMatchers.status().isOk) | ||
.andExpect(MockMvcResultMatchers.jsonPath("\$.dataVersion").value("1234")) | ||
} | ||
} |