eclipse-jkube / jkube

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

WildflyJARGeneratorTest : Replace `Mockito.mock` by creating actual object #3362

Closed rohanKanojia closed 1 month ago

rohanKanojia commented 2 months ago

Component

JKube Kit

Task description

Related to https://github.com/eclipse/jkube/issues/2316

WildflyJARGeneratorTest seems to be using mock here :

https://github.com/eclipse-jkube/jkube/blob/c2c9a0cdd076fbeb25087a6598b448b5271d6293/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java#L57-L58

This can easily be refactored to use real object using lombok builders:

      project = JavaProject.builder().build();
      context = GeneratorContext.builder()
        .project(project)
        .build();

Similarly these when( statements can also be replaced with builder calls like this:

https://github.com/eclipse-jkube/jkube/blob/c2c9a0cdd076fbeb25087a6598b448b5271d6293/jkube-kit/jkube-kit-wildfly-jar/src/test/java/org/eclipse/jkube/wildfly/jar/generator/WildflyJARGeneratorTest.java#L251-L254

      context = context.toBuilder()
        .project(JavaProject.builder()
          .outputDirectory(temporaryFolder.toFile())
          .plugins(Collections.emptyList())
          .version("1.0.0")
          .build())
        .build();

Usage of org.mockito.Mockito.mock and org.mockito.Mockito.when is removed from WildflyJARGeneratorTest

Expected Behavior

Usages of Mockito.mock and Mockito.when are removed from WildflyJARGeneratorTest

Acceptance Criteria

vijaybhagwat24 commented 2 months ago

Hi, kindly assign this to me.