Search in sources :

Example 11 with KsqlEntityList

use of io.confluent.ksql.rest.entity.KsqlEntityList in project ksql by confluentinc.

the class KsqlResourceTest method shouldFailCreateTableWithInferenceWithIncorrectKey.

@Test
public void shouldFailCreateTableWithInferenceWithIncorrectKey() throws Exception {
    KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
    final String ksqlString = "CREATE TABLE orders WITH (KAFKA_TOPIC='orders-topic', " + "VALUE_FORMAT = 'avro', KEY = 'orderid1');";
    Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, new HashMap<>()));
    KsqlEntityList result = (KsqlEntityList) response.getEntity();
    assertThat("Incorrect response.", result.size(), equalTo(1));
    assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
}
Also used : Response(javax.ws.rs.core.Response) KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) KsqlRequest(io.confluent.ksql.rest.entity.KsqlRequest) HashMap(java.util.HashMap) ErrorMessageEntity(io.confluent.ksql.rest.entity.ErrorMessageEntity) Test(org.junit.Test)

Example 12 with KsqlEntityList

use of io.confluent.ksql.rest.entity.KsqlEntityList in project ksql by confluentinc.

the class KsqlResourceTest method shouldCreateTableWithInference.

@Test
public void shouldCreateTableWithInference() throws Exception {
    KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
    final String ksqlString = "CREATE TABLE orders WITH (KAFKA_TOPIC='orders-topic', " + "VALUE_FORMAT = 'avro', KEY = 'orderid');";
    Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, new HashMap<>()));
    KsqlEntityList result = (KsqlEntityList) response.getEntity();
    assertThat("Incorrect response.", result.size(), equalTo(1));
    assertTrue(result.get(0) instanceof CommandStatusEntity);
    CommandStatusEntity commandStatusEntity = (CommandStatusEntity) result.get(0);
    assertTrue(commandStatusEntity.getCommandId().getType().name().equalsIgnoreCase("TABLE"));
}
Also used : Response(javax.ws.rs.core.Response) KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) KsqlRequest(io.confluent.ksql.rest.entity.KsqlRequest) HashMap(java.util.HashMap) CommandStatusEntity(io.confluent.ksql.rest.entity.CommandStatusEntity) Test(org.junit.Test)

Example 13 with KsqlEntityList

use of io.confluent.ksql.rest.entity.KsqlEntityList in project ksql by confluentinc.

the class KsqlRestClientTest method testKsqlResource.

@Test
public void testKsqlResource() {
    RestResponse<KsqlEntityList> results = ksqlRestClient.makeKsqlRequest("Test request");
    Assert.assertNotNull(results);
    Assert.assertTrue(results.isSuccessful());
    KsqlEntityList ksqlEntityList = results.getResponse();
    Assert.assertTrue(ksqlEntityList.size() == 1);
    Assert.assertTrue(ksqlEntityList.get(0) instanceof ExecutionPlan);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ExecutionPlan(io.confluent.ksql.rest.entity.ExecutionPlan) Test(org.junit.Test)

Aggregations

KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)13 ErrorMessageEntity (io.confluent.ksql.rest.entity.ErrorMessageEntity)8 Test (org.junit.Test)8 KsqlRequest (io.confluent.ksql.rest.entity.KsqlRequest)7 Response (javax.ws.rs.core.Response)7 CommandStatusEntity (io.confluent.ksql.rest.entity.CommandStatusEntity)3 ExecutionPlan (io.confluent.ksql.rest.entity.ExecutionPlan)3 HashMap (java.util.HashMap)3 PropertiesList (io.confluent.ksql.rest.entity.PropertiesList)2 POST (javax.ws.rs.POST)2 FakeException (io.confluent.ksql.FakeException)1 AbstractStreamCreateStatement (io.confluent.ksql.parser.tree.AbstractStreamCreateStatement)1 DdlStatement (io.confluent.ksql.parser.tree.DdlStatement)1 Statement (io.confluent.ksql.parser.tree.Statement)1 QueryId (io.confluent.ksql.query.QueryId)1 KafkaTopicInfo (io.confluent.ksql.rest.entity.KafkaTopicInfo)1 KafkaTopicsList (io.confluent.ksql.rest.entity.KafkaTopicsList)1 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)1 KsqlTopicInfo (io.confluent.ksql.rest.entity.KsqlTopicInfo)1 KsqlTopicsList (io.confluent.ksql.rest.entity.KsqlTopicsList)1