Search in sources :

Example 1 with Source

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

the class ConnectorsServiceTest method slackSource.

private static Source slackSource() {
    Source action = new Source();
    action.setType(SlackSource.TYPE);
    action.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, TEST_SOURCE_CHANNEL, SlackSource.TOKEN_PARAM, TEST_SOURCE_TOKEN));
    return action;
}
Also used : SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) MethodSource(org.junit.jupiter.params.provider.MethodSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source)

Example 2 with Source

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

the class ProcessorServiceTest method createSlackSource.

private static Source createSlackSource() {
    Source source = new Source();
    source.setType(SlackSource.TYPE);
    source.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, "test-channel", SlackSource.TOKEN_PARAM, "test-token"));
    return source;
}
Also used : 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)

Example 3 with Source

use of com.redhat.service.smartevents.infra.models.gateways.Source 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 4 with Source

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

the class TestUtils method createSlackSource.

public static Source createSlackSource() {
    Source s = new Source();
    s.setType(SlackSource.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(SlackSource.CHANNEL_PARAM, "channel");
    params.put(SlackSource.TOKEN_PARAM, "token");
    s.setMapParameters(params);
    return s;
}
Also used : HashMap(java.util.HashMap) SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source)

Example 5 with Source

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

the class GatewayConnectorTest method testSlackConnectorPayloadWithErrorHandler.

@Test
public void testSlackConnectorPayloadWithErrorHandler() throws JsonProcessingException {
    String channel = "channel";
    String token = "token";
    String topicName = "topic";
    String errorTopicName = "errorHandlerTopic";
    String payload = "{" + "  \"slack_channel\":\"" + channel + "\"," + "  \"slack_token\":\"" + token + "\"," + "  \"kafka_topic\":\"" + topicName + "\"," + "  \"processors\": [" + "    {" + "      \"log\": {" + "        \"multiLine\":true," + "        \"showHeaders\":true" + "      }" + "    }" + "  ], " + "  \"error_handler\": {" + "    \"dead_letter_queue\": {" + "      \"topic\": \"errorHandlerTopic\"" + "    }" + "  }" + "}";
    JsonNode expectedPayload = mapper.readTree(payload);
    Source source = new Source();
    source.setType(SlackSource.TYPE);
    source.setMapParameters(Map.of(SlackSource.CHANNEL_PARAM, channel, SlackSource.TOKEN_PARAM, token));
    JsonNode actualPayload = gatewayConnector.connectorPayload(source, topicName, errorTopicName);
    assertThat(actualPayload).isEqualTo(expectedPayload);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) SlackSource(com.redhat.service.smartevents.processor.sources.slack.SlackSource) Source(com.redhat.service.smartevents.infra.models.gateways.Source) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

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