Search in sources :

Example 11 with Processor

use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testUpdateProcessorWithFilter.

@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithFilter(ProcessorRequest request) {
    Processor existingProcessor = createReadyProcessorFromRequest(request);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
    Set<BaseFilter> updatedFilters = Collections.singleton(new StringEquals("key", "value"));
    request.setFilters(updatedFilters);
    Processor updatedProcessor = processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request);
    ProcessorResponse updatedResponse = processorService.toResponse(updatedProcessor);
    assertThat(updatedResponse.getStatus()).isEqualTo(ACCEPTED);
    assertThat(updatedResponse.getFilters()).hasSize(1);
    BaseFilter updatedFilter = updatedResponse.getFilters().iterator().next();
    assertThat(updatedFilter.getKey()).isEqualTo("key");
    assertThat(updatedFilter.getValue()).isEqualTo("value");
    assertThat(updatedResponse.getTransformationTemplate()).isNull();
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with Processor

use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method createErrorHandlerProcessor.

private static Processor createErrorHandlerProcessor() {
    Processor processor = createReadyProcessorFromRequest(new ProcessorRequest(ERROR_HANDLER_PROCESSOR_NAME, TestUtils.createWebhookAction()));
    processor.setId(ERROR_HANDLER_PROCESSOR_ID);
    processor.setType(ERROR_HANDLER);
    return processor;
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)

Example 13 with Processor

use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testUpdateProcessorWithGatewayWithOppositeType.

@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithGatewayWithOppositeType(ProcessorRequest request) {
    Processor existingProcessor = createReadyProcessorFromRequest(request);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
    if (request.getType() == ProcessorType.SOURCE) {
        Action dummyNewAction = new Action();
        dummyNewAction.setType("DummyAction");
        request.setAction(dummyNewAction);
        request.setSource(null);
    } else if (request.getType() == SINK) {
        Source dummyNewSource = new Source();
        dummyNewSource.setType("DummySource");
        request.setSource(dummyNewSource);
        request.setAction(null);
    }
    assertThatExceptionOfType(BadRequestException.class).isThrownBy(() -> processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request));
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) Processor(com.redhat.service.smartevents.manager.models.Processor) BadRequestException(com.redhat.service.smartevents.infra.exceptions.definitions.user.BadRequestException) MethodSource(org.junit.jupiter.params.provider.MethodSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source) SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with Processor

use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testUpdateProcessorStatus.

@Test
void testUpdateProcessorStatus() {
    ProcessorDTO updateDto = new ProcessorDTO();
    updateDto.setType(DEFAULT_PROCESSOR_TYPE);
    updateDto.setId(DEFAULT_PROCESSOR_ID);
    updateDto.setBridgeId(DEFAULT_BRIDGE_ID);
    updateDto.setCustomerId(DEFAULT_CUSTOMER_ID);
    updateDto.setStatus(FAILED);
    Processor updated = processorService.updateProcessorStatus(updateDto);
    assertThat(updated.getStatus()).isEqualTo(FAILED);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with Processor

use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method doTestCreateProcessor.

private void doTestCreateProcessor(ProcessorRequest request, ProcessorType type) {
    Processor processor = processorService.createProcessor(DEFAULT_BRIDGE_ID, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, request);
    doAssertProcessorCreation(processor, request, type);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor)

Aggregations

Processor (com.redhat.service.smartevents.manager.models.Processor)82 Bridge (com.redhat.service.smartevents.manager.models.Bridge)45 QuarkusTest (io.quarkus.test.junit.QuarkusTest)36 Test (org.junit.jupiter.api.Test)36 Transactional (javax.transaction.Transactional)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 Action (com.redhat.service.smartevents.infra.models.gateways.Action)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)9 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)8 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Work (com.redhat.service.smartevents.manager.models.Work)7 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)6 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)6 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)6 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)5 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)5 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)5