Skip to content

Commit

Permalink
Merge branch 'master' into TFP-5929_VurderePermisjon
Browse files Browse the repository at this point in the history
  • Loading branch information
AnjaAalerud authored Jan 30, 2025
2 parents adc3d4a + 41b0c0d commit c8683dc
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static no.nav.foreldrepenger.domene.modell.BeregningAktivitetOverstyring
private static no.nav.foreldrepenger.domene.modell.BeregningAktivitetOverstyring mapAktivitetOverstyring(BeregningAktivitetOverstyringEntitet beregningAktivitetOverstyringEntitet) {
return no.nav.foreldrepenger.domene.modell.BeregningAktivitetOverstyring.builder()
.medArbeidsgiver(beregningAktivitetOverstyringEntitet.getArbeidsgiver().orElse(null))
.medArbeidsforholdRef(beregningAktivitetOverstyringEntitet.getArbeidsforholdRef())
.medArbeidsforholdRef(beregningAktivitetOverstyringEntitet.getArbeidsforholdRef() == null ? InternArbeidsforholdRef.nullRef() : beregningAktivitetOverstyringEntitet.getArbeidsforholdRef())
.medHandling(beregningAktivitetOverstyringEntitet.getHandling())
.medOpptjeningAktivitetType(beregningAktivitetOverstyringEntitet.getOpptjeningAktivitetType())
.medPeriode(ÅpenDatoIntervallEntitet.fraOgMedTilOgMed(beregningAktivitetOverstyringEntitet.getPeriode().getFomDato(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class AksjonspunktRestTjeneste {
static final String BASE_PATH = "/behandling";
private static final String AKSJONSPUNKT_OVERSTYR_PART_PATH = "/aksjonspunkt/overstyr";
public static final String AKSJONSPUNKT_OVERSTYR_PATH = BASE_PATH + AKSJONSPUNKT_OVERSTYR_PART_PATH;
private static final String AKSJONSPUNKT_BESLUTT_PART_PATH = "/aksjonspunkt/beslutt";
public static final String AKSJONSPUNKT_BESLUTT_PATH = BASE_PATH + AKSJONSPUNKT_BESLUTT_PART_PATH;
private static final String AKSJONSPUNKT_PART_PATH = "/aksjonspunkt";
public static final String AKSJONSPUNKT_PATH = BASE_PATH + AKSJONSPUNKT_PART_PATH;
private static final String AKSJONSPUNKT_V2_PART_PATH = "/aksjonspunkt-v2";
Expand Down Expand Up @@ -129,6 +131,13 @@ public Response bekreft(@Context HttpServletRequest request,
@Parameter(description = "Liste over aksjonspunkt som skal bekreftes, inklusiv data som trengs for å løse de.") @Valid BekreftedeAksjonspunkterDto apDto)
throws URISyntaxException {

if (apDto.getBekreftedeAksjonspunktDtoer().stream().anyMatch(a -> a.getAksjonspunktDefinisjon() == AksjonspunktDefinisjon.FATTER_VEDTAK)) {
LOG.info("Bekreft kalles for fatter vedtak"); //Endre til exception når frontend ikke har cachet lenke
}
return bekreftAksjonspunkt(request, apDto);
}

private Response bekreftAksjonspunkt(HttpServletRequest request, BekreftedeAksjonspunkterDto apDto) throws URISyntaxException {
var bekreftedeAksjonspunktDtoer = apDto.getBekreftedeAksjonspunktDtoer();

var behandling = behandlingRepository.hentBehandling(apDto.getBehandlingUuid());
Expand Down Expand Up @@ -178,6 +187,27 @@ public Response overstyr(@Context HttpServletRequest request,
return Redirect.tilBehandlingPollStatus(request, behandling.getUuid());
}

@POST
@Path(AKSJONSPUNKT_BESLUTT_PART_PATH)
@Consumes(MediaType.APPLICATION_JSON)
@Operation(description = "Lagre totrinnsvurdering aksjonspunkt", tags = "aksjonspunkt")
@BeskyttetRessurs(actionType = ActionType.UPDATE, resourceType = ResourceType.FAGSAK)
public Response beslutt(@Context HttpServletRequest request,
@TilpassetAbacAttributt(supplierClass = BekreftetAbacDataSupplier.class)
@Parameter(description = "Liste over aksjonspunkt som skal bekreftes, inklusiv data som trengs for å løse de.") @Valid BekreftedeAksjonspunkterDto apDto)
throws URISyntaxException {

var bekreftedeAksjonspunktDtoer = apDto.getBekreftedeAksjonspunktDtoer();
if (bekreftedeAksjonspunktDtoer.size() > 1) {
throw new IllegalArgumentException("Forventer kun ett aksjonspunkt");
}
var bekreftetAksjonspunktDto = bekreftedeAksjonspunktDtoer.stream().findFirst().orElseThrow();
if (bekreftetAksjonspunktDto.getAksjonspunktDefinisjon() != AksjonspunktDefinisjon.FATTER_VEDTAK) {
throw new IllegalArgumentException("Forventer aksjonspunkt FATTER_VEDTAK");
}
return bekreftAksjonspunkt(request, apDto);
}

private static void validerBetingelserForAksjonspunkt(Behandling behandling, Collection<? extends AksjonspunktKode> aksjonspunktDtoer) {
// TODO (FC): skal ikke ha spesfikke pre-conditions inne i denne tjenesten (sjekk på status FATTER_VEDTAK). Se om kan håndteres annerledes.
if (behandling.getStatus().equals(BehandlingStatus.FATTER_VEDTAK) && !erFatteVedtakAkpt(aksjonspunktDtoer)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,13 @@ public ArbeidsgiverOversiktDto getArbeidsgiverOpplysninger(@TilpassetAbacAttribu
});

if (behandling.erAvsluttet() || behandlingskontrollTjeneste.erIStegEllerSenereSteg(behandling.getId(), BehandlingStegType.SIMULER_OPPDRAG)) {
var simuleringResultatDto = fpOppdragRestKlient.hentSimuleringResultatMedOgUtenInntrekk(behandling.getId());
arbeidsgivere.addAll(simuleringResultatDto.map(this::finnArbeidsgivereFraSimulering).orElse(Collections.emptySet()));
try {
var simuleringResultatDto = fpOppdragRestKlient.hentSimuleringResultatMedOgUtenInntrekk(behandling.getId());
arbeidsgivere.addAll(simuleringResultatDto.map(this::finnArbeidsgivereFraSimulering).orElse(Collections.emptySet()));
} catch (Exception e) {
// Do nothing
}

}

if (!overstyrtNavn.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private BehandlingDto lagBehandlingDto(Behandling behandling,

// Totrinnsbehandling
if (!BehandlingType.INNSYN.equals(behandling.getType()) && BehandlingStatus.FATTER_VEDTAK.equals(behandling.getStatus())) {
dto.leggTil(post(AksjonspunktRestTjeneste.AKSJONSPUNKT_PATH, "bekreft-totrinnsaksjonspunkt", uuidDto));
dto.leggTil(post(AksjonspunktRestTjeneste.AKSJONSPUNKT_BESLUTT_PATH, "bekreft-totrinnsaksjonspunkt", uuidDto));
}

// Brev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private FagsakBehandlingDto lagBehandlingDto(Behandling behandling,
if (BehandlingStatus.FATTER_VEDTAK.equals(behandling.getStatus())) {
dto.setTotrinnskontrollÅrsaker(totrinnskontrollTjeneste.hentTotrinnsSkjermlenkeContext(behandling, behandlingsresultat));
dto.setTotrinnskontrollReadonly(false);
dto.leggTil(post(AksjonspunktRestTjeneste.AKSJONSPUNKT_PATH, "bekreft-totrinnsaksjonspunkt", uuidDto));
dto.leggTil(post(AksjonspunktRestTjeneste.AKSJONSPUNKT_BESLUTT_PATH, "bekreft-totrinnsaksjonspunkt", uuidDto));
} else if (BehandlingStatus.UTREDES.equals(behandling.getStatus())) {
dto.setTotrinnskontrollÅrsaker(totrinnskontrollTjeneste.hentTotrinnsvurderingSkjermlenkeContext(behandling, behandlingsresultat));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.foreldrepenger.web.app.tjenester.behandling.aksjonspunkt;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
Expand All @@ -8,6 +9,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.net.URISyntaxException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -30,6 +32,7 @@
import no.nav.foreldrepenger.familiehendelse.aksjonspunkt.dto.BekreftTerminbekreftelseAksjonspunktDto;
import no.nav.foreldrepenger.familiehendelse.aksjonspunkt.dto.SjekkManglendeFodselDto;
import no.nav.foreldrepenger.familiehendelse.aksjonspunkt.dto.UidentifisertBarnDto;
import no.nav.foreldrepenger.web.app.tjenester.behandling.uttak.dto.FastsetteUttakDto;
import no.nav.foreldrepenger.web.app.tjenester.behandling.vedtak.aksjonspunkt.AksjonspunktGodkjenningDto;
import no.nav.vedtak.exception.FunksjonellException;

Expand Down Expand Up @@ -123,6 +126,21 @@ void skal_ikke_kunne_bekrefte_andre_aksjonspunkt_ved_status_fatter_vedtak() {
assertThrows(FunksjonellException.class, () -> aksjonspunktRestTjeneste.bekreft(request, dto));
}

@Test
void skal_kunne_sende_fatte_vedtak_til_beslutter_endepunkt() throws URISyntaxException {
aksjonspunktRestTjeneste.beslutt(mock(HttpServletRequest.class), BekreftedeAksjonspunkterDto.lagDto(behandlingUuid, behandlingVersjon,
List.of(new FatterVedtakAksjonspunktDto(begrunnelse, List.of(new AksjonspunktGodkjenningDto())))));

verify(aksjonspunktTjenesteMock).bekreftAksjonspunkter(ArgumentMatchers.anyCollection(), anyLong());
}

@Test
void skal_ikke_kunne_sende_fatte_vedtak_til_beslutter_endepunkt() {
assertThatThrownBy(() -> aksjonspunktRestTjeneste.beslutt(mock(HttpServletRequest.class),
BekreftedeAksjonspunkterDto.lagDto(behandlingUuid, behandlingVersjon,
List.of(new FastsetteUttakDto.FastsetteUttakPerioderDto(List.of()))))).isExactlyInstanceOf(IllegalArgumentException.class);
}

private AksjonspunktGodkjenningDto opprettetGodkjentAksjonspunkt() {
var endretDto = new AksjonspunktGodkjenningDto();
endretDto.setAksjonspunktKode(AksjonspunktDefinisjon.SJEKK_MANGLENDE_FØDSEL);
Expand Down

0 comments on commit c8683dc

Please sign in to comment.