0

I am connecting to sonar to fetch the gate result for a project, once i get the result I must extract value from within response and return (BOOLEAN) TRUE or FALSE. If the value of getQualityGateStatus() == "OK" i will return TRUE else FALSE. Would like to do with webclient without blocking, i do not want to use rest template.

public Mono<String> getResult(String repo, String branch) {
         Mono<String> res = sonarWebClient.get()
                .uri("some url").retrieve()
                .bodyToMono(Branch.class).map(x -> x.getStatus().getQualityGateStatus());
    }
Praveen Om
  • 7
  • 1
  • 7
Sagar
  • 61
  • 9
  • The answer is in the question: Use map(). – JB Nizet Aug 07 '19 at 17:12
  • i am not sure how to use it, i tried but not able to return the result – Sagar Aug 07 '19 at 17:17
  • What does the existing map() call in your question do? Do you understand that? Can you explain it? If not, have you read the documentation of Mono.map()? – JB Nizet Aug 07 '19 at 17:18
  • yes i did read the documentation, and my expectation was that map would take the response object and transform it to string with the value of getQualityGateStatus(), but that does not happen and i get error, java.lang.NullPointerException: null at com.tmobile.quad.quadgating.impl.SonarGatingService.lambda$0(SonarGatingService.java:24) ~[classes/:na] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE] – Sagar Aug 07 '19 at 17:27
  • So either x is null, or x.getStatus() is null. Use your debugger, or simple println() statements, to find out. And change your code accordingly. – JB Nizet Aug 07 '19 at 17:29
  • I did that, result is not null. – Sagar Aug 07 '19 at 17:40

0 Answers0