Skip to content

Commit

Permalink
Fikset merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Sep 20, 2023
2 parents 64e2bb8 + 1e297f2 commit 7abbfb0
Show file tree
Hide file tree
Showing 224 changed files with 1,864 additions and 1,984 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static Mono<String> getAapStatus(AapResponse response, ErrorStatusDecoder

public static String fmtResponse(String miljoe, String system, String status) {

return encodeStatus(String.format(MILJOE_FMT, miljoe, system, status));
return String.format(MILJOE_FMT, miljoe, system, encodeStatus(status));
}

public static String getMessage(String jsonFeilmelding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public Flux<PersonMiljoeDTO> call() {
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.retrieve()
.bodyToFlux(PersonMiljoeDTO.class)
.map(resultat -> {
resultat.setIdent(ident);
return resultat;
})
.onErrorResume(throwable -> Mono.just(PersonMiljoeDTO.builder()
.status("FEIL")
.melding(WebClientFilter.getStatus(throwable).getReasonPhrase())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.ClientFuture;
import no.nav.dolly.bestilling.tpsmessagingservice.TpsMessagingConsumer;
import no.nav.dolly.consumer.pdlperson.PdlPersonConsumer;
import no.nav.dolly.domain.PdlPerson;
import no.nav.dolly.domain.PdlPersonBolk;
import no.nav.dolly.domain.jpa.BestillingProgress;
import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling;
import no.nav.dolly.domain.resultset.SystemTyper;
Expand All @@ -20,6 +23,7 @@
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand All @@ -41,21 +45,46 @@ public class TpsPersonService {
private final TpsMessagingConsumer tpsMessagingConsumer;
private final TransactionHelperService transactionHelperService;
private final TransaksjonMappingService transaksjonMappingService;
private final PdlPersonConsumer pdlPersonConsumer;

public Flux<ClientFuture> syncPerson(DollyPerson dollyPerson, RsDollyUtvidetBestilling bestilling, BestillingProgress progress, boolean isOpprettEndre) {

long startTime = System.currentTimeMillis();

return Flux.from(Flux.fromIterable(bestilling.getEnvironments())
return Flux.fromIterable(bestilling.getEnvironments())
.filter(PENSJON_MILJOER::contains)
.collectList()
.filter(penMiljoer -> !penMiljoer.isEmpty())
.filter(penMiljoer -> isRelevantBestilling(bestilling) &&
(isOpprettEndre || !isTransaksjonMapping(dollyPerson.getIdent(), bestilling, penMiljoer)))
.flatMap(penMiljoer -> getTpsPerson(startTime, dollyPerson.getIdent(),
penMiljoer, Collections.emptyList(), progress))
.map(status -> prepareResult(dollyPerson.getIdent(), status, bestilling.getEnvironments(), startTime))
.map(status -> futurePersist(progress, status)));
.flatMapMany(penMiljoer ->
getRelasjoner(dollyPerson.getIdent())
.flatMap(relasjon -> Flux.from(getTpsPerson(startTime, dollyPerson.getIdent(),
penMiljoer, Collections.emptyList(), progress)
.map(status -> prepareResult(relasjon, status, bestilling.getEnvironments(), startTime)))))
.collectList()
.flatMapIterable(list -> list)
.map(status -> futurePersist(progress, dollyPerson.getIdent(), status));
}

private Flux<String> getRelasjoner(String ident) {

return pdlPersonConsumer.getPdlPersoner(List.of(ident))
.filter(pdlPersonBolk -> nonNull(pdlPersonBolk.getData()))
.map(PdlPersonBolk::getData)
.map(PdlPersonBolk.Data::getHentPersonBolk)
.flatMap(Flux::fromIterable)
.filter(personBolk -> nonNull(personBolk.getPerson()))
.flatMap(person -> Flux.fromStream(Stream.of(
Stream.of(ident),
person.getPerson().getSivilstand().stream()
.map(PdlPerson.Sivilstand::getRelatertVedSivilstand)
.filter(Objects::nonNull),
person.getPerson().getForelderBarnRelasjon().stream()
.map(PdlPerson.ForelderBarnRelasjon::getRelatertPersonsIdent)
.filter(Objects::nonNull))
.flatMap(Function.identity())))
.distinct();
}

private boolean isRelevantBestilling(RsDollyUtvidetBestilling bestilling) {
Expand Down Expand Up @@ -120,6 +149,7 @@ private List<PersonMiljoeDTO> prepareResult(String ident, List<PersonMiljoeDTO>
miljoer.stream()
.filter(miljoe -> status.stream().noneMatch(status1 -> miljoe.equals(status1.getMiljoe())))
.map(miljoe -> PersonMiljoeDTO.builder()
.ident(ident)
.miljoe(miljoe)
.status("NOK")
.utfyllendeMelding(String.format("Feil: Synkronisering mot TPS gitt opp etter %d sekunder.", MAX_MILLIES / 1000))
Expand All @@ -128,17 +158,19 @@ private List<PersonMiljoeDTO> prepareResult(String ident, List<PersonMiljoeDTO>
.toList();
}

private ClientFuture futurePersist(BestillingProgress progress, List<PersonMiljoeDTO> status) {
private ClientFuture futurePersist(BestillingProgress progress, String ident, List<PersonMiljoeDTO> status) {

return () -> {

progress.setIsTpsSyncEnv(status.stream()
.filter(status1 -> ident.equals(status1.getIdent()))
.filter(PersonMiljoeDTO::isOk)
.map(PersonMiljoeDTO::getMiljoe)
.toList());

transactionHelperService.persister(progress, BestillingProgress::setTpsSyncStatus,
status.stream()
.filter(detalj -> ident.equals(detalj.getIdent()))
.map(detalj -> String.format("%s:%s", detalj.getMiljoe(),
ErrorStatusDecoder.encodeStatus(detalj.isOk() ? detalj.getStatus() :
StringUtils.trimToEmpty(String.format("FEIL: %s", detalj.getUtfyllendeMelding())))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static String encodeStatus(String toBeEncoded) {
.replace("]", "")
.replace(',', ';')
.replace(':', '=')
.replace("\"", ""): "";
.replace("\"", "")
.replace("$", "§") : "";
}

public String getErrorText(HttpStatus errorStatus, String errorMsg) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----------------------------
-- A L T E R T A B L E S --
-----------------------------

alter table transaksjon_mapping
alter column transaksjon_id type varchar(2000);
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ private Function<PredicateSpec, Buildable<Route>> createRoute(String segment, St
.filters(filter, addUserJwtHeaderFilter())
).uri(host);
}
}
}
9 changes: 9 additions & 0 deletions apps/dolly-frontend/src/main/js/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ import { defineConfig } from 'cypress'
export default defineConfig({
pageLoadTimeout: 120000,
defaultCommandTimeout: 25000,

env: {
'cypress-react-selector': {
root: '#root',
},
},

e2e: {
setupNodeEvents() {},
experimentalRunAllSpecs: true,
specPattern: 'cypress/e2e/**/*.cy.{js,ts,jsx,tsx}',
excludeSpecPattern: ['**/__snapshots__/*', '**/__image_snapshots__/*'],
},

component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
31 changes: 31 additions & 0 deletions apps/dolly-frontend/src/main/js/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ***********************************************************
// This example support/component.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

import './commands'

import { mount } from 'cypress/react18'

declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)
Loading

0 comments on commit 7abbfb0

Please sign in to comment.