|
@@ -3,28 +3,22 @@ package com.provectus.kafka.ui.service.ksql;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
-import com.fasterxml.jackson.databind.node.DoubleNode;
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.node.DecimalNode;
|
|
import com.fasterxml.jackson.databind.node.IntNode;
|
|
import com.fasterxml.jackson.databind.node.IntNode;
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
import com.fasterxml.jackson.databind.node.TextNode;
|
|
import com.fasterxml.jackson.databind.node.TextNode;
|
|
import com.provectus.kafka.ui.AbstractIntegrationTest;
|
|
import com.provectus.kafka.ui.AbstractIntegrationTest;
|
|
-import com.provectus.kafka.ui.container.KsqlDbContainer;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
-import java.util.List;
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import org.junit.jupiter.api.AfterAll;
|
|
import org.junit.jupiter.api.AfterAll;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.testcontainers.shaded.org.awaitility.Awaitility;
|
|
import org.testcontainers.shaded.org.awaitility.Awaitility;
|
|
-import org.testcontainers.utility.DockerImageName;
|
|
|
|
import reactor.test.StepVerifier;
|
|
import reactor.test.StepVerifier;
|
|
|
|
|
|
class KsqlApiClientTest extends AbstractIntegrationTest {
|
|
class KsqlApiClientTest extends AbstractIntegrationTest {
|
|
|
|
|
|
- private static final KsqlDbContainer KSQL_DB = new KsqlDbContainer(
|
|
|
|
- DockerImageName.parse("confluentinc/ksqldb-server").withTag("0.24.0"))
|
|
|
|
- .withKafka(kafka);
|
|
|
|
-
|
|
|
|
@BeforeAll
|
|
@BeforeAll
|
|
static void startContainer() {
|
|
static void startContainer() {
|
|
KSQL_DB.start();
|
|
KSQL_DB.start();
|
|
@@ -72,7 +66,7 @@ class KsqlApiClientTest extends AbstractIntegrationTest {
|
|
private void assertLastKsqTutorialQueryResult(KsqlApiClient client) {
|
|
private void assertLastKsqTutorialQueryResult(KsqlApiClient client) {
|
|
// expected results:
|
|
// expected results:
|
|
//{"header":"Schema","columnNames":[...],"values":null}
|
|
//{"header":"Schema","columnNames":[...],"values":null}
|
|
- //{"header":"Row","columnNames":null,"values":[[0.0,["4ab5cbad","8b6eae59","4a7c7b41"],3]]}
|
|
|
|
|
|
+ //{"header":"Row","columnNames":null,"values":[[0,["4ab5cbad","8b6eae59","4a7c7b41"],3]]}
|
|
//{"header":"Row","columnNames":null,"values":[[10.0,["18f4ea86"],1]]}
|
|
//{"header":"Row","columnNames":null,"values":[[10.0,["18f4ea86"],1]]}
|
|
StepVerifier.create(
|
|
StepVerifier.create(
|
|
client.execute(
|
|
client.execute(
|
|
@@ -86,34 +80,26 @@ class KsqlApiClientTest extends AbstractIntegrationTest {
|
|
assertThat(header.getValues()).isNull();
|
|
assertThat(header.getValues()).isNull();
|
|
})
|
|
})
|
|
.assertNext(row -> {
|
|
.assertNext(row -> {
|
|
- assertThat(row).isEqualTo(
|
|
|
|
- KsqlApiClient.KsqlResponseTable.builder()
|
|
|
|
- .header("Row")
|
|
|
|
- .columnNames(null)
|
|
|
|
- .values(List.of(List.of(
|
|
|
|
- new DoubleNode(0.0),
|
|
|
|
- new ArrayNode(JsonNodeFactory.instance)
|
|
|
|
- .add(new TextNode("4ab5cbad"))
|
|
|
|
- .add(new TextNode("8b6eae59"))
|
|
|
|
- .add(new TextNode("4a7c7b41")),
|
|
|
|
- new IntNode(3)
|
|
|
|
- )))
|
|
|
|
- .build()
|
|
|
|
- );
|
|
|
|
|
|
+ var distance = (DecimalNode) row.getValues().get(0).get(0);
|
|
|
|
+ var riders = (ArrayNode) row.getValues().get(0).get(1);
|
|
|
|
+ var count = (IntNode) row.getValues().get(0).get(2);
|
|
|
|
+
|
|
|
|
+ assertThat(distance).isEqualTo(new DecimalNode(new BigDecimal(0)));
|
|
|
|
+ assertThat(riders).isEqualTo(new ArrayNode(JsonNodeFactory.instance)
|
|
|
|
+ .add(new TextNode("4ab5cbad"))
|
|
|
|
+ .add(new TextNode("8b6eae59"))
|
|
|
|
+ .add(new TextNode("4a7c7b41")));
|
|
|
|
+ assertThat(count).isEqualTo(new IntNode(3));
|
|
})
|
|
})
|
|
.assertNext(row -> {
|
|
.assertNext(row -> {
|
|
- assertThat(row).isEqualTo(
|
|
|
|
- KsqlApiClient.KsqlResponseTable.builder()
|
|
|
|
- .header("Row")
|
|
|
|
- .columnNames(null)
|
|
|
|
- .values(List.of(List.of(
|
|
|
|
- new DoubleNode(10.0),
|
|
|
|
- new ArrayNode(JsonNodeFactory.instance)
|
|
|
|
- .add(new TextNode("18f4ea86")),
|
|
|
|
- new IntNode(1)
|
|
|
|
- )))
|
|
|
|
- .build()
|
|
|
|
- );
|
|
|
|
|
|
+ var distance = (DecimalNode) row.getValues().get(0).get(0);
|
|
|
|
+ var riders = (ArrayNode) row.getValues().get(0).get(1);
|
|
|
|
+ var count = (IntNode) row.getValues().get(0).get(2);
|
|
|
|
+
|
|
|
|
+ assertThat(distance).isEqualTo(new DecimalNode(new BigDecimal(10)));
|
|
|
|
+ assertThat(riders).isEqualTo(new ArrayNode(JsonNodeFactory.instance)
|
|
|
|
+ .add(new TextNode("18f4ea86")));
|
|
|
|
+ assertThat(count).isEqualTo(new IntNode(1));
|
|
})
|
|
})
|
|
.verifyComplete();
|
|
.verifyComplete();
|
|
}
|
|
}
|