-
Notifications
You must be signed in to change notification settings - Fork 2
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
FDP-2359: command handling reboot #39
Conversation
846d2d4
to
9a59d1f
Compare
Signed-off-by: Jasper Kamerling <[email protected]> Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Jasper Kamerling <[email protected]> Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
79cc17b
to
8dbc12e
Compare
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
application/src/integrationTest/kotlin/org/gxf/crestdeviceservice/CoapMessageHandlingTest.kt
Outdated
Show resolved
Hide resolved
application/src/integrationTest/kotlin/org/gxf/crestdeviceservice/CoapMessageHandlingTest.kt
Outdated
Show resolved
Hide resolved
application/src/main/kotlin/org/gxf/crestdeviceservice/command/consumer/CommandConsumer.kt
Outdated
Show resolved
Hide resolved
application/src/main/kotlin/org/gxf/crestdeviceservice/command/consumer/CommandConsumer.kt
Outdated
Show resolved
Hide resolved
...ication/src/main/kotlin/org/gxf/crestdeviceservice/command/service/CommandFeedbackService.kt
Outdated
Show resolved
Hide resolved
val parts = commandInProgress.type.parts | ||
return parts.all { part -> downlink.contains(part) } |
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.
Would it be possible to use regex pattern matchers instead of parts?
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.
Refactored a bit, but without regex. Do you have a regex suggestion that improves on this?
application/src/test/kotlin/org/gxf/crestdeviceservice/command/service/CommandServiceTest.kt
Outdated
Show resolved
Hide resolved
...src/test/kotlin/org/gxf/crestdeviceservice/consumer/IncomingDeviceCredentialsConsumerTest.kt
Outdated
Show resolved
Hide resolved
application/src/test/kotlin/org/gxf/crestdeviceservice/service/DownlinkServiceTest.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
…/service/CommandServiceTest.kt Co-authored-by: Sander van der Heijden <[email protected]> Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Sander Verbruggen <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Sander Verbruggen <[email protected]>
@@ -190,7 +189,7 @@ class CoapMessageHandlingTest { | |||
} | |||
|
|||
@Test | |||
fun shouldSendCommandToProxyAndSaveWithStatusInProgress() { | |||
fun shouldSaveCommandWithStatusPendingAndSendReceivedFeedbackWhenReceivingCommandFromMaki() { |
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.
This test method should probably be moved to a different class, as it has nothing to do with handling coap messages?
const val DEVICE_ID = "device-id" | ||
const val MESSAGE_RECEIVED = "Command received" | ||
val CORRELATION_ID = UUID.randomUUID() | ||
val timestamp = Instant.now() |
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.
Consider adding a separate TestConstants class for the shared test constants.
application/src/test/kotlin/org/gxf/crestdeviceservice/command/consumer/CommandConsumerTest.kt
Outdated
Show resolved
Hide resolved
val expectedException = CommandValidationException("Command unknown") | ||
|
||
assertThatThrownBy { CommandMapper.externalCommandToCommandEntity(externalCommand, status) } | ||
.usingRecursiveComparison() | ||
.isEqualTo(expectedException) |
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.
I think I might prefer one of these possible alternatives without using recursive comparison:
- with checks on type and message:
assertThatThrownBy { CommandMapper.externalCommandToCommandEntity(externalCommand, status) }
.isInstanceOf(CommandValidationException::class.java)
.hasMessage("Command unknown: ${externalCommand.command}")
- with (likely) increased readability:
assertThatExceptionOfType(CommandValidationException::class.java)
.isThrownBy { CommandMapper.externalCommandToCommandEntity(externalCommand, status) }
.withMessage("Command unknown: ${externalCommand.command}")
- with a clearer distinction between "act" and "assert":
val actual = catchThrowable {
CommandMapper.externalCommandToCommandEntity(externalCommand, status)
}
assertThat(actual)
.isInstanceOf(CommandValidationException::class.java)
.hasMessage("Command unknown: ${externalCommand.command}")
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.
mooier inderdaad
val command = "invalid" | ||
|
||
assertThat(result).isEqualTo("REBOOT") | ||
assertThatThrownBy { CommandMapper.commandNameToType(command) } | ||
.isInstanceOf(IllegalArgumentException::class.java) |
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 even reduce this to:
assertThatIllegalArgumentException().isThrownBy {
CommandMapper.commandNameToType("invalid")
}
or more verbose with a clearer distinction between the "triple A" sections ("arrange, "act", and "assert")
val commandName = "invalid"
val actual = catchThrowable { CommandMapper.commandNameToType(commandName) }
assertThat(actual).isInstanceOf(IllegalArgumentException::class.java)
…/consumer/CommandConsumerTest.kt Co-authored-by: Sander van der Heijden <[email protected]> Signed-off-by: Loes Immens <[email protected]>
Signed-off-by: Loes Immens <[email protected]>
Quality Gate passedIssues Measures |
No description provided.