Removed code smells.
Improved coverage
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-735
Change-Id: I391df1746af764c9e188f2269d7855758b36750c
return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext(),
useHttpProxy ? httpProxyConfig : null);
} catch (Exception e) {
- String exceptionString = e.toString();
- logger.error("Could not init SSL context, reason: {}", exceptionString);
+ logger.error("Could not init SSL context, reason: {}", e.toString());
}
}
return new AsyncRestClient(baseUrl, null, httpProxyConfig);
@TestPropertySource(properties = { //
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks", //
+ "app.webclient.trust-store-used=true", //
"app.configuration-filepath=./src/test/resources/test_application_configuration.json"//
})
class ApplicationTest {
kafkaConsumer.start(Flux.just("data"));
ConsumerController.TestResults consumer = this.consumerController.testResults;
- await().untilAsserted(() -> assertThat(consumer.receivedBodies.size()).isEqualTo(1));
+ await().untilAsserted(() -> assertThat(consumer.receivedBodies).hasSize(1));
assertThat(consumer.receivedBodies.get(0)).isEqualTo("[\"data\"]");
// Test send an exception
DmaapSimulatorController.dmaapResponses.add("DmaapResponse1");
DmaapSimulatorController.dmaapResponses.add("DmaapResponse2");
ConsumerController.TestResults consumer = this.consumerController.testResults;
- await().untilAsserted(() -> assertThat(consumer.receivedBodies.size()).isEqualTo(2));
+ await().untilAsserted(() -> assertThat(consumer.receivedBodies).hasSize(2));
assertThat(consumer.receivedBodies.get(0)).isEqualTo("DmaapResponse1");
String jobUrl = baseUrl() + ProducerCallbacksController.JOB_URL;
import org.oran.dmaapadapter.configuration.WebClientConfig;
import org.oran.dmaapadapter.configuration.WebClientConfig.HttpProxyConfig;
import org.oran.dmaapadapter.r1.ConsumerJobInfo;
-import org.oran.dmaapadapter.repository.InfoTypes;
import org.oran.dmaapadapter.repository.Job;
import org.oran.dmaapadapter.repository.Jobs;
import org.oran.dmaapadapter.tasks.ProducerRegstrationTask;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-
@SuppressWarnings("java:S3577") // Rename class
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@Autowired
private Jobs jobs;
- @Autowired
- private InfoTypes types;
-
@Autowired
private ConsumerController consumerController;
DmaapSimulatorController.dmaapResponses.add("Junk");
ConsumerController.TestResults results = this.consumerController.testResults;
- await().untilAsserted(() -> assertThat(results.receivedBodies.size()).isEqualTo(2));
+ await().untilAsserted(() -> assertThat(results.receivedBodies).hasSize(2));
assertThat(results.receivedBodies.get(0)).isEqualTo("DmaapResponse1");
deleteInformationJobInIcs(DMAAP_JOB_ID);
private void verifiedReceivedByConsumer(String... strings) {
ConsumerController.TestResults consumer = this.consumerController.testResults;
- await().untilAsserted(() -> assertThat(consumer.receivedBodies.size()).isEqualTo(strings.length));
+ await().untilAsserted(() -> assertThat(consumer.receivedBodies).hasSize(strings.length));
for (String s : strings) {
assertTrue(consumer.hasReceived(s));
}
}
+ @SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests.
+ private static void sleep(long millis) throws InterruptedException {
+ Thread.sleep(millis);
+ }
+
@Test
void simpleCase() throws InterruptedException {
final String JOB_ID = "ID";
this.icsSimulatorController.addJob(consumerJobInfo(null, Duration.ZERO, 0, 1), JOB_ID, restClient());
await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1));
- Thread.sleep(4000);
+ sleep(4000);
var dataToSend = Flux.just(senderRecord("Message"));
sendDataToStream(dataToSend);
await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(2));
- Thread.sleep(2000);
+ sleep(2000);
var dataToSend = Flux.range(1, 3).map(i -> senderRecord("Message_" + i)); // Message_1, Message_2 etc.
sendDataToStream(dataToSend);
this.icsSimulatorController.deleteJob(JOB_ID2, restClient()); // Delete one job
kafkaTopicConsumers.restartNonRunningTopics();
- Thread.sleep(1000); // Restarting the input seems to take some asynch time
+ sleep(1000); // Restarting the input seems to take some asynch time
dataToSend = Flux.just(senderRecord("Howdy\""));
sendDataToStream(dataToSend);