use of com.redhat.service.smartevents.processor.actions.slack.SlackAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceConnectorTest method createConnectorSuccess.
@Test
void createConnectorSuccess() {
Bridge b = createPersistBridge(READY);
Action slackAction = createSlackAction();
ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
// Emulate successful External Connector creation
Connector externalConnector = stubbedExternalConnector("connectorExternalId");
ConnectorStatusStatus externalConnectorStatus = new ConnectorStatusStatus();
externalConnectorStatus.setState(ConnectorState.READY);
externalConnector.setStatus(externalConnectorStatus);
when(connectorsApiClient.getConnector(any())).thenReturn(externalConnector);
when(connectorsApiClient.createConnector(any(ConnectorEntity.class))).thenCallRealMethod();
when(connectorsApiClient.createConnector(any(ConnectorRequest.class))).thenReturn(externalConnector);
when(rhoasService.createTopicAndGrantAccessFor(anyString(), any())).thenReturn(new Topic());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), b.getOwner(), processorRequest);
// There will be 2 re-tries at 5s each. Add 5s to be certain everything completes.
await().atMost(15, SECONDS).untilAsserted(() -> {
ConnectorEntity connector = connectorsDAO.findByProcessorIdAndName(processor.getId(), resourceNamesProvider.getProcessorConnectorName(processor.getId()));
assertThat(connector).isNotNull();
assertThat(connector.getError()).isNullOrEmpty();
assertThat(connector.getStatus()).isEqualTo(READY);
});
verify(rhoasService, atLeast(1)).createTopicAndGrantAccessFor(anyString(), eq(RhoasTopicAccessType.PRODUCER));
ArgumentCaptor<ConnectorRequest> connectorCaptor = ArgumentCaptor.forClass(ConnectorRequest.class);
verify(connectorsApiClient).createConnector(connectorCaptor.capture());
ConnectorRequest calledConnector = connectorCaptor.getValue();
assertThat(calledConnector.getKafka()).isNotNull();
}
use of com.redhat.service.smartevents.processor.actions.slack.SlackAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsServiceTest method slackAction.
private static Action slackAction() {
Action action = new Action();
action.setType(SlackAction.TYPE);
action.setMapParameters(Map.of(SlackAction.CHANNEL_PARAM, TEST_ACTION_CHANNEL, SlackAction.WEBHOOK_URL_PARAM, TEST_ACTION_WEBHOOK));
return action;
}
use of com.redhat.service.smartevents.processor.actions.slack.SlackAction 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.processor.actions.slack.SlackAction 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));
}
Aggregations