Skip to content

Commit

Permalink
Add mocks for brukerService in TestgruppeControllerGetTest to ensure …
Browse files Browse the repository at this point in the history
…proper user handling #deploy-test-dolly-backend #deploy-dolly-backend
  • Loading branch information
krharum committed Feb 28, 2025
1 parent b2d5da2 commit 7a8c85c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import java.util.Random;
import java.util.Set;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down Expand Up @@ -41,6 +41,8 @@ void shouldGetTestgrupperWithNavIdent()
throws Exception {

var bruker = super.createBruker();
when(brukerService.fetchOrCreateBruker(any())).thenReturn(bruker);
when(brukerService.fetchBruker(any())).thenReturn(bruker);

var testgruppe1 = super.createTestgruppe("Gruppen er ikke en favoritt", bruker);
var testgruppe2 = super.createTestgruppe("Gruppen er en favoritt", bruker);
Expand Down

0 comments on commit 7a8c85c

Please sign in to comment.