Search in sources :

Example 1 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method updateProcessorWithMalformedTemplate.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithMalformedTemplate() {
    Bridge bridge = Fixtures.createBridge();
    bridgeDAO.persist(bridge);
    Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", null, null, TestUtils.createKafkaAction()));
    ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    setProcessorAsReady(processor.getId());
    Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), null, "template {this.is.broken", processor.getAction()));
    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) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 2 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method updateProcessorWithTemplate.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithTemplate() {
    Bridge bridge = Fixtures.createBridge();
    bridgeDAO.persist(bridge);
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("key", "value"));
    Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", filters, "template", TestUtils.createKafkaAction()));
    ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    setProcessorAsReady(processor.getId());
    Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), filters, "template-updated", processor.getAction()));
    assertThat(response.getStatusCode()).isEqualTo(202);
    ProcessorResponse updated = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    assertThat(updated.getName()).isEqualTo("myProcessor");
    assertThat(updated.getFilters().size()).isEqualTo(1);
    BaseFilter updatedFilter = updated.getFilters().iterator().next();
    assertThat(updatedFilter.getKey()).isEqualTo("key");
    assertThat(updatedFilter.getValue()).isEqualTo("value");
    assertThat(updated.getTransformationTemplate()).isEqualTo("template-updated");
    assertRequestedAction(updated);
}
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) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) 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 3 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method updateProcessorWithName.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithName() {
    Bridge bridge = Fixtures.createBridge();
    bridgeDAO.persist(bridge);
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("key", "value"));
    Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", filters, null, TestUtils.createKafkaAction()));
    ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    setProcessorAsReady(processor.getId());
    Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName() + "-updated", filters, processor.getTransformationTemplate(), processor.getAction()));
    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) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) 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 Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ConnectorsServiceTest method processorWith.

private static Processor processorWith(Gateway gateway) {
    Processor processor = new Processor();
    processor.setBridge(new Bridge());
    ProcessorDefinition processorDefinition = new ProcessorDefinition();
    if (gateway instanceof Action) {
        processorDefinition.setRequestedAction((Action) gateway);
        processor.setType(ProcessorType.SINK);
    } else {
        processorDefinition.setRequestedSource((Source) gateway);
        processor.setType(ProcessorType.SOURCE);
    }
    processor.setId(TEST_PROCESSOR_ID);
    processor.setName(TEST_PROCESSOR_NAME);
    processor.setDefinition(processorDefinition);
    return processor;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) SlackAction(com.redhat.service.smartevents.processor.actions.slack.SlackAction) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition) Bridge(com.redhat.service.smartevents.manager.models.Bridge)

Example 5 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeDAOTest method testListByCustomerIdPaginationFilterByStatus.

@Test
public void testListByCustomerIdPaginationFilterByStatus() {
    for (int i = 0; i < 10; i++) {
        String id = String.valueOf(i);
        Bridge bridge = buildBridge(id, id);
        bridge.setStatus(i % 2 == 0 ? READY : ACCEPTED);
        bridgeDAO.persist(bridge);
    }
    ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(0, 2, filter().by(READY).build()));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(5);
    assertThat(retrievedBridges.getPage()).isZero();
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("8");
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("6");
    retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(1, 2, filter().by(READY).build()));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(5);
    assertThat(retrievedBridges.getPage()).isEqualTo(1);
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("4");
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("2");
    retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(2, 2, filter().by(READY).build()));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(1);
    assertThat(retrievedBridges.getTotal()).isEqualTo(5);
    assertThat(retrievedBridges.getPage()).isEqualTo(2);
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("0");
}
Also used : QueryResourceInfo(com.redhat.service.smartevents.infra.models.QueryResourceInfo) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

Bridge (com.redhat.service.smartevents.manager.models.Bridge)99 QuarkusTest (io.quarkus.test.junit.QuarkusTest)68 Test (org.junit.jupiter.api.Test)68 Processor (com.redhat.service.smartevents.manager.models.Processor)45 Transactional (javax.transaction.Transactional)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 TestSecurity (io.quarkus.test.security.TestSecurity)14 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)13 Work (com.redhat.service.smartevents.manager.models.Work)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 QueryResourceInfo (com.redhat.service.smartevents.infra.models.QueryResourceInfo)11 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)11 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)10 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)9 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)8 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)8 Response (io.restassured.response.Response)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Action (com.redhat.service.smartevents.infra.models.gateways.Action)7 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)7