eclipse-jkube / jkube

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

VertxGeneratorIsApplicableTest : Replace `Mockito.mock` by creating actual object #3405

Open rohanKanojia opened 1 week ago

rohanKanojia commented 1 week ago

Component

JKube Kit

Task description

Component

JKube Kit

Task description

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

VertxGeneratorIsApplicableTest seems to be using mock here :

https://github.com/eclipse-jkube/jkube/blob/dad4cc61149c435dbf91a5700a2c7f7cfe7d9a99/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java#L41

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/dad4cc61149c435dbf91a5700a2c7f7cfe7d9a99/jkube-kit/jkube-kit-vertx/src/test/java/org/eclipse/jkube/vertx/generator/VertxGeneratorIsApplicableTest.java#L59-L60

context = context.toBuilder()
  .project(project.toBuilder().plugins(pluginList).dependencies(dependencyList).build())
  .build();

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

Expected Behavior

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

Acceptance Criteria

kanumalivad commented 2 days ago

Hi @rohanKanojia, Can you assign this to me ?