-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TFP-5481: Mulighet for å reservere og avreservere en oppgave. (#1288)
- Loading branch information
Showing
8 changed files
with
172 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...klient/src/main/java/no/nav/vedtak/felles/integrasjon/oppgave/v1/OppdaterReservasjon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package no.nav.vedtak.felles.integrasjon.oppgave.v1; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
@JsonInclude() | ||
public record OppdaterReservasjon(Long id, Integer versjon, String tilordnetRessurs) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../src/test/java/no/nav/vedtak/felles/integrasjon/oppgave/v1/AbstractOppgaveKlientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package no.nav.vedtak.felles.integrasjon.oppgave.v1; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import no.nav.vedtak.felles.integrasjon.rest.RestClient; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestClientConfig; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestRequest; | ||
import no.nav.vedtak.felles.integrasjon.rest.TokenFlow; | ||
import no.nav.vedtak.mapper.json.DefaultJsonMapper; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class AbstractOppgaveKlientTest { | ||
private Oppgaver oppgaver; | ||
|
||
@Mock | ||
private RestClient restKlient; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
// Service setup | ||
oppgaver = new TestOppgave(restKlient); | ||
} | ||
|
||
private static final String json = """ | ||
{ | ||
"id": 357736794, | ||
"tildeltEnhetsnr":"1234", | ||
"opprettetAvEnhetsnr":"1234", | ||
"saksreferanse":"152200771", | ||
"aktoerId":"1000000000000", | ||
"beskrivelse":"Må behandle sak i VL!", | ||
"temagruppe":"FMLI", | ||
"tema":"FOR", | ||
"behandlingstema":"ab0326", | ||
"oppgavetype":"BEH_SAK", | ||
"versjon":1, | ||
"opprettetAv":"srvengangsstonad", | ||
"prioritet":"NORM", | ||
"status": "OPPRETTET", | ||
"metadata":{}, | ||
"fristFerdigstillelse":"2023-01-23", | ||
"aktivDato":"2023-01-22", | ||
"opprettetTidspunkt":"2023-01-22T18:52:45.206+01:00" | ||
} | ||
"""; | ||
|
||
@SuppressWarnings("resource") | ||
@Test | ||
void skal_returnere_dokumentoversikt_fagsak() { | ||
var captor = ArgumentCaptor.forClass(RestRequest.class); | ||
|
||
when(restKlient.send(any(RestRequest.class), eq(Oppgave.class))).thenReturn(DefaultJsonMapper.fromJson(json, Oppgave.class)); | ||
when(restKlient.sendExpectConflict(captor.capture(), eq(String.class))).thenReturn("test"); | ||
|
||
oppgaver.reserverOppgave("1", "testSbh"); | ||
|
||
var rq = captor.getValue(); | ||
rq.validateDelayedHeaders(Set.of("Authorization")); | ||
} | ||
|
||
@RestClientConfig(tokenConfig = TokenFlow.AZUREAD_CC, endpointProperty = "OPPGAVE_GRUNNLAG_URL", endpointDefault = "http://oppgave.tbd/", scopesProperty = "OPPGAVE_GRUNNLAG_SCOPES", scopesDefault = "api://prod-fss.tbd.oppgave/.default") | ||
private static class TestOppgave extends AbstractOppgaveKlient { | ||
public TestOppgave(RestClient restKlient) { | ||
super(restKlient); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...nt/src/test/java/no/nav/vedtak/felles/integrasjon/oppgave/v1/OppdaterReservasjonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package no.nav.vedtak.felles.integrasjon.oppgave.v1; | ||
|
||
import no.nav.vedtak.mapper.json.DefaultJsonMapper; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class OppdaterReservasjonTest { | ||
|
||
@Test | ||
void reservasjonSerdes() { | ||
var testBruker = "testBruker"; | ||
var objekt = new OppdaterReservasjon(1L, 1, testBruker); | ||
|
||
var ser = DefaultJsonMapper.toJson(objekt); | ||
|
||
assertThat(ser).contains(String.format("{\"id\":1,\"versjon\":1,\"tilordnetRessurs\":\"%s\"}",testBruker)); | ||
|
||
var des = DefaultJsonMapper.fromJson(ser, OppdaterReservasjon.class); | ||
|
||
assertThat(des.tilordnetRessurs()).isEqualTo(testBruker); | ||
} | ||
|
||
@Test | ||
void avreservasjonSerdes() { | ||
var patchObjekt = new OppdaterReservasjon(1L, 1, null); | ||
|
||
var ser = DefaultJsonMapper.toJson(patchObjekt); | ||
|
||
assertThat(ser).contains("{\"id\":1,\"versjon\":1,\"tilordnetRessurs\":null}"); | ||
|
||
var des = DefaultJsonMapper.fromJson(ser, OppdaterReservasjon.class); | ||
|
||
assertThat(des.tilordnetRessurs()).isNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters