Search in sources :

Example 36 with BridgeResponse

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

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

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

the class ProcessorAPITest method listProcessorsFilterByTypeWithIncorrectValue.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByTypeWithIncorrectValue() {
    // See JAX-RS 2.1 Specification, Section 3.2.
    // HTTP-404 is correct if the QueryString contains an invalid value.
    // If the field or property is annotated with @MatrixParam, @QueryParam or @PathParam then an implementation
    // MUST generate an instance of NotFoundException (404 status) that wraps the thrown exception...
    BridgeResponse bridgeResponse = createAndDeployBridge();
    TestUtils.listProcessorsFilterByTypeWithAnyValue(bridgeResponse.getId(), "banana").then().statusCode(404);
}
Also used : 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 39 with BridgeResponse

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

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

the class ShardBridgesSyncAPITest method getProcessorsWithKafkaAction.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getProcessorsWithKafkaAction() {
    BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    // Emulate the Shard having deployed the Bridge
    BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO());
    TestUtils.updateBridge(bridge);
    // Create a Processor for the Bridge
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, filters, null, TestUtils.createKafkaAction()));
    final List<ProcessorDTO> processors = new ArrayList<>();
    await().atMost(5, SECONDS).untilAsserted(() -> {
        processors.clear();
        processors.addAll(TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
        }));
        assertThat(processors.size()).isEqualTo(1);
    });
    ProcessorDTO processor = processors.get(0);
    assertThat(processor.getName()).isEqualTo(DEFAULT_PROCESSOR_NAME);
    assertThat(processor.getStatus()).isEqualTo(PREPARING);
    assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
    assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
    assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(processor.getDefinition().getRequestedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
    assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
    assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(processor.getDefinition().getResolvedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
Also used : StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) TypeRef(io.restassured.common.mapper.TypeRef) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) ArrayList(java.util.ArrayList) 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)

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