-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for the format parameter #1299
base: develop
Are you sure you want to change the base?
Conversation
Test Results 69 files ±0 69 suites ±0 1m 23s ⏱️ -1s Results for commit 873b29e. ± Comparison against base commit a76f793. This pull request removes 189 and adds 34 tests. Note that renamed tests count towards both.
|
Quality Gate passedIssues Measures |
@@ -28,9 +29,14 @@ data class NgsiLdDataRepresentation( | |||
acceptMediaType: MediaType | |||
): NgsiLdDataRepresentation { | |||
val optionsParam = queryParams.getOrDefault(QueryParameter.OPTIONS.key, emptyList()) | |||
val formatParam = queryParams.getOrDefault(QueryParameter.FORMAT.key, emptyList()) | |||
val attributeRepresentation = when { |
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.
since you are in it and since it is very related, also add support for the simplified
value for the format
query param (synonym of keyValues
)
package com.egm.stellio.shared.queryparameter | ||
|
||
enum class FormatValue(val value: String) { | ||
KEY_VALUES("keyValues"), |
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.
don't forget to remove it in the OptionsValues
enum
KEY_VALUES("keyValues"), | ||
NORMALIZED("normalized"), | ||
TEMPORAL_VALUES("temporalValues"), | ||
AGGREGATED_VALUES("aggregatedValues") |
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.
TEMPORAL_VALUES
and AGGREGATED_VALUES
are unused, this is problematic
TEMPORAL_VALUES("temporalValues"), | ||
AUDIT("audit"), | ||
AGGREGATED_VALUES("aggregatedValues") | ||
} | ||
|
||
fun hasValueInOptionsParam(options: Optional<String>, optionValue: OptionsParamValue): Boolean = | ||
fun hasValueInQueryParam(options: Optional<String>, queryParamValue: QueryParamValue): Boolean = |
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.
options
is no longer a good name for the 1st parameter
@@ -168,16 +168,16 @@ internal fun canExpandJsonLdKeyFromCore(contexts: List<String>): Boolean { | |||
return expandedType == NGSILD_DATASET_ID_PROPERTY | |||
} | |||
|
|||
enum class OptionsParamValue(val value: String) { | |||
enum class QueryParamValue(val value: String) { |
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.
TEMPORAL_VALUES
and AGGREGATED_VALUES
should be moved / merged in FormatValue
. AUDIT
should be moved / merged in OptionsValue
@@ -33,27 +33,27 @@ class ApiUtilsTests { | |||
|
|||
@Test | |||
fun `it should not find a value if there is no options query param`() { |
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.
also update the names of the test functions (options
is no longer valid)
@@ -480,6 +480,47 @@ class EntityHandlerTests { | |||
) | |||
} | |||
|
|||
@Test | |||
fun `get entity by id should correctly return the representation asked in the format parameter`() { |
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.
better add one or more tests on the parseRepresentations
function in NgsiLdDataRepresentation
@@ -45,18 +45,22 @@ fun composeTemporalEntitiesQueryFromGet( | |||
|
|||
if (inQueryEntities) | |||
entitiesQueryFromGet.validateMinimalQueryEntitiesParameters().bind() | |||
val optionsParam = Optional.ofNullable(requestParams.getFirst(QueryParameter.OPTIONS.key)) | |||
val formatParam = Optional.ofNullable(requestParams.getFirst(QueryParameter.FORMAT.key)) | |||
val withTemporalValues = when { |
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.
you could take this opportunity to return an APIException
if both temporalValues
and aggregatedValues
are provided
No description provided.