Skip to content

OBPIH-6300 Add tests for mapping requestor's dashboard statuses#4585

Merged
awalkowiak merged 2 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6300-tests
Apr 19, 2024
Merged

OBPIH-6300 Add tests for mapping requestor's dashboard statuses#4585
awalkowiak merged 2 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-6300-tests

Conversation

@alannadolny
Copy link
Collaborator

No description provided.


// Because this function needs to handle more than one enum, I left the argument's type as def
static String getTranslatedDisplayStatus(def status) {
String getTranslatedDisplayStatus(def status) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get a chance to review this but could you please change the implementation of this method to be ...

   return applicationTagLib.message(code: 'enum.' + status?.class?.simpleName + '.' + status)

Also why do we need a second method to get the translated display status when the original getDisplayStatus() method already does the localization?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why do we need a second method to get the translated display status when the original getDisplayStatus() method already does the localization?

I am not sure if I understand what you mean, but I moved this to a separate function because I wanted to make the code more clean 🤔

void 'StockMovement.getDisplayStatus() should return: #expected for requisition status #status'() {
when:
StockMovement stockMovement = new StockMovement() {
@Override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on these tests!

In general I'm not the hugest fan of overriding methods in a test like this. Usually I'd try to Stub out the tagLib but it doesn't look like that'd be easy to do since it's fetched statically in the StockMovement. You could maybe Stub the StockMovemnt instance itself with something like:

StockMovement stockMovement = Stub(StockMovement) {
            getTranslatedDisplayStatus(def status) >> status.name()
        }

but that's essentially what you're doing anyways with your override (and I don't even know if the above code would work). I'm okay with your approach here.

Yay tests!

@awalkowiak awalkowiak merged commit dde94b5 into feature/upgrade-to-grails-3.3.10 Apr 19, 2024
@awalkowiak awalkowiak deleted the OBPIH-6300-tests branch April 19, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants