-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/maven/interne-deps-76abc52044
- Loading branch information
Showing
9 changed files
with
112 additions
and
8 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
10 changes: 10 additions & 0 deletions
10
src/main/java/no/nav/foreldrepenger/los/felles/util/RegexPatterns.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,10 @@ | ||
package no.nav.foreldrepenger.los.felles.util; | ||
|
||
public class RegexPatterns { | ||
|
||
public static final String ENHETSNUMMER = "\\d{4}"; | ||
|
||
private RegexPatterns() { | ||
throw new IllegalAccessError("Skal ikke instansieres"); | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/no/nav/foreldrepenger/los/tjenester/admin/dto/DriftAvdelingEnhetDto.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,19 @@ | ||
package no.nav.foreldrepenger.los.tjenester.admin.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import no.nav.foreldrepenger.los.felles.util.RegexPatterns; | ||
import no.nav.vedtak.sikkerhet.abac.AbacDataAttributter; | ||
import no.nav.vedtak.sikkerhet.abac.AbacDto; | ||
|
||
public record DriftAvdelingEnhetDto(@JsonProperty("avdelingEnhet") | ||
@NotNull | ||
@Pattern(regexp = RegexPatterns.ENHETSNUMMER) | ||
String avdelingEnhet) implements AbacDto { | ||
@Override | ||
public AbacDataAttributter abacAttributter() { | ||
return AbacDataAttributter.opprett(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/resources/db/migration/defaultDS/2.2/V2.2_06__avdeling_deaktivering.sql
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,4 @@ | ||
ALTER TABLE AVDELING | ||
ADD AKTIV VARCHAR(1 char) DEFAULT 'J' NOT NULL; | ||
|
||
COMMENT ON COLUMN AVDELING.AKTIV IS 'Styrer om avdeling er aktiv'; |
38 changes: 38 additions & 0 deletions
38
src/test/java/no/nav/foreldrepenger/los/organisasjon/OrganisasjonRepositoryTest.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,38 @@ | ||
package no.nav.foreldrepenger.los.organisasjon; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import no.nav.foreldrepenger.los.JpaExtension; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
@ExtendWith(JpaExtension.class) | ||
class OrganisasjonRepositoryTest { | ||
private OrganisasjonRepository repository; | ||
private EntityManager entityManager; | ||
|
||
@BeforeEach | ||
void setUp(EntityManager entityManager) { | ||
this.entityManager = entityManager; | ||
repository = new OrganisasjonRepository(entityManager); | ||
} | ||
|
||
@Test | ||
void deaktiverAvdeling() { | ||
var enhetsNummer = "4802"; | ||
var avdelinger = repository.hentAktiveAvdelinger().stream().map(Avdeling::getAvdelingEnhet); | ||
|
||
repository.deaktiverAvdeling(enhetsNummer); | ||
entityManager.flush(); // håndteres av transaksjon i rammeverk | ||
|
||
var etterDeaktiver = repository.hentAktiveAvdelinger().stream().map(Avdeling::getAvdelingEnhet); | ||
|
||
assertThat(avdelinger).contains(enhetsNummer); | ||
assertThat(etterDeaktiver).isNotEmpty().doesNotContain(enhetsNummer); | ||
} | ||
} |