Search in sources :

Example 36 with ProcessorRequest

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

the class ActionParamValidatorContainerTest method isValid_nullActionIsNotValid.

@Test
public void isValid_nullActionIsNotValid() {
    ProcessorRequest p = buildTestRequest();
    p.setAction(null);
    assertThat(container.isValid(p, validatorContext)).isFalse();
    verify(actionProviderFactoryMock, never()).getActionProvider(any());
    verify(actionValidatorMock, never()).isValid(any());
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 37 with ProcessorRequest

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

the class ActionParamValidatorContainerTest method isValid_messageFromActionValidatorAddedOnFailure.

@Test
public void isValid_messageFromActionValidatorAddedOnFailure() {
    String testErrorMessage = "This is a test error message returned from action validator";
    when(actionValidatorMock.isValid(any())).thenReturn(ValidationResult.invalid(testErrorMessage));
    ProcessorRequest p = buildTestRequest();
    assertThat(container.isValid(p, validatorContext)).isFalse();
    verify(actionProviderFactoryMock).getActionProvider(TEST_ACTION_TYPE);
    verify(actionValidatorMock).isValid(any());
    ArgumentCaptor<String> messageCap = ArgumentCaptor.forClass(String.class);
    verify(validatorContext).disableDefaultConstraintViolation();
    verify(validatorContext).buildConstraintViolationWithTemplate(messageCap.capture());
    verify(builderMock).addConstraintViolation();
    assertThat(messageCap.getValue()).isEqualTo(testErrorMessage);
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 38 with ProcessorRequest

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

the class ActionParamValidatorContainerTest method isValid_actionWithEmptyParamsIsValid.

@Test
public void isValid_actionWithEmptyParamsIsValid() {
    ProcessorRequest p = buildTestRequest();
    p.getAction().getParameters().clear();
    assertThat(container.isValid(p, validatorContext)).isTrue();
    verify(actionProviderFactoryMock).getActionProvider(TEST_ACTION_TYPE);
    verify(actionValidatorMock).isValid(any());
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 39 with ProcessorRequest

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

the class SendToBridgeActionTransformerTest method testActionWithUnavailableBridgeId.

@Test
void testActionWithUnavailableBridgeId() {
    BaseAction inputAction = actionWithBridgeId(UNAVAILABLE_BRIDGE_ID);
    ProcessorRequest inputRequest = requestWithAction(inputAction);
    assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> transformer.transform(inputRequest.getAction(), bridge.getId(), TEST_CUSTOMER_ID, ""));
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 40 with ProcessorRequest

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

the class SendToBridgeActionTransformerTest method testActionWithUnknownBridgeId.

@Test
void testActionWithUnknownBridgeId() {
    BaseAction inputAction = actionWithBridgeId(UNKNOWN_BRIDGE_ID);
    ProcessorRequest inputRequest = requestWithAction(inputAction);
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> transformer.transform(inputRequest.getAction(), bridge.getId(), TEST_CUSTOMER_ID, ""));
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)48 QuarkusTest (io.quarkus.test.junit.QuarkusTest)46 Test (org.junit.jupiter.api.Test)46 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)22 TestSecurity (io.quarkus.test.security.TestSecurity)22 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)17 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)16 Bridge (com.redhat.service.bridge.manager.models.Bridge)15 Processor (com.redhat.service.bridge.manager.models.Processor)14 Response (io.restassured.response.Response)14 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)9 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)8 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)8 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)5 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)5 List (java.util.List)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)3