-
Notifications
You must be signed in to change notification settings - Fork 1
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-2929 ~ Adds alarm command handling and ... #44
Conversation
smvdheijden
commented
Jan 23, 2025
- Refactors command handling
- Updates dependency management to use toml file
- Replaces mockito by mockK
* Refactors command handling * Updates dependency management to use toml file * Replaces mockito by mockK Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
...n/src/main/kotlin/org/gxf/crestdevicesimulator/simulator/data/entity/AlarmThresholdValues.kt
Outdated
Show resolved
Hide resolved
application/src/main/kotlin/org/gxf/crestdevicesimulator/simulator/message/MessageHandler.kt
Outdated
Show resolved
Hide resolved
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ValueSource | ||
|
||
class AlarmCommandHandlerTest { |
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.
testing command failures?
...n/src/main/kotlin/org/gxf/crestdevicesimulator/simulator/data/entity/AlarmThresholdValues.kt
Outdated
Show resolved
Hide resolved
application/src/main/kotlin/org/gxf/crestdevicesimulator/simulator/message/MessageHandler.kt
Outdated
Show resolved
Hide resolved
application/src/main/kotlin/org/gxf/crestdevicesimulator/simulator/message/MessageHandler.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/org/gxf/crestdevicesimulator/simulator/response/handlers/AlarmCommandHandler.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/org/gxf/crestdevicesimulator/simulator/response/handlers/AlarmCommandHandler.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Sander van der Heijden <[email protected]>
simulatorState.addDownlink(command) | ||
} catch (ex: Exception) { | ||
logger.error { ex } |
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 would except the error logging of the exception at the point where the InvalidCommandException is caught -> in or above handleFailure().
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 notation only logs ex.toString()
. Use logger.error(ex) { "Your message here" }
for full stack trace
} catch (ex: InvalidCommandException) { | ||
handleFailure(command, simulatorState) | ||
} | ||
if (!canHandleCommand(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.
This check is already done in the MessageHandler, right before handleCommand() is called.
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.
Agree with Loes and defensive programming can be used as an argument to double check. This can be done in a more concise way in Kotlin:
require(canHandleCommand(command)) { "Alarm command handler can not handle command: $command" }
This throws an IllegalArgumentException
Signed-off-by: Sander van der Heijden <[email protected]>
Signed-off-by: Sander van der Heijden <[email protected]>
@@ -3,7 +3,7 @@ | |||
// SPDX-License-Identifier: Apache-2.0 | |||
package org.gxf.crestdevicesimulator.simulator.response.handlers | |||
|
|||
import org.assertj.core.api.Assertions.assertThat | |||
import org.assertj.core.api.Assertions.* |
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.
separate imports
Signed-off-by: Sander van der Heijden <[email protected]>
|