import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
+import org.springframework.http.HttpStatus;
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)
"server.ssl.key-store=./config/keystore.jks", //
"app.webclient.trust-store=./config/truststore.jks", //
"app.configuration-filepath=./src/test/resources/test_application_configuration.json", //
- "app.ecs-base-url=https://localhost:8434" //
+ "app.ics-base-url=https://localhost:8434" //
})
-class IntegrationWithEcs {
+class IntegrationWithIcs {
private static final String DMAAP_JOB_ID = "DMAAP_JOB_ID";
private static final String DMAAP_TYPE_ID = "DmaapInformationType";
return "https://localhost:" + this.applicationConfig.getLocalServerHttpPort();
}
- private String ecsBaseUrl() {
+ private String icsBaseUrl() {
return applicationConfig.getIcsBaseUrl();
}
private String jobUrl(String jobId) {
- return ecsBaseUrl() + "/data-consumer/v1/info-jobs/" + jobId + "?typeCheck=true";
+ return icsBaseUrl() + "/data-consumer/v1/info-jobs/" + jobId + "?typeCheck=true";
}
- private void createInformationJobInEcs(String typeId, String jobId, String filter) {
+ private void createInformationJobInIcs(String typeId, String jobId, String filter) {
String body = gson.toJson(consumerJobInfo(typeId, filter));
try {
// Delete the job if it already exists
- deleteInformationJobInEcs(jobId);
+ deleteInformationJobInIcs(jobId);
} catch (Exception e) {
}
restClient().putForEntity(jobUrl(jobId), body).block();
}
- private void deleteInformationJobInEcs(String jobId) {
+ private void deleteInformationJobInIcs(String jobId) {
restClient().delete(jobUrl(jobId)).block();
}
await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1));
- deleteInformationJobInEcs("KAFKA_JOB_ID");
+ deleteInformationJobInIcs("KAFKA_JOB_ID");
await().untilAsserted(() -> assertThat(this.jobs.size()).isZero());
}
@Test
- void testWholeChain() throws Exception {
+ void testKafkaJobParameterOutOfRange() {
await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInIcs()).isTrue());
+ final String TYPE_ID = "KafkaInformationType";
+
+ Job.Parameters param = new Job.Parameters("filter", new Job.BufferTimeout(123, 170 * 1000), 1);
+
+ ConsumerJobInfo jobInfo =
+ new ConsumerJobInfo(TYPE_ID, jsonObject(gson.toJson(param)), "owner", consumerUri(), "");
+ String body = gson.toJson(jobInfo);
- createInformationJobInEcs(DMAAP_TYPE_ID, DMAAP_JOB_ID, ".*DmaapResponse.*");
+ ApplicationTest.testErrorCode(restClient().put(jobUrl("KAFKA_JOB_ID"), body), HttpStatus.BAD_REQUEST,
+ "Json validation failure");
+
+ }
+
+ @Test
+ void testDmaapMessage() throws Exception {
+ await().untilAsserted(() -> assertThat(producerRegstrationTask.isRegisteredInIcs()).isTrue());
+
+ createInformationJobInIcs(DMAAP_TYPE_ID, DMAAP_JOB_ID, ".*DmaapResponse.*");
await().untilAsserted(() -> assertThat(this.jobs.size()).isEqualTo(1));
await().untilAsserted(() -> assertThat(results.receivedBodies.size()).isEqualTo(2));
assertThat(results.receivedBodies.get(0)).isEqualTo("DmaapResponse1");
- deleteInformationJobInEcs(DMAAP_JOB_ID);
+ deleteInformationJobInIcs(DMAAP_JOB_ID);
await().untilAsserted(() -> assertThat(this.jobs.size()).isZero());
-
- synchronized (this) {
- // logger.warn("**************** Keeping server alive! " +
- // this.applicationConfig.getLocalServerHttpPort());
- // this.wait();
- }
}
}