use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method createConnectorSuccess.
@Test
void createConnectorSuccess() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
BaseAction 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);
// Emulate the connector not being found when first looked up, to force provisioning
when(connectorsApiClient.getConnector(any())).thenReturn(null, 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(), 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(), String.format("OpenBridge-slack_sink_0.1-%s", processor.getId()));
assertThat(connector).isNotNull();
assertThat(connector.getError()).isNullOrEmpty();
assertThat(connector.getStatus()).isEqualTo(ManagedResourceStatus.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.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testGetProcessorsCount.
@Test
public void testGetProcessorsCount() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
await().atMost(5, SECONDS).untilAsserted(() -> {
Processor p = processorDAO.findById(processor.getId());
assertThat(p).isNotNull();
assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
});
Long result = processorService.getProcessorsCount(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(result).isEqualTo(1L);
}
use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorStatusReadyPublishedAt.
@Test
public void testUpdateProcessorStatusReadyPublishedAt() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
processor.setStatus(ManagedResourceStatus.PROVISIONING);
processorService.updateProcessorStatus(processorService.toDTO(processor));
Processor retrievedProcessor = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
assertThat(retrievedProcessor.getStatus()).isEqualTo(ManagedResourceStatus.PROVISIONING);
assertThat(retrievedProcessor.getPublishedAt()).isNull();
// Once ready it should have its published date set
processor.setStatus(ManagedResourceStatus.READY);
processorService.updateProcessorStatus(processorService.toDTO(processor));
Processor publishedProcessor = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
assertThat(publishedProcessor.getStatus()).isEqualTo(ManagedResourceStatus.READY);
ZonedDateTime publishedAt = publishedProcessor.getPublishedAt();
assertThat(publishedAt).isNotNull();
// Check calls to set PublishedAt at idempotent
processorService.updateProcessorStatus(processorService.toDTO(processor));
Processor publishedProcessor2 = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
assertThat(publishedProcessor2.getStatus()).isEqualTo(ManagedResourceStatus.READY);
assertThat(publishedProcessor2.getPublishedAt()).isEqualTo(publishedAt);
}
Aggregations