Skip to content

Commit

Permalink
HAI-1844 Add test for hanke tunnus check
Browse files Browse the repository at this point in the history
  • Loading branch information
pitkni committed Aug 30, 2023
1 parent 125a9d0 commit 03f25ec
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ class HankeControllerTest {
verify { disclosureLogService.saveDisclosureLogsForHanke(any(), eq(username)) }
}

@Test
fun `test that the updateHanke will throw if mismatch in hanke tunnus payload vs path`() {
val hankeUpdate = HankeFactory.create()
val existingHanke = HankeFactory.create(hankeTunnus = "wrong")
Mockito.`when`(hankeService.findHankeOrThrow("wrong")).thenReturn(existingHanke)

assertThatExceptionOfType(HankeArgumentException::class.java)
.isThrownBy { hankeController.updateHanke(hankeUpdate, "wrong") }
.withMessageContaining(
"Hanketunnus mismatch. (In payload=${hankeUpdate.hankeTunnus}, In path=wrong)"
)
}

@Test
fun `test that the updateHanke will give validation errors from invalid hanke data for name`() {
val partialHanke =
Expand Down

0 comments on commit 03f25ec

Please sign in to comment.