Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POFIM-98: Lager en fager-api-mock for backend og frontend #1531

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import no.nav.foreldrepenger.vtp.testmodell.repo.BasisdataProvider;
import no.nav.foreldrepenger.vtp.testmodell.repo.TestscenarioBuilderRepository;
import no.nav.foreldrepenger.vtp.testmodell.repo.impl.BasisdataProviderFileImpl;
import no.nav.foreldrepenger.vtp.testmodell.repo.impl.TestscenarioRepositoryImpl;

/*
* Tjeneste for å sjekke om person har tilgang til en .
Expand All @@ -23,17 +27,17 @@
@Tag(name = "altinn-rettigheter")
@Path("/altinn-rettigheter-proxy")
public class AltinnRettigheterProxyMock {
protected static final Set<String> ALLE_VIRKSOMHETER = BasisdataProviderFileImpl.getInstance()
.getVirksomhetIndeks()
.getAlleVirksomheter()
.keySet();

@Context
private TestscenarioBuilderRepository scenarioRepository;

@GET
@Path("/ekstern/altinn/api/serviceowner/reportees")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Henter alle virksomheter.")
public Response hentTilgangerTilVirksomheter() {
return Response.ok().entity(mapToResponse()).build();
var alleOrgnr = scenarioRepository.hentAlleOrganisasjonsnummer();
return Response.ok().entity(mapToResponse(alleOrgnr)).build();
}

@GET
Expand All @@ -44,8 +48,8 @@ public Response hentIngenTilganger() {
return Response.ok().entity(List.of()).build();
}

private List<AltinnReportee> mapToResponse() {
return AltinnRettigheterProxyMock.ALLE_VIRKSOMHETER.stream().map(AltinnReportee::new).toList();
private List<AltinnReportee> mapToResponse(Set<String> alleOrgnr) {
return alleOrgnr.stream().map(AltinnReportee::new).toList();
}

@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
Expand Down
85 changes: 85 additions & 0 deletions mocks/fager-mock/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mocks</artifactId>
<groupId>no.nav.foreldrepenger.vtp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>fager-mock</artifactId>
<name>VTP ::fager-mock</name>
<packaging>jar</packaging>

<properties>
<apigen.version>5.0.0</apigen.version>
</properties>

<dependencies>
<dependency>
<artifactId>jakarta.annotation-api</artifactId>
<groupId>jakarta.annotation</groupId>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>
<dependency>
<groupId>com.distelli.graphql</groupId>
<artifactId>graphql-apigen-deps</artifactId>
<version>${apigen.version}</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
</dependency>
<dependency>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-java-codegen</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<artifactId>saf-mock</artifactId>
<groupId>no.nav.foreldrepenger.vtp</groupId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<graphqlSchemaPaths>${project.basedir}/src/main/resources/schemas/produsent.graphql</graphqlSchemaPaths>
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir>
<packageName>no.nav.fager</packageName>
<customTypesMapping>
<DateTime>java.util.Date</DateTime>
</customTypesMapping>
<generateClient>true</generateClient>
<generateApis>false</generateApis>
<generateBuilder>true</generateBuilder>
<generateToString>true</generateToString>
<generateParameterizedFieldsResolvers>false</generateParameterizedFieldsResolvers>
<addGeneratedAnnotation>true</addGeneratedAnnotation>
<generatedAnnotation>jakarta.annotation.Generated</generatedAnnotation>
<modelValidationAnnotation>@jakarta.validation.constraints.NotNull</modelValidationAnnotation>
<generateJacksonTypeIdResolver>true</generateJacksonTypeIdResolver>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading