Search in sources :

Example 1 with Status

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

the class DistributingExecutorTest method setUp.

@Before
public void setUp() throws InterruptedException {
    scnCounter = new AtomicLong();
    when(schemaInjector.inject(any())).thenAnswer(inv -> inv.getArgument(0));
    when(topicInjector.inject(any())).thenAnswer(inv -> inv.getArgument(0));
    when(queue.enqueueCommand(any(), any(), any())).thenReturn(status);
    when(status.tryWaitForFinalStatus(any())).thenReturn(SUCCESS_STATUS);
    when(status.getCommandId()).thenReturn(CS_COMMAND);
    when(status.getCommandSequenceNumber()).thenAnswer(inv -> scnCounter.incrementAndGet());
    when(executionContext.getMetaStore()).thenReturn(metaStore);
    when(executionContext.createSandbox(any())).thenReturn(sandboxContext);
    when(commandRunnerWarning.get()).thenReturn("");
    serviceContext = SandboxedServiceContext.create(TestServiceContext.create());
    when(executionContext.getServiceContext()).thenReturn(serviceContext);
    when(validatedCommandFactory.create(any(), any())).thenReturn(command);
    when(queue.createTransactionalProducer()).thenReturn(transactionalProducer);
    securityContext = new KsqlSecurityContext(Optional.empty(), serviceContext);
    distributor = new DistributingExecutor(KSQL_CONFIG, queue, DURATION_10_MS, (ec, sc) -> InjectorChain.of(schemaInjector, topicInjector), Optional.of(authorizationValidator), validatedCommandFactory, errorHandler, commandRunnerWarning);
}
Also used : DataSource(io.confluent.ksql.metastore.model.DataSource) Query(io.confluent.ksql.parser.tree.Query) ArgumentMatchers(org.mockito.ArgumentMatchers) Matchers.isA(org.hamcrest.Matchers.isA) ColumnName(io.confluent.ksql.name.ColumnName) SourceName(io.confluent.ksql.name.SourceName) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) StatementExecutorResponse(io.confluent.ksql.rest.server.execution.StatementExecutorResponse) ServiceContext(io.confluent.ksql.services.ServiceContext) KsqlTopicAuthorizationException(io.confluent.ksql.exception.KsqlTopicAuthorizationException) CommandId(io.confluent.ksql.rest.entity.CommandId) InjectorChain(io.confluent.ksql.statement.InjectorChain) CommonCreateConfigs(io.confluent.ksql.properties.with.CommonCreateConfigs) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) KsqlErrorMessage(io.confluent.ksql.rest.entity.KsqlErrorMessage) KsqlAuthorizationValidator(io.confluent.ksql.security.KsqlAuthorizationValidator) Mockito.doThrow(org.mockito.Mockito.doThrow) Duration(java.time.Duration) Mockito.doReturn(org.mockito.Mockito.doReturn) CommandStatus(io.confluent.ksql.rest.entity.CommandStatus) ImmutableMap(com.google.common.collect.ImmutableMap) Errors(io.confluent.ksql.rest.Errors) Mockito.doNothing(org.mockito.Mockito.doNothing) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlConfig(io.confluent.ksql.util.KsqlConfig) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) KsqlRestConfig(io.confluent.ksql.rest.server.KsqlRestConfig) TestServiceContext(io.confluent.ksql.services.TestServiceContext) KsqlExecutionContext(io.confluent.ksql.KsqlExecutionContext) ProducerFencedException(org.apache.kafka.common.errors.ProducerFencedException) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Status(io.confluent.ksql.rest.entity.CommandStatus.Status) KsqlRestException(io.confluent.ksql.rest.server.resources.KsqlRestException) KsqlException(io.confluent.ksql.util.KsqlException) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Statement(io.confluent.ksql.parser.tree.Statement) WarningEntity(io.confluent.ksql.rest.entity.WarningEntity) Matchers.containsString(org.hamcrest.Matchers.containsString) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Action(io.confluent.ksql.rest.entity.CommandId.Action) Mock(org.mockito.Mock) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) KsqlSecurityContext(io.confluent.ksql.security.KsqlSecurityContext) Supplier(java.util.function.Supplier) ListProperties(io.confluent.ksql.parser.tree.ListProperties) SessionConfig(io.confluent.ksql.config.SessionConfig) CreateStream(io.confluent.ksql.parser.tree.CreateStream) ImmutableList(com.google.common.collect.ImmutableList) Injector(io.confluent.ksql.statement.Injector) MetaStore(io.confluent.ksql.metastore.MetaStore) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) InsertInto(io.confluent.ksql.parser.tree.InsertInto) Before(org.junit.Before) TimeoutException(org.apache.kafka.common.errors.TimeoutException) InOrder(org.mockito.InOrder) Producer(org.apache.kafka.clients.producer.Producer) Assert.assertTrue(org.junit.Assert.assertTrue) CommandStatusEntity(io.confluent.ksql.rest.entity.CommandStatusEntity) SandboxedServiceContext(io.confluent.ksql.services.SandboxedServiceContext) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Type(io.confluent.ksql.rest.entity.CommandId.Type) AtomicLong(java.util.concurrent.atomic.AtomicLong) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) CreateSourceProperties(io.confluent.ksql.parser.properties.with.CreateSourceProperties) KsqlServerException(io.confluent.ksql.util.KsqlServerException) TableElements(io.confluent.ksql.parser.tree.TableElements) DefaultErrorMessages(io.confluent.ksql.rest.DefaultErrorMessages) Assert.assertEquals(org.junit.Assert.assertEquals) PreparedStatement(io.confluent.ksql.parser.KsqlParser.PreparedStatement) AtomicLong(java.util.concurrent.atomic.AtomicLong) KsqlSecurityContext(io.confluent.ksql.security.KsqlSecurityContext) Before(org.junit.Before)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 KsqlExecutionContext (io.confluent.ksql.KsqlExecutionContext)1 SessionConfig (io.confluent.ksql.config.SessionConfig)1 KsqlTopicAuthorizationException (io.confluent.ksql.exception.KsqlTopicAuthorizationException)1 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)1 MetaStore (io.confluent.ksql.metastore.MetaStore)1 DataSource (io.confluent.ksql.metastore.model.DataSource)1 ColumnName (io.confluent.ksql.name.ColumnName)1 SourceName (io.confluent.ksql.name.SourceName)1 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)1 CreateSourceProperties (io.confluent.ksql.parser.properties.with.CreateSourceProperties)1 CreateStream (io.confluent.ksql.parser.tree.CreateStream)1 InsertInto (io.confluent.ksql.parser.tree.InsertInto)1 ListProperties (io.confluent.ksql.parser.tree.ListProperties)1 Query (io.confluent.ksql.parser.tree.Query)1 Statement (io.confluent.ksql.parser.tree.Statement)1 TableElements (io.confluent.ksql.parser.tree.TableElements)1 CommonCreateConfigs (io.confluent.ksql.properties.with.CommonCreateConfigs)1 DefaultErrorMessages (io.confluent.ksql.rest.DefaultErrorMessages)1