X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Futils%2FMockA1Client.java;h=fc0eba35326a4b7d5bcd14ae7447b52a73300b37;hb=c9a6805df30f6282ace0285df26107b5518d4e2b;hp=0fa5be4f7d4a3b5b7a281d94e607c59c8399fae4;hpb=ae4206bbd7437adda91fc429efef03a13da2b702;p=nonrtric.git diff --git a/policy-agent/src/test/java/org/oransc/policyagent/utils/MockA1Client.java b/policy-agent/src/test/java/org/oransc/policyagent/utils/MockA1Client.java index 0fa5be4f..fc0eba35 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/utils/MockA1Client.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/utils/MockA1Client.java @@ -20,6 +20,7 @@ package org.oransc.policyagent.utils; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.List; import java.util.Vector; @@ -29,6 +30,8 @@ import org.oransc.policyagent.repository.Policies; import org.oransc.policyagent.repository.Policy; import org.oransc.policyagent.repository.PolicyType; import org.oransc.policyagent.repository.PolicyTypes; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -114,6 +117,13 @@ public class MockA1Client implements A1Client { } } + Mono monoError(String responseBody, HttpStatus status) { + byte[] responseBodyBytes = responseBody.getBytes(StandardCharsets.UTF_8); + WebClientResponseException a1Exception = new WebClientResponseException(status.value(), + status.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null); + return Mono.error(a1Exception); + } + @SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests. private void sleep() { try {