Search in sources :

Example 21 with ProcessorResponse

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

the class ProcessorAPITest method listProcessorsFilterByName.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByName() {
    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.createKafkaAction())).as(ProcessorResponse.class);
    ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByName(bridgeResponse.getId(), "myProcessor2").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 22 with ProcessorResponse

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

the class ProcessorAPITest method listProcessorsFilterByNameAndType.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByNameAndType() {
    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.listProcessorsFilterByNameAndType(bridgeResponse.getId(), "myProcessor", 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 23 with ProcessorResponse

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

the class ProcessorAPITest method addProcessorToBridgeAndRetrieve.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridgeAndRetrieve() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, TestUtils.createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(202);
    ProcessorResponse retrieved = TestUtils.getProcessor(bridgeResponse.getId(), response.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
    assertThat(retrieved.getName()).isEqualTo("myProcessor");
    assertThat(retrieved.getFilters().size()).isEqualTo(1);
    assertThat(retrieved.getTransformationTemplate()).isNull();
    assertRequestedAction(retrieved);
}
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) 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 24 with ProcessorResponse

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

the class ProcessorAPITest method listProcessorsFilterByStatus.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByStatus() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    ProcessorResponse p1 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
    ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
    setProcessorStatus(p1.getId(), ACCEPTED);
    setProcessorStatus(p2.getId(), READY);
    ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByStatus(bridgeResponse.getId(), READY).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 25 with ProcessorResponse

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

the class ProcessorServiceTest method testUpdateProcessorWithTemplate.

@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithTemplate(ProcessorRequest request) {
    Processor existingProcessor = createReadyProcessorFromRequest(request);
    when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
    String updatedTransformationTemplate = "template";
    request.setTransformationTemplate(updatedTransformationTemplate);
    Processor updatedProcessor = processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request);
    ProcessorResponse updatedResponse = processorService.toResponse(updatedProcessor);
    assertThat(updatedResponse.getStatus()).isEqualTo(ACCEPTED);
    assertThat(updatedResponse.getFilters()).isNull();
    assertThat(updatedResponse.getTransformationTemplate()).isEqualTo(updatedTransformationTemplate);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)27 QuarkusTest (io.quarkus.test.junit.QuarkusTest)22 Test (org.junit.jupiter.api.Test)22 TestSecurity (io.quarkus.test.security.TestSecurity)21 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)20 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)20 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)20 Response (io.restassured.response.Response)11 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)7 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)7 Bridge (com.redhat.service.smartevents.manager.models.Bridge)7 Processor (com.redhat.service.smartevents.manager.models.Processor)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Action (com.redhat.service.smartevents.infra.models.gateways.Action)2 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)2 BridgeContext (com.redhat.service.smartevents.integration.tests.context.BridgeContext)2 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)2 When (io.cucumber.java.en.When)2 JsonObject (io.vertx.core.json.JsonObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2