Search in sources :

Example 26 with Action

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

the class SendToBridgeActionResolverTest method testActionWithUnavailableBridgeId.

@Test
void testActionWithUnavailableBridgeId() {
    Action inputAction = actionWithBridgeId(UNAVAILABLE_BRIDGE_ID);
    assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> resolver.resolve(inputAction, TEST_CUSTOMER_ID, BRIDGE_ID, ""));
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) BridgeLifecycleException(com.redhat.service.smartevents.infra.exceptions.definitions.user.BridgeLifecycleException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 27 with Action

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

the class SlackActionResolverTest method testTransform.

@Test
void testTransform() {
    Action action = buildTestAction();
    Action transformedAction = slackActionResolver.resolve(action, TEST_CUSTOMER_ID, TEST_BRIDGE_ID, TEST_PROCESSOR_ID);
    assertThat(transformedAction.getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(transformedAction.getParameter(SlackAction.CHANNEL_PARAM)).isEqualTo(TEST_CHANNEL_PARAM);
    assertThat(transformedAction.getParameter(SlackAction.WEBHOOK_URL_PARAM)).isEqualTo(TEST_WEBHOOK_PARAM);
    assertThat(transformedAction.getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TEST_PROCESSOR_TOPIC_NAME);
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 28 with Action

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

the class SlackActionResolverTest method buildTestAction.

private Action buildTestAction() {
    Map<String, String> parameters = Map.of(SlackAction.CHANNEL_PARAM, TEST_CHANNEL_PARAM, SlackAction.WEBHOOK_URL_PARAM, TEST_WEBHOOK_PARAM);
    Action action = new Action();
    action.setType(SlackAction.TYPE);
    action.setMapParameters(parameters);
    return action;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)

Example 29 with Action

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

the class WebhookActionValidatorTest method isInvalidWithNullParametersMap.

@Test
void isInvalidWithNullParametersMap() {
    Action action = new Action();
    action.setType(WebhookAction.TYPE);
    action.setMapParameters(new HashMap<>());
    ValidationResult validationResult = validator.isValid(action);
    assertThat(validationResult.isValid()).isFalse();
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) ValidationResult(com.redhat.service.smartevents.infra.validations.ValidationResult) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with Action

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

the class KafkaTopicActionInvokerBuilderTest method createProcessorWithActionForTopic.

private ProcessorDTO createProcessorWithActionForTopic(String topicName) {
    Action b = new Action();
    b.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, topicName);
    b.setMapParameters(params);
    ProcessorDTO p = new ProcessorDTO();
    p.setType(ProcessorType.SINK);
    p.setId("myProcessor");
    p.setDefinition(new ProcessorDefinition(null, null, b));
    p.setBridgeId("myBridge");
    return p;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)

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