+ return "{\"servingCellNrcgi\":\"1\"}";
+ }
+
+ @Test
+ void testConcurrency() throws Exception {
+ final Instant startTime = Instant.now();
+ List<Thread> threads = new ArrayList<>();
+ a1ClientFactory.setResponseDelay(Duration.ofMillis(1));
+ addRic("ric");
+ addPolicyType("type1", "ric");
+ addPolicyType("type2", "ric");
+
+ for (int i = 0; i < 10; ++i) {
+ Thread thread =
+ new Thread(new ConcurrencyTestRunnable(baseUrl(), supervision, a1ClientFactory, rics, policyTypes),
+ "TestThread_" + i);
+ thread.start();
+ threads.add(thread);
+ }
+ for (Thread t : threads) {
+ t.join();
+ }
+ assertThat(policies.size()).isZero();
+ logger.info("Concurrency test took " + Duration.between(startTime, Instant.now()));
+ }
+
+ private AsyncRestClient restClient(boolean useTrustValidation) {
+ WebClientConfig config = this.applicationConfig.getWebClientConfig();
+ config = ImmutableWebClientConfig.builder() //
+ .keyStoreType(config.keyStoreType()) //
+ .keyStorePassword(config.keyStorePassword()) //
+ .keyStore(config.keyStore()) //
+ .keyPassword(config.keyPassword()) //
+ .isTrustStoreUsed(useTrustValidation) //
+ .trustStore(config.trustStore()) //
+ .trustStorePassword(config.trustStorePassword()) //
+ .build();
+
+ return new AsyncRestClient(baseUrl(), config);
+ }
+
+ private AsyncRestClient restClient() {
+ return restClient(false);
+ }
+
+ private void testErrorCode(Mono<?> request, HttpStatus expStatus) {
+ testErrorCode(request, expStatus, "");
+ }
+
+ private void testErrorCode(Mono<?> request, HttpStatus expStatus, String responseContains) {
+ StepVerifier.create(request) //
+ .expectSubscription() //
+ .expectErrorMatches(t -> checkWebClientError(t, expStatus, responseContains)) //
+ .verify();
+ }
+
+ private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains) {
+ assertTrue(throwable instanceof WebClientResponseException);
+ WebClientResponseException responseException = (WebClientResponseException) throwable;
+ assertThat(responseException.getStatusCode()).isEqualTo(expStatus);
+ assertThat(responseException.getResponseBodyAsString()).contains(responseContains);
+ return true;