-
Notifications
You must be signed in to change notification settings - Fork 19
Add StatusResponse class to handle successful response messages #1167
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
Add StatusResponse class to handle successful response messages #1167
Conversation
@Test | ||
void createStatusResponse_allFieldsProvided_Success() { | ||
// all three fields provided | ||
StatusResponse item = new StatusResponse("TestOffice", "TestMessage", "TestIdentifier123"); |
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.
Use "real" data.... At least for the office anyways. I get a real "message" could be a bit tricky.
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.
Done, used more realistic test data names.
@@ -0,0 +1,5 @@ | |||
{ |
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.
Do we actually want the officeID, there's a "CwmsBaseDTO" that CwmsDTO Derives from that intentionally doesn't include the office-id field.
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'm trying to include some relevant data other than just the response message. I assumed an office-id would be helpful to have, but I'm open to getting rid of it if we think it's unnecessary. Perhaps there's some more specific data that would be better to include instead.
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.
if you look at CdaError it contains a Map field for additional data.
... might also be worth seeing if that just needs a better name, like CdaResponse, in instead of error.
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.
Yes, I've been looking at the CdaError class. I do think I can rework/use that class to become a general message response class. Although the incidentIdentifier field in that class would be a little useless for successful responses since there won't be any error logging.
I guess this begs the question of whether or not we want to create a new class for general messages or whether or not we want to reuse the CdaError class and put some information in the details map. I think either way is probably fine.
Also, I rewrote some messages in the TurbineController class as an example of how the current StatusResponse class would be used.
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.
Now that I've worked further, I believe the two most important fields to report are the message itself and a name or ID of what was changed (created, updated, or deleted).
While it was possible to rework the CdaError class to be more generalized, I don't think that this basic status response class needs a details map or an incident identifier for error logs. Having separate classes for errors and successful responses also seems to make more sense.
Also, since there are a lot of files to update, it may be better to get this PR merged first and then I can make separate PRs to update the rest of the codebase. This might make things easier on reviewers as well.
cwms-data-api/src/main/java/cwms/cda/data/dto/StatusResponse.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/TurbineController.java
Outdated
Show resolved
Hide resolved
…age, update tests and TurbineController accordingly
…e work still necessary)
cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/StreamLocationController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/watersupply/WaterContractTypeCreateController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/WaterContractControllerTestIT.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/PropertyController.java
Outdated
Show resolved
Hide resolved
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.
Please do not add additional controller changes to this PR. It's already rather long.
For clarity I mean updates to the new scheme, fixes and additional change may be expected. |
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class, aliases = {Formats.DEFAULT, Formats.JSON}) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) | ||
public final class StatusResponse extends CwmsDTO{ |
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.
why was this set back to CwmsDTO from CwmsDTOBase?
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.
We looked over everything again, and decided that the office-id field is useful to include since almost everything is office specific. There was really no additional overhead to requiring the office-id field.
Also, every controller has an office-id with easy access. I checked all the instances of where I'm going to be implementing StatusResponse and I couldn't find a case where I wouldn't be able to grab an office-id.
cwms-data-api/src/main/java/cwms/cda/api/MeasurementController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/location/kind/OutletController.java
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/MeasurementControllerTestIT.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/MeasurementControllerTestIT.java
Outdated
Show resolved
Hide resolved
…eChanges, and StreamReach Controllers. Update Tests accordingly.
…, TurbineChanges, and StreamReach Controllers. Update Tests accordingly." This reverts commit 7a9513b.
… delete response bodies
cwms-data-api/src/main/java/cwms/cda/api/StreamLocationController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/api/LookupTypeController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/StreamLocationControllerTestIT.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/WaterContractControllerTestIT.java
Outdated
Show resolved
Hide resolved
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.
Changes look good
Fixes #1112
Saving the last 5 tasks for a separate PR (This one is too long already)