Search in sources :

Example 11 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorGatewayConstraintValidatorTest method buildTestSource.

private static Source buildTestSource() {
    Source source = new Source();
    source.setType(TEST_SOURCE_TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(TEST_PARAM_NAME, TEST_PARAM_VALUE);
    source.setMapParameters(params);
    return source;
}
Also used : HashMap(java.util.HashMap) MethodSource(org.junit.jupiter.params.provider.MethodSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source)

Example 12 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testUpdateProcessorWithGateway.

@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithGateway(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) {
        Source dummyNewSource = new Source();
        dummyNewSource.setType("DummySource");
        request.setSource(dummyNewSource);
    } else if (request.getType() == SINK) {
        Action dummyNewAction = new Action();
        dummyNewAction.setType("DummyAction");
        request.setAction(dummyNewAction);
    }
    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 13 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SourceResolverTest method createSlackSource.

private Source createSlackSource() {
    Source source = new Source();
    source.setType(SlackSource.TYPE);
    source.setMapParameters(Map.of(CHANNEL_PARAM, "channel", TOKEN_PARAM, "token"));
    return source;
}
Also used : SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source)

Example 14 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SourceResolverTest method testActionWithoutBridgeId.

@Test
void testActionWithoutBridgeId() {
    Source inputSource = createSlackSource();
    Action resolvedAction = resolver.resolve(inputSource, CUSTOMER_ID, BRIDGE_ID, PROCESSOR_ID);
    assertThat(resolvedAction).isNotNull();
    assertThat(resolvedAction.getType()).isEqualTo(WebhookAction.TYPE);
    assertThat(resolvedAction.getParameter(WebhookAction.ENDPOINT_PARAM)).isEqualTo(BRIDGE_ENDPOINT);
    assertThat(resolvedAction.getParameter(WebhookAction.USE_TECHNICAL_BEARER_TOKEN_PARAM)).isEqualTo("true");
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 15 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SourceResolverTest method testActionWithoutOtherBridgeId.

@Test
void testActionWithoutOtherBridgeId() {
    Source inputSource = createSlackSource();
    assertThatExceptionOfType(GatewayProviderException.class).isThrownBy(() -> resolver.resolve(inputSource, CUSTOMER_ID, OTHER_BRIDGE_ID, PROCESSOR_ID));
}
Also used : GatewayProviderException(com.redhat.service.smartevents.infra.exceptions.definitions.user.GatewayProviderException) SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

Source (com.redhat.service.smartevents.infra.models.gateways.Source)15 SlackSource (com.redhat.service.smartevents.processor.sources.slack.SlackSource)10 Action (com.redhat.service.smartevents.infra.models.gateways.Action)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 BadRequestException (com.redhat.service.smartevents.infra.exceptions.definitions.user.BadRequestException)3 Processor (com.redhat.service.smartevents.manager.models.Processor)3 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)3 QuarkusTest (io.quarkus.test.junit.QuarkusTest)3 Test (org.junit.jupiter.api.Test)3 GatewayProviderException (com.redhat.service.smartevents.infra.exceptions.definitions.user.GatewayProviderException)2 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)2 WebhookAction (com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)2 HashMap (java.util.HashMap)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ProcessorLifecycleException (com.redhat.service.smartevents.infra.exceptions.definitions.user.ProcessorLifecycleException)1 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)1 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)1 Transactional (javax.transaction.Transactional)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1