use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAOTest method testGetProcessorsFilterByNameAndStatus.
@Test
@Transactional
void testGetProcessorsFilterByNameAndStatus() {
Bridge b = createBridge();
Processor p = createProcessor(b, "foo");
createProcessor(b, "bar");
p.setStatus(READY);
processorDAO.persist(p);
ListResult<Processor> results = processorDAO.findByBridgeIdAndCustomerId(b.getId(), b.getCustomerId(), new QueryProcessorResourceInfo(0, 100, filter().by(p.getName()).by(p.getStatus()).build()));
assertThat(results.getPage()).isZero();
assertThat(results.getSize()).isEqualTo(1L);
assertThat(results.getTotal()).isEqualTo(1L);
assertThat(results.getItems().get(0).getId()).isEqualTo(p.getId());
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class MetricsServiceImplTest method onOperationComplete_forProcessor.
@ParameterizedTest
@EnumSource(MetricsOperation.class)
public void onOperationComplete_forProcessor(MetricsOperation metricsOperation) {
Bridge bridge = Fixtures.createBridge();
ManagedResourceStatus status = metricsOperation == MetricsOperation.DELETE ? ManagedResourceStatus.DELETED : ManagedResourceStatus.READY;
Processor processor = Fixtures.createProcessor(bridge, status);
processor.setSubmittedAt(ZonedDateTime.now().minusMinutes(4));
processor.setPublishedAt(ZonedDateTime.now().minusMinutes(3));
processor.setModifiedAt(ZonedDateTime.now().minusMinutes(2));
processor.setDeletionRequestedAt(ZonedDateTime.now().minusMinutes(1));
metricsService.onOperationComplete(processor, metricsOperation);
List<Tag> expectedTags = createdExpectedTags(processor, metricsOperation);
assertThat(meterRegistry.counter(operationTotalSuccessCountMetricName, expectedTags).count()).isEqualTo(1.0);
assertThat(meterRegistry.timer(operatonDurationMetricName, expectedTags).totalTime(TimeUnit.MINUTES)).isNotEqualTo(0);
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class Fixtures method createProcessor.
public static Processor createProcessor(Bridge b, ManagedResourceStatus status) {
Processor p = new Processor();
p.setType(ProcessorType.SINK);
p.setName(TestConstants.DEFAULT_PROCESSOR_NAME);
p.setStatus(status);
p.setPublishedAt(ZonedDateTime.now());
p.setSubmittedAt(ZonedDateTime.now());
p.setBridge(b);
p.setShardId(TestConstants.SHARD_ID);
p.setOwner(TestConstants.DEFAULT_USER_NAME);
p.setDefinition(new ProcessorDefinition());
return p;
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class TestUtils method waitForProcessorDependenciesToBeReady.
public static Processor waitForProcessorDependenciesToBeReady(ProcessorDAO processorDAO, Processor processor) {
final List<Processor> processors = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
processors.clear();
Processor p = processorDAO.findById(processor.getId());
assertThat(p).isNotNull();
assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
processors.add(p);
});
return processors.get(0);
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeWorkerTest method doTestProvisionworkWithKnownResourceAndErrorHandler.
private void doTestProvisionworkWithKnownResourceAndErrorHandler(ManagedResourceStatus status, ManagedResourceStatus dependencyStatusWhenComplete, boolean throwRhoasError, boolean isWorkComplete, boolean errorHandlerProcessorPresent) {
Bridge bridge = Fixtures.createBridge();
bridge.setId(TestConstants.DEFAULT_BRIDGE_ID);
bridge.setStatus(status);
bridge.setDefinition(new BridgeDefinition(createWebhookAction()));
bridgeDAO.persist(bridge);
Work work = workManager.schedule(bridge);
List<Processor> processors = errorHandlerProcessorPresent ? List.of(createErrorHandlerProcessor(bridge)) : Collections.emptyList();
when(processorServiceMock.getHiddenProcessors(TestConstants.DEFAULT_BRIDGE_ID, TestConstants.DEFAULT_CUSTOMER_ID)).thenReturn(new ListResult<>(processors, 0, processors.size()));
if (throwRhoasError) {
when(rhoasServiceMock.createTopicAndGrantAccessFor(any(), any())).thenThrow(new InternalPlatformException("error"));
}
Bridge refreshed = worker.handleWork(work);
verify(rhoasServiceMock).createTopicAndGrantAccessFor(TEST_TOPIC_NAME, RhoasTopicAccessType.CONSUMER_AND_PRODUCER);
verify(rhoasServiceMock, times(throwRhoasError ? 0 : 1)).createTopicAndGrantAccessFor(TEST_ERROR_HANDLER_TOPIC_NAME, RhoasTopicAccessType.CONSUMER_AND_PRODUCER);
verify(processorServiceMock, times(throwRhoasError || errorHandlerProcessorPresent ? 0 : 1)).createErrorHandlerProcessor(eq(bridge.getId()), eq(TestConstants.DEFAULT_CUSTOMER_ID), eq(TestConstants.DEFAULT_USER_NAME), any());
assertThat(refreshed.getDependencyStatus()).isEqualTo(dependencyStatusWhenComplete);
assertThat(workManager.exists(work)).isNotEqualTo(isWorkComplete);
}
Aggregations