use of com.redhat.service.bridge.manager.models.Processor 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.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method getProcessorByStatuses.
@Test
@Transactional
public void getProcessorByStatuses() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
final Processor processor1 = new Processor();
processor1.setName("My Processor");
processor1.setBridge(b);
processor1.setShardId(TestConstants.SHARD_ID);
processor1.setStatus(ManagedResourceStatus.ACCEPTED);
processor1.setDependencyStatus(ManagedResourceStatus.READY);
processor1.setSubmittedAt(ZonedDateTime.now());
processor1.setDefinition(new TextNode("definition"));
processorDAO.persist(processor1);
final Processor processor2 = new Processor();
processor2.setName("My Processor 2");
processor2.setBridge(b);
processor2.setShardId(TestConstants.SHARD_ID);
processor2.setStatus(ManagedResourceStatus.READY);
processor2.setDependencyStatus(ManagedResourceStatus.READY);
processor2.setSubmittedAt(ZonedDateTime.now());
processor2.setDefinition(new TextNode("definition"));
processorDAO.persist(processor2);
final Processor processor3 = new Processor();
processor3.setName("My Processor 3");
processor3.setBridge(b);
processor3.setShardId(TestConstants.SHARD_ID);
processor3.setStatus(ManagedResourceStatus.DEPROVISION);
processor3.setDependencyStatus(ManagedResourceStatus.DELETED);
processor3.setSubmittedAt(ZonedDateTime.now());
processor3.setDefinition(new TextNode("definition"));
processorDAO.persist(processor3);
List<Processor> processors = processorService.findByShardIdWithReadyDependencies(TestConstants.SHARD_ID);
assertThat(processors.size()).isEqualTo(2);
processors.forEach((px) -> assertThat(px.getName()).isIn("My Processor", "My Processor 3"));
}
use of com.redhat.service.bridge.manager.models.Processor 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);
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method waitForConnectorToBeDeleted.
private void waitForConnectorToBeDeleted(final Bridge bridge, final Processor processor) {
// There will be 2 re-tries at 5s each. Add 5s to be certain everything completes.
await().atMost(15, SECONDS).untilAsserted(() -> {
ConnectorEntity foundConnector = connectorsDAO.findByProcessorIdAndName(processor.getId(), "connectorToBeDeleted");
assertThat(foundConnector).isNull();
final Processor processorDeleted = processorService.getProcessor(processor.getId(), bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(processorDeleted.getStatus()).isEqualTo(DEPROVISION);
});
}
use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method reloadAssertProcessorIsInStatus.
private void reloadAssertProcessorIsInStatus(Processor processor, ManagedResourceStatus status) {
Processor foundProcessor = processorDAO.findById(processor.getId());
assertThat(foundProcessor.getStatus()).isEqualTo(status);
}
Aggregations