Search in sources :

Example 16 with Action

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

the class BridgesAPITest method getBridgeWithErrorHandler.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getBridgeWithErrorHandler() {
    Action errorHandler = createWebhookAction();
    Response bridgeCreateResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME, errorHandler));
    bridgeCreateResponse.then().statusCode(202);
    BridgeResponse bridge = bridgeCreateResponse.as(BridgeResponse.class);
    BridgeResponse retrievedBridge = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
    assertThat(retrievedBridge).isNotNull();
    assertThat(retrievedBridge.getId()).isEqualTo(bridge.getId());
    assertThat(retrievedBridge.getName()).isEqualTo(bridge.getName());
    assertThat(retrievedBridge.getEndpoint()).isEqualTo(bridge.getEndpoint());
    assertThat(retrievedBridge.getErrorHandler()).isNotNull();
    assertThat(retrievedBridge.getErrorHandler()).isEqualTo(errorHandler);
}
Also used : ErrorResponse(com.redhat.service.smartevents.infra.api.models.responses.ErrorResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) Response(io.restassured.response.Response) BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) Action(com.redhat.service.smartevents.infra.models.gateways.Action) TestUtils.createWebhookAction(com.redhat.service.smartevents.manager.utils.TestUtils.createWebhookAction) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 17 with Action

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

the class TestUtils method createWebhookAction.

public static Action createWebhookAction() {
    Action action = new Action();
    action.setType(WebhookAction.TYPE);
    action.setMapParameters(Map.of(WebhookAction.ENDPOINT_PARAM, "https://webhook.site/a0704e8f-a817-4d02-b30a-b8c49d0132dc"));
    return action;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)

Example 18 with Action

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

the class SourceResolver method resolve.

@Override
public Action resolve(Source source, String customerId, String bridgeId, String processorId) {
    Action resolvedAction = new Action();
    resolvedAction.setType(WebhookAction.TYPE);
    resolvedAction.setMapParameters(Map.of(WebhookAction.ENDPOINT_PARAM, getBridgeWebhookUrl(customerId, bridgeId), WebhookAction.USE_TECHNICAL_BEARER_TOKEN_PARAM, "true"));
    return resolvedAction;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)

Example 19 with Action

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

the class KafkaTopicActionValidatorTest method createActionWithTopic.

private Action createActionWithTopic(String topicName) {
    Action action = new Action();
    action.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, topicName);
    action.setMapParameters(params);
    return action;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) HashMap(java.util.HashMap)

Example 20 with Action

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

the class KafkaTopicActionValidatorTest method isInvalid_noTopicIsNotValid.

@Test
void isInvalid_noTopicIsNotValid() {
    Action action = createActionWithTopic("myTopic");
    action.getParameters().remove(KafkaTopicAction.TOPIC_PARAM);
    ValidationResult validationResult = validator.isValid(action);
    assertThat(validationResult.isValid()).isFalse();
    assertThat(validationResult.getMessage()).isEqualTo("$.topic: is missing but it is required");
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) ValidationResult(com.redhat.service.smartevents.infra.validations.ValidationResult) 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