-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
9 changed files
with
125 additions
and
22 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
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
50 changes: 50 additions & 0 deletions
50
shared/src/test/kotlin/com/egm/stellio/shared/model/NgsiLdDataRepresentationTest.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,50 @@ | ||
package com.egm.stellio.shared.model | ||
|
||
import com.egm.stellio.shared.model.NgsiLdDataRepresentation.Companion.parseRepresentations | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.http.MediaType | ||
import org.springframework.test.context.ActiveProfiles | ||
import org.springframework.util.LinkedMultiValueMap | ||
|
||
@ActiveProfiles("test") | ||
class NgsiLdDataRepresentationTest { | ||
|
||
@Test | ||
fun `it should return the attribute representation in the format query param when options exist`() { | ||
val queryParams = LinkedMultiValueMap<String, String>() | ||
queryParams.add("timerel", "after") | ||
queryParams.add("timeAt", "2025-01-03T07:45:24Z") | ||
queryParams.add("options", "simplified") | ||
queryParams.add("format", "normalized") | ||
|
||
val parsedRepresentation = parseRepresentations(queryParams, MediaType.APPLICATION_JSON) | ||
|
||
assertEquals(AttributeRepresentation.NORMALIZED, parsedRepresentation.attributeRepresentation) | ||
} | ||
|
||
@Test | ||
fun `it should return the attribute representation in the options query param when no format is given`() { | ||
val queryParams = LinkedMultiValueMap<String, String>() | ||
queryParams.add("timerel", "after") | ||
queryParams.add("timeAt", "2025-01-03T07:45:24Z") | ||
queryParams.add("options", "simplified") | ||
|
||
val parsedRepresentation = parseRepresentations(queryParams, MediaType.APPLICATION_JSON) | ||
|
||
assertEquals(AttributeRepresentation.SIMPLIFIED, parsedRepresentation.attributeRepresentation) | ||
} | ||
|
||
@Test | ||
fun `it should return the attribute representation in the first format query param`() { | ||
val queryParams = LinkedMultiValueMap<String, String>() | ||
queryParams.add("timerel", "after") | ||
queryParams.add("timeAt", "2025-01-03T07:45:24Z") | ||
queryParams.add("format", "simplified") | ||
queryParams.add("format", "normalized") | ||
|
||
val parsedRepresentation = parseRepresentations(queryParams, MediaType.APPLICATION_JSON) | ||
|
||
assertEquals(AttributeRepresentation.SIMPLIFIED, parsedRepresentation.attributeRepresentation) | ||
} | ||
} |
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