Skip to content

Commit 98f73d3

Browse files
authored
Fix hentFullmakt mono to flux (#3955)
1 parent c6b97f0 commit 98f73d3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/fullmakt/FullmaktConsumer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public Flux<FullmaktPostResponse> createFullmaktData(List<RsFullmakt> fullmakter
5959
}
6060

6161
@Timed(name = "providers", tags = { "operation", "fullmakt_getData" })
62-
public Mono<FullmaktPostResponse.Fullmakt> getFullmaktData(String ident) {
62+
public Flux<FullmaktPostResponse.Fullmakt> getFullmaktData(String ident) {
6363

6464
return tokenService.exchange(serverProperties)
65-
.flatMap(token -> new GetFullmaktDataCommand(webClient, ident,
65+
.flatMapMany(token -> new GetFullmaktDataCommand(webClient, ident,
6666
token.getTokenValue()).call());
6767
}
6868

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/fullmakt/command/GetFullmaktDataCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import no.nav.testnav.libs.reactivecore.web.WebClientHeader;
99
import org.springframework.web.reactive.function.client.WebClient;
1010
import org.springframework.web.reactive.function.client.WebClientResponseException;
11+
import reactor.core.publisher.Flux;
1112
import reactor.core.publisher.Mono;
1213

1314
import java.util.concurrent.Callable;
@@ -18,15 +19,15 @@
1819

1920
@RequiredArgsConstructor
2021
@Slf4j
21-
public class GetFullmaktDataCommand implements Callable<Mono<FullmaktPostResponse.Fullmakt>> {
22+
public class GetFullmaktDataCommand implements Callable<Flux<FullmaktPostResponse.Fullmakt>> {
2223

2324
private static final String HENT_FULLMAKT_URL = "/api/fullmaktsgiver";
2425

2526
private final WebClient webClient;
2627
private final String ident;
2728
private final String token;
2829

29-
public Mono<FullmaktPostResponse.Fullmakt> call() {
30+
public Flux<FullmaktPostResponse.Fullmakt> call() {
3031
return webClient
3132
.get()
3233
.uri(uriBuilder -> uriBuilder
@@ -37,15 +38,14 @@ public Mono<FullmaktPostResponse.Fullmakt> call() {
3738
.header("fnr", ident)
3839
.headers(WebClientHeader.bearer(token))
3940
.retrieve()
40-
.bodyToMono(FullmaktPostResponse.Fullmakt.class)
41+
.bodyToFlux(FullmaktPostResponse.Fullmakt.class)
4142
.doOnError(WebClientError.logTo(log))
4243
.onErrorResume(throwable -> {
4344
var description = WebClientError.describe(throwable);
4445
return Mono.just(FullmaktPostResponse.Fullmakt.builder()
4546
.status(description.getStatus().getReasonPhrase())
4647
.build());
4748
})
48-
4949
.onErrorResume(WebClientResponseException.NotFound.class::isInstance, throwable -> Mono.empty());
5050
}
5151
}

0 commit comments

Comments
 (0)