Search in sources :

Example 6 with BridgeResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method getProcessor.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessor() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(202);
    ProcessorResponse pr = response.as(ProcessorResponse.class);
    assertThat(pr.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(pr.getAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
    ProcessorResponse found = TestUtils.getProcessor(bridgeResponse.getId(), pr.getId()).as(ProcessorResponse.class);
    assertThat(found.getId()).isEqualTo(pr.getId());
    assertThat(found.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(found.getAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
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) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) 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 7 with BridgeResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method listProcessorsFilterByType.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByType() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
    ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", TestUtils.createSlackSource())).as(ProcessorResponse.class);
    ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByType(bridgeResponse.getId(), SOURCE).as(ProcessorListResponse.class);
    assertThat(listResponse.getPage()).isZero();
    assertThat(listResponse.getSize()).isEqualTo(1L);
    assertThat(listResponse.getTotal()).isEqualTo(1L);
    assertThat(listResponse.getItems().get(0).getId()).isEqualTo(p2.getId());
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) 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 8 with BridgeResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse 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 9 with BridgeResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse 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 10 with BridgeResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method addProcessorWithWrongFilterFiltersToBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorWithWrongFilterFiltersToBridge() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", Collections.singleton(new StringIn("pepe", null)), null, TestUtils.createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
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) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) StringIn(com.redhat.service.smartevents.infra.models.filters.StringIn) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)48 QuarkusTest (io.quarkus.test.junit.QuarkusTest)42 TestSecurity (io.quarkus.test.security.TestSecurity)42 Test (org.junit.jupiter.api.Test)42 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)29 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)27 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)26 Response (io.restassured.response.Response)19 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)10 BridgeListResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse)8 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)7 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)7 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)7 Action (com.redhat.service.smartevents.infra.models.gateways.Action)6 TypeRef (io.restassured.common.mapper.TypeRef)6 ArrayList (java.util.ArrayList)6 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)5 Bridge (com.redhat.service.smartevents.manager.models.Bridge)5 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)5 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)5