Search in sources :

Example 16 with ProcessorRequest

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

the class ProcessorAPITest method listProcessors_pageOffset.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors_pageOffset() {
    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.listProcessors(bridgeResponse.getId(), 1, 1).as(ProcessorListResponse.class);
    assertThat(listResponse.getPage()).isEqualTo(1L);
    assertThat(listResponse.getSize()).isEqualTo(1L);
    assertThat(listResponse.getTotal()).isEqualTo(2L);
    assertThat(listResponse.getItems().get(0).getId()).isEqualTo(p2.getId());
    assertRequestedAction(listResponse.getItems().get(0));
}
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 17 with ProcessorRequest

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

the class ProcessorAPITest method listProcessorsFilterByNameAndStatus.

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

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

the class ProcessorGatewayConstraintValidatorTest method isValid_noGatewaysIsNotValid.

@Test
void isValid_noGatewaysIsNotValid() {
    ProcessorRequest p = new ProcessorRequest();
    assertThat(constraintValidator.isValid(p, validatorContextMock)).isFalse();
    verify(gatewayConfiguratorMock, never()).getActionValidator(any());
    verify(gatewayConfiguratorMock, never()).getSourceValidator(any());
    verify(actionValidatorMock, never()).isValid(any());
    verify(sourceValidatorMock, never()).isValid(any());
    verifyErrorMessage(MISSING_GATEWAY_ERROR);
}
Also used : ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with ProcessorRequest

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

the class ProcessorGatewayConstraintValidatorTest method isValid_gatewayWithEmptyParamsIsValid.

@ParameterizedTest
@MethodSource("gateways")
void isValid_gatewayWithEmptyParamsIsValid(Gateway gateway) {
    gateway.setMapParameters(new HashMap<>());
    ProcessorRequest p = buildTestRequest(gateway);
    assertThat(constraintValidator.isValid(p, validatorContextMock)).isTrue();
    verifyGetValidatorCall(gateway, times(1), gateway.getType());
    verifyIsValidCall(gateway, times(1));
}
Also used : ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 20 with ProcessorRequest

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

the class ProcessorGatewayConstraintValidatorTest method isValid_noMessageFromValidatorGenericMessageAdded.

@ParameterizedTest
@MethodSource("gateways")
void isValid_noMessageFromValidatorGenericMessageAdded(Gateway gateway) {
    lenient().when(actionValidatorMock.isValid(any())).thenReturn(ValidationResult.invalid());
    lenient().when(sourceValidatorMock.isValid(any())).thenReturn(ValidationResult.invalid());
    ProcessorRequest p = buildTestRequest(gateway);
    assertThat(constraintValidator.isValid(p, validatorContextMock)).isFalse();
    verifyGetValidatorCall(gateway, times(1), gateway.getType());
    verifyIsValidCall(gateway, times(1));
    verifyErrorMessage(GATEWAY_PARAMETERS_NOT_VALID_ERROR, gateway, true);
}
Also used : ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)59 Test (org.junit.jupiter.api.Test)49 QuarkusTest (io.quarkus.test.junit.QuarkusTest)47 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)41 TestSecurity (io.quarkus.test.security.TestSecurity)40 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)36 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)36 Response (io.restassured.response.Response)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)11 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)11 Bridge (com.redhat.service.smartevents.manager.models.Bridge)11 Action (com.redhat.service.smartevents.infra.models.gateways.Action)10 Processor (com.redhat.service.smartevents.manager.models.Processor)8 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)8 MethodSource (org.junit.jupiter.params.provider.MethodSource)8 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)6 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)6 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)6 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)6