use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorGatewayConstraintValidatorTest method isValid_gatewayWithNullParametersIsNotValid.
@ParameterizedTest
@MethodSource("gateways")
void isValid_gatewayWithNullParametersIsNotValid(Gateway gateway) {
gateway.setParameters(null);
ProcessorRequest p = buildTestRequest(gateway);
assertThat(constraintValidator.isValid(p, validatorContextMock)).isFalse();
verifyGetValidatorCall(gateway, never(), ArgumentMatchers::anyString);
verifyIsValidCall(gateway, never());
verifyErrorMessage(GATEWAY_PARAMETERS_MISSING_ERROR, gateway, false);
}
use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceConnectorTest method createConnectorFailureOnExternalConnectorCreation.
@Test
void createConnectorFailureOnExternalConnectorCreation() {
Bridge b = createPersistBridge(READY);
Action slackAction = createSlackAction();
ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
doThrow(new InternalPlatformException(RhoasServiceImpl.createFailureErrorMessageFor("errorDeletingConnector"), new RuntimeException("error"))).when(connectorsApiClient).deleteConnector(anyString());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), b.getOwner(), processorRequest);
waitForProcessorAndConnectorToFail(processor);
}
use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceConnectorTest method createConnectorFailureOnKafkaTopicCreation.
@Test
void createConnectorFailureOnKafkaTopicCreation() {
Bridge b = createPersistBridge(READY);
Action slackAction = createSlackAction();
ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
when(rhoasService.createTopicAndGrantAccessFor(anyString(), any())).thenThrow(new InternalPlatformException(RhoasServiceImpl.createFailureErrorMessageFor("errorTopic"), new RuntimeException("error")));
when(connectorsApiClient.createConnector(any(ConnectorRequest.class))).thenReturn(new Connector());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), b.getOwner(), processorRequest);
waitForProcessorAndConnectorToFail(processor);
verify(rhoasService, atLeast(1)).createTopicAndGrantAccessFor(anyString(), eq(RhoasTopicAccessType.PRODUCER));
verify(connectorsApiClient, never()).createConnector(any(ConnectorRequest.class));
}
use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateErrorHandlerProcessorFails.
@Test
void testUpdateErrorHandlerProcessorFails() {
ProcessorRequest request = new ProcessorRequest(ERROR_HANDLER_PROCESSOR_NAME, TestUtils.createWebhookAction());
assertThatExceptionOfType(BadRequestException.class).isThrownBy(() -> processorService.updateProcessor(DEFAULT_BRIDGE_ID, ERROR_HANDLER_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request));
}
use of com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest 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);
}
Aggregations