eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
734 stars 480 forks source link

ResourceConfigTest : Replace AssertJ's deprecated asList() DSL method with asInstanceOf(InstanceOfAssertFactories.list(type.class)) #3397

Open ShivamChavan01 opened 17 hours ago

ShivamChavan01 commented 17 hours ago

Component

JKube Kit

Task description

Description

In the latest versions of Assertj asList() DSL method has been marked as deprecated: The class ResourceConfigTest presents the issue: Usage of the deprecated method asList() from AssertJ.

The following lines of code: https://github.com/eclipse-jkube/jkube/blob/d2afc38505144ef4d5c1ff084d8e8ab83e9e5637/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/ResourceConfigTest.java#L154-L155

https://github.com/eclipse-jkube/jkube/blob/d2afc38505144ef4d5c1ff084d8e8ab83e9e5637/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/ResourceConfigTest.java#L160-L161

https://github.com/eclipse-jkube/jkube/blob/d2afc38505144ef4d5c1ff084d8e8ab83e9e5637/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/ResourceConfigTest.java#L179-L180

https://github.com/eclipse-jkube/jkube/blob/d2afc38505144ef4d5c1ff084d8e8ab83e9e5637/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/ResourceConfigTest.java#L183-L184

users are advised to use asInstanceOf(InstanceOfAssertFactories.list(type.class)) instead, we need to update asList() calls with this.

Expected Behavior

AssertJ's asList() is replaced with asInstanceOf(InstanceOfAssertFactories.list(type.class))

Acceptance Criteria

ShivamChavan01 commented 17 hours ago

Hi @rohanKanojia, Could I please get assigned to the relevant issue?
I’ve tested the code using the asInstanceOf()method, and it works fine! Screenshot 2024-09-21 142059

I would appreciate your advice regarding the following line of code: https://github.com/eclipse-jkube/jkube/blob/d2afc38505144ef4d5c1ff084d8e8ab83e9e5637/jkube-kit/config/resource/src/test/java/org/eclipse/jkube/kit/config/resource/ResourceConfigTest.java#L135

Can I replace this line with: .asInstanceOf(InstanceOfAssertFactories.list(VolumeConfig.class)) .singleElement()

rohanKanojia commented 11 hours ago

Can I replace this line with

@ShivamChavan01 : I don't think we need to make this change as we're already passing an object of List type to assertThat

ShivamChavan01 commented 11 hours ago

Okay what About the Above Changes Can i Make it ??

rohanKanojia commented 11 hours ago

It's a bit strange as I don't see sonar complaining about these occurrences of asList . Although refactoring them like you suggested should do no harm.

ShivamChavan01 commented 11 hours ago

It's a bit strange as I don't see sonar complaining about these occurrences of asList . Although refactoring them like you suggested should do no harm.

Yeah I agree,if you think it's a good idea to proceed with the refactoring with the latest AssertJ practices, I'd be happy to make those changes. Could you please confirm if I should go ahead with it?