This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/aos 2839 helse endepunkt formater #62
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
109 changes: 109 additions & 0 deletions
109
src/test/kotlin/no/skatteetaten/aurora/mokey/service/HealthResponseParserTest.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,109 @@ | ||
package no.skatteetaten.aurora.mokey.service | ||
|
||
import assertk.assertions.isEqualTo | ||
import com.fasterxml.jackson.databind.node.IntNode | ||
import com.fasterxml.jackson.databind.node.LongNode | ||
import com.fasterxml.jackson.databind.node.TextNode | ||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import no.skatteetaten.aurora.mokey.model.HealthPart | ||
import no.skatteetaten.aurora.mokey.model.HealthResponse | ||
import no.skatteetaten.aurora.mokey.model.HealthStatus | ||
import org.intellij.lang.annotations.Language | ||
import org.junit.jupiter.api.Test | ||
|
||
class HealthResponseParserTest { | ||
|
||
@Test | ||
fun `parse flat spring-boot 1-X health endpoint response`() { | ||
@Language("JSON") | ||
val json = """{ | ||
"status": "UP", | ||
"atsServiceHelse": { | ||
"status": "UP" | ||
}, | ||
"diskSpace": { | ||
"status": "UP", | ||
"total": 10718543872, | ||
"free": 10508611584, | ||
"threshold": 10485760 | ||
}, | ||
"db": { | ||
"status": "UP", | ||
"database": "Oracle", | ||
"hello": "Hello" | ||
} | ||
}""" | ||
|
||
val response = parse(json) | ||
assertk.assert(response).isEqualTo( | ||
HealthResponse( | ||
HealthStatus.UP, | ||
mutableMapOf( | ||
"atsServiceHelse" to HealthPart(HealthStatus.UP, mutableMapOf()), | ||
"diskSpace" to HealthPart( | ||
HealthStatus.UP, mutableMapOf( | ||
"total" to LongNode.valueOf(10718543872), | ||
"threshold" to IntNode.valueOf(10485760), | ||
"free" to LongNode.valueOf(10508611584) | ||
) | ||
), | ||
"db" to HealthPart( | ||
HealthStatus.UP, mutableMapOf( | ||
"hello" to TextNode.valueOf("Hello"), | ||
"database" to TextNode.valueOf("Oracle") | ||
) | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `parse nested spring-boot 2-X health endpoint response`() { | ||
@Language("JSON") | ||
val json = """{ | ||
"status": "UP", | ||
"details": { | ||
"diskSpace": { | ||
"status": "UP", | ||
"details": { | ||
"total": 10718543872, | ||
"free": 10502053888, | ||
"threshold": 10485760 | ||
} | ||
}, | ||
"db": { | ||
"status": "UP", | ||
"details": { | ||
"database": "Oracle", | ||
"hello": "Hello" | ||
} | ||
} | ||
} | ||
}""" | ||
|
||
val response = parse(json) | ||
assertk.assert(response).isEqualTo( | ||
HealthResponse( | ||
HealthStatus.UP, | ||
mutableMapOf( | ||
"diskSpace" to HealthPart( | ||
HealthStatus.UP, mutableMapOf( | ||
"total" to LongNode.valueOf(10718543872), | ||
"threshold" to IntNode.valueOf(10485760), | ||
"free" to LongNode.valueOf(10502053888) | ||
) | ||
), | ||
"db" to HealthPart( | ||
HealthStatus.UP, mutableMapOf( | ||
"hello" to TextNode.valueOf("Hello"), | ||
"database" to TextNode.valueOf("Oracle") | ||
) | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
private fun parse(json: String) = HealthResponseParser.parse(jacksonObjectMapper().readTree(json)) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Her syns jeg det hadde vært ryddig å enten dele opp koden eller ha med named arguments. For min del begynner dette å bli såpass mye kode på en gang at jeg sliter litt med å lese det.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bare noen småting, du kan velge om du vil ta det med eller ikke :)