Search in sources :

Example 61 with Action

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

the class GatewayConnectorTest method testSlackConnectorPayload.

@Test
public void testSlackConnectorPayload() throws JsonProcessingException {
    String channel = "channel";
    String webhookURL = "https://www.example.com/webhook";
    String topicName = "topic";
    String payload = "{" + "   \"slack_channel\":\"" + channel + "\"," + "   \"slack_webhook_url\":\"" + webhookURL + "\"," + "   \"kafka_topic\":\"" + topicName + "\"," + "   \"processors\": [" + "       {" + "           \"log\": {" + "               \"multiLine\":true," + "               \"showHeaders\":true" + "        }" + "     }" + "   ]" + "}";
    JsonNode expectedPayload = mapper.readTree(payload);
    Action action = new Action();
    action.setType(SlackAction.TYPE);
    action.setMapParameters(Map.of(SlackAction.CHANNEL_PARAM, channel, SlackAction.WEBHOOK_URL_PARAM, webhookURL));
    JsonNode actualPayload = gatewayConnector.connectorPayload(action, topicName);
    assertThat(actualPayload).isEqualTo(expectedPayload);
}
Also used : SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) Action(com.redhat.service.smartevents.infra.models.gateways.Action) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 62 with Action

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

the class KafkaTopicActionValidatorTest method isValid.

@Test
void isValid() {
    Action action = createActionWithTopic("myTopic");
    assertThat(validator.isValid(action).isValid()).isTrue();
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

Action (com.redhat.service.smartevents.infra.models.gateways.Action)62 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)23 QuarkusTest (io.quarkus.test.junit.QuarkusTest)23 Test (org.junit.jupiter.api.Test)23 WebhookAction (com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)21 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)13 HashMap (java.util.HashMap)13 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)12 Processor (com.redhat.service.smartevents.manager.models.Processor)12 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)12 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)9 Source (com.redhat.service.smartevents.infra.models.gateways.Source)7 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)6 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)6 Bridge (com.redhat.service.smartevents.manager.models.Bridge)6 TestSecurity (io.quarkus.test.security.TestSecurity)6 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)5 Response (io.restassured.response.Response)5 ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)4 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)4