Skip to content

Commit

Permalink
remove spymocks and replace their functionality using @import
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Jan 7, 2025
1 parent 4ae5f8c commit 4872499
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
Expand All @@ -30,13 +31,13 @@
@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
@WebMvcTest(AlignmentController.class)
@Import(AlignmentSelectionMapper.class)
class AlignmentControllerIT {
@Autowired
private MockMvc mvc;

@MockitoBean
private AlignmentSelectionBusinessService alignmentSelectionBusinessService;
@MockitoSpyBean
private AlignmentSelectionMapper alignmentSelectionMapper;

static String alignmentObjectiveName = "Objective 5";
static List<AlignmentSelection> alignmentSelectionPuzzle = List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
Expand All @@ -37,6 +38,7 @@
@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
@WebMvcTest(CheckInController.class)
@Import(DeserializerHelper.class)
class CheckInControllerIT {
@Autowired
private MockMvc mvc;
Expand All @@ -46,8 +48,6 @@ class CheckInControllerIT {
private CheckInMapper checkInMapper;
@MockitoBean
private KeyResultBusinessService keyResultBusinessService;
@MockitoSpyBean
DeserializerHelper deserializerHelper;

@BeforeEach
void setUp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
Expand All @@ -48,6 +49,7 @@
@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
@WebMvcTest(KeyResultController.class)
@Import(DeserializerHelper.class)
class KeyResultControllerIT {

@MockitoBean
Expand All @@ -66,8 +68,6 @@ class KeyResultControllerIT {
ObjectivePersistenceService objectivePersistenceService;
@MockitoBean
private KeyResultBusinessService keyResultBusinessService;
@MockitoSpyBean
DeserializerHelper deserializerHelper;
@Autowired
private MockMvc mvc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

import ch.puzzle.okr.mapper.AlignmentSelectionMapper;
import ch.puzzle.okr.mapper.OverviewMapper;
import ch.puzzle.okr.models.overview.Overview;
import ch.puzzle.okr.models.overview.OverviewId;
Expand All @@ -24,6 +25,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
Expand All @@ -34,14 +36,12 @@
@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
@WebMvcTest(OverviewController.class)
@Import(OverviewMapper.class)
class OverviewControllerIT {
@Autowired
private MockMvc mvc;
@MockitoBean
private OverviewAuthorizationService overviewAuthorizationService;
// Dashboard and OverviewMapper are required for testing
@MockitoSpyBean
private OverviewMapper overviewMapper;

public static final String PUZZLE = "Puzzle";
public static final String DESCRIPTION = "This is a description";
Expand Down

0 comments on commit 4872499

Please sign in to comment.