Search in sources :

Example 1 with Action

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

the class ProcessorAPITest method addProcessorToBridge_unrecognisedActionType.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_unrecognisedActionType() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Action action = TestUtils.createKafkaAction();
    action.setType("thisDoesNotExist");
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, action));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 2 with Action

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

the class ProcessorAPITest method addProcessorWithEmptyWebhookURLParameterToBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorWithEmptyWebhookURLParameterToBridge() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Action action = TestUtils.createKafkaAction();
    action.setType(SlackAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(SlackAction.CHANNEL_PARAM, "channel");
    params.put(SlackAction.WEBHOOK_URL_PARAM, "");
    action.setMapParameters(params);
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", null, null, action));
    assertThat(response.getStatusCode()).isEqualTo(202);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction) HashMap(java.util.HashMap) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 3 with Action

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

the class ProcessorAPITest method addProcessorToBridge_missingActionParameters.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_missingActionParameters() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Action action = TestUtils.createKafkaAction();
    action.setMapParameters(new HashMap<>());
    action.getParameters().put("thisIsNotCorrect", "myTopic");
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, action));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 4 with Action

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

the class ProcessorAPITest method assertRequestedAction.

private void assertRequestedAction(ProcessorResponse processorResponse) {
    Action action = processorResponse.getAction();
    assertThat(action).isNotNull();
    assertThat(action.getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(action.getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)

Example 5 with Action

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

the class ProcessorGatewayConstraintValidatorTest method buildTestAction.

private static Action buildTestAction() {
    Action action = new Action();
    action.setType(TEST_ACTION_TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(TEST_PARAM_NAME, TEST_PARAM_VALUE);
    action.setMapParameters(params);
    return action;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) HashMap(java.util.HashMap)

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