Skip to content

Commit

Permalink
Replaced Mockito.mock by creating actual object
Browse files Browse the repository at this point in the history
Signed-off-by: Kanu <[email protected]>
  • Loading branch information
Kanu authored and kanumalivad committed Oct 11, 2024
1 parent f83f477 commit 09a35b8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mockito;

import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

class VertxGeneratorIsApplicableTest {
Expand All @@ -38,8 +36,10 @@ class VertxGeneratorIsApplicableTest {

@BeforeEach
void setUp() {
project = mock(JavaProject.class, Mockito.RETURNS_DEEP_STUBS);
context = mock(GeneratorContext.class, Mockito.RETURNS_DEEP_STUBS);
project = JavaProject.builder().build();
context = GeneratorContext.builder()
.project(project)
.build();
when(context.getProject()).thenReturn(project);
}

Expand All @@ -56,8 +56,9 @@ static Stream<Arguments> data() {
@MethodSource("data")
void isApplicable(String testDescription, List<Plugin> pluginList, List<Dependency> dependencyList, boolean expectedValue) {
// Given
when(project.getPlugins()).thenReturn(pluginList);
when(project.getDependencies()).thenReturn(dependencyList);
context = context.toBuilder()
.project(project.toBuilder().plugins(pluginList).dependencies(dependencyList).build())
.build();
// When
final boolean result = new VertxGenerator(context).isApplicable(Collections.emptyList());
// Then
Expand Down

0 comments on commit 09a35b8

Please sign in to comment.