-
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.
POFIM-98: Lager en fager-api-mock for backend
- Loading branch information
Showing
27 changed files
with
3,870 additions
and
1 deletion.
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
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> |
266 changes: 266 additions & 0 deletions
266
mocks/fager-mock/src/main/java/no/nav/fager/FagerBasicWiring.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,266 @@ | ||
package no.nav.fager; | ||
|
||
import graphql.schema.idl.RuntimeWiring; | ||
import no.nav.fager.graphql.DateScalar; | ||
import no.nav.fager.graphql.DateTimeScalar; | ||
import no.nav.fager.graphql.DurationScalar; | ||
import no.nav.fager.graphql.LocalDateTimeScalar; | ||
|
||
public class FagerBasicWiring { | ||
|
||
public static RuntimeWiring lagBasicWiring() { | ||
return RuntimeWiring.newRuntimeWiring() | ||
.scalar(DateScalar.DATE) | ||
.scalar(DateTimeScalar.ISO_8601_DATE_TIME) | ||
.scalar(LocalDateTimeScalar.ISO_8601_LOCAL_DATE_TIME) | ||
.scalar(DurationScalar.ISO_8601_DURATION) | ||
.type("Error", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof DuplikatGrupperingsid) { | ||
return env.getSchema().getObjectType("DuplikatGrupperingsid"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("NySakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else if (javaObject instanceof DuplikatGrupperingsid) { | ||
return env.getSchema().getObjectType("DuplikatGrupperingsid"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("NyOppgaveResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NyOppgaveVellykket) { | ||
return env.getSchema().getObjectType("NyOppgaveVellykket"); | ||
} else if (javaObject instanceof DuplikatEksternIdOgMerkelapp) { | ||
return env.getSchema().getObjectType("DuplikatEksternIdOgMerkelapp"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("OppgaveUtgaattResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof OppgaveUtgaattVellykket) { | ||
return env.getSchema().getObjectType("OppgaveUtgaattVellykket"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("OppgaveUtfoertResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof OppgaveUtfoertVellykket) { | ||
return env.getSchema().getObjectType("OppgaveUtfoertVellykket"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("NyStatusSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NyStatusSakVellykket) { | ||
return env.getSchema().getObjectType("NyStatusSakVellykket"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("TilleggsinformasjonSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof TilleggsinformasjonSakVellykket) { | ||
return env.getSchema().getObjectType("TilleggsinformasjonSakVellykket"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("HardDeleteSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof HardDeleteSakVellykket) { | ||
return env.getSchema().getObjectType("HardDeleteSakVellykket"); | ||
} else { | ||
throw new RuntimeException("Ikke støttet type"); | ||
} | ||
}) | ||
) | ||
.type("MineNotifikasjonerResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NotifikasjonConnection) { | ||
return env.getSchema().getObjectType("NotifikasjonConnection"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("HentNotifikasjonResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof HentetNotifikasjon) { | ||
return env.getSchema().getObjectType("HentetNotifikasjon"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("HentSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof HentetSak) { | ||
return env.getSchema().getObjectType("HentetSak"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("Notifikasjon", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof Oppgave) { | ||
return env.getSchema().getObjectType("Oppgave"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("Mottaker", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof AltinnMottaker) { | ||
return env.getSchema().getObjectType("AltinnMottaker"); | ||
} else { | ||
return env.getSchema().getObjectType("NaermesteLederMottaker"); | ||
} | ||
}) | ||
) | ||
.type("NesteStegSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("SoftDeleteNotifikasjonResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("HardDeleteNotifikasjonResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("SoftDeleteSakResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("OppgaveUtsettFristResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("OppgaveEndrePaaminnelseResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("OppdaterKalenderavtaleResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
|
||
.type("NyBeskjedResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NySakVellykket) { | ||
return env.getSchema().getObjectType("NySakVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.type("NyKalenderavtaleResultat", typeWriting -> | ||
typeWriting | ||
.typeResolver(env -> { | ||
var javaObject = env.getObject(); | ||
if (javaObject instanceof NyKalenderavtaleVellykket) { | ||
return env.getSchema().getObjectType("NyKalenderavtaleVellykket"); | ||
} else { | ||
return env.getSchema().getObjectType("UkjentProdusent"); | ||
} | ||
}) | ||
) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.