File tree Expand file tree Collapse file tree 4 files changed +41
-10
lines changed
main/kotlin/no/nav/hjelpemidler
test/kotlin/no/nav/hjelpemidler/api Expand file tree Collapse file tree 4 files changed +41
-10
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ internal object Configuration {
38
38
" HTTP_PORT" to " 8085" ,
39
39
40
40
" NAIS_APP_NAME" to " hm-oebs-listener" ,
41
- " NAIS_CLUSTER_NAME" to " local " ,
41
+ " NAIS_CLUSTER_NAME" to Profile . LOCAL .name ,
42
42
" NAIS_NAMESPACE" to " teamdigihot" ,
43
43
44
44
" OEBSTOKEN" to " token" ,
Original file line number Diff line number Diff line change @@ -24,15 +24,19 @@ object Ntfy {
24
24
}
25
25
}
26
26
27
- fun publish (notification : Notification ) = runBlocking(Dispatchers .IO ) {
28
- val response = client.post(Configuration .ntfyUrl) {
29
- contentType(ContentType .Application .Json )
30
- setBody(notification)
31
- }
32
- when (response.status) {
33
- HttpStatusCode .OK -> Unit
34
- else -> log.warn(" Feil ved publisering til ntfy: ${response.body<Map <String , Any ?>>()} " )
27
+ fun publish (notification : Notification ) = runCatching {
28
+ runBlocking(Dispatchers .IO ) {
29
+ val response = client.post(Configuration .ntfyUrl) {
30
+ contentType(ContentType .Application .Json )
31
+ setBody(notification.copy(tags = notification.tags + setOf (Configuration .profile.name)))
32
+ }
33
+ when (response.status) {
34
+ HttpStatusCode .OK -> Unit
35
+ else -> log.warn(" Feil under publisering til ntfy: ${response.body<Map <String , Any ?>>()} " )
36
+ }
35
37
}
38
+ }.getOrElse {
39
+ log.warn(it) { " Feil under publisering til ntfy" }
36
40
}
37
41
38
42
data class Notification (
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ object Slack {
23
23
}
24
24
}
25
25
26
- fun post (url : String = Configuration .slackHook, text : String , channel : String ) =
26
+ fun post (url : String = Configuration .slackHook, text : String , channel : String ) = runCatching {
27
27
runBlocking(Dispatchers .IO ) {
28
28
val response = client
29
29
.post(url) {
@@ -42,4 +42,7 @@ object Slack {
42
42
else -> log.info(response.body<String >())
43
43
}
44
44
}
45
+ }.getOrElse {
46
+ log.warn(it) { " Feil under publisering til Slack" }
47
+ }
45
48
}
Original file line number Diff line number Diff line change @@ -47,6 +47,30 @@ internal class OrdreAPITest {
47
47
}
48
48
}
49
49
50
+ @Test
51
+ internal fun `sender ut ordrefeilmelding på rapid` () = testApplication {
52
+ configure()
53
+ val body = context.jsonMapper.writeValueAsString(
54
+ Ordrefeilmelding (
55
+ id = " 1" ,
56
+ saksnummer = " 2" ,
57
+ feilmelding = " Feilmelding" ,
58
+ system = " HOTSAK" ,
59
+ status = " ERROR"
60
+ )
61
+ )
62
+ client.post(" /ordrefeilmelding" ) {
63
+ bearerAuth(" qwer1234" )
64
+ contentType(ContentType .Application .Json )
65
+ setBody(body)
66
+ }.apply {
67
+ status shouldBe HttpStatusCode .OK
68
+ verify {
69
+ context.publish(" 2" , match { it.contains(body) })
70
+ }
71
+ }
72
+ }
73
+
50
74
private fun ApplicationTestBuilder.configure () {
51
75
install(ContentNegotiation ) {
52
76
jackson()
You can’t perform that action at this time.
0 commit comments