use of com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus 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.infra.models.dto.ManagedResourceStatus in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAO method getProcessorIds.
private ProcessorResults getProcessorIds(String customerId, String bridgeId, QueryProcessorResourceInfo queryInfo, Set<ProcessorType> restrictTypes) {
Parameters parameters = Parameters.with("customerId", customerId).and("bridgeId", bridgeId);
PanacheQuery<Processor> query = find("#PROCESSOR.findByBridgeIdAndCustomerIdNoFilter", parameters);
// filter by name
String filterName = queryInfo.getFilterInfo().getFilterName();
if (Objects.nonNull(filterName)) {
query.filter("byName", Parameters.with("name", filterName + "%"));
}
// filter by status
Set<ManagedResourceStatus> filterStatus = queryInfo.getFilterInfo().getFilterStatus();
if (Objects.nonNull(filterStatus) && !filterStatus.isEmpty()) {
query.filter("byStatus", Parameters.with("status", filterStatus));
}
// filter by type, considering onlyUserVisible flag
ProcessorType filterType = queryInfo.getFilterInfo().getFilterType();
if (restrictTypes != null) {
if (Objects.isNull(filterType)) {
query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, restrictTypes));
} else {
if (restrictTypes.contains(filterType)) {
query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, Set.of(filterType)));
} else {
return new ProcessorResults(emptyList(), 0);
}
}
} else {
if (Objects.nonNull(filterType)) {
query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, Set.of(filterType)));
}
}
long total = query.count();
List<Processor> processors = query.page(queryInfo.getPageNumber(), queryInfo.getPageSize()).list();
List<String> ids = processors.stream().map(Processor::getId).collect(Collectors.toList());
return new ProcessorResults(ids, total);
}
use of com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAO method findByCustomerId.
public ListResult<Bridge> findByCustomerId(String customerId, QueryResourceInfo queryInfo) {
Parameters parameters = Parameters.with("customerId", customerId);
PanacheQuery<Bridge> query = find("#BRIDGE.findByCustomerId", parameters);
String filterName = queryInfo.getFilterInfo().getFilterName();
Set<ManagedResourceStatus> filterStatus = queryInfo.getFilterInfo().getFilterStatus();
if (Objects.nonNull(filterName)) {
query.filter("byName", Parameters.with("name", filterName + "%"));
}
if (Objects.nonNull(filterStatus) && !filterStatus.isEmpty()) {
query.filter("byStatus", Parameters.with("status", filterStatus));
}
long total = query.count();
List<Bridge> bridges = query.page(queryInfo.getPageNumber(), queryInfo.getPageSize()).list();
return new ListResult<>(bridges, queryInfo.getPageNumber(), total);
}
use of com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class MetricsServiceImplTest method onOperationStart_forProcessor.
@ParameterizedTest
@EnumSource(MetricsOperation.class)
public void onOperationStart_forProcessor(MetricsOperation metricsOperation) {
Bridge bridge = Fixtures.createBridge();
ManagedResourceStatus status = metricsOperation == MetricsOperation.DELETE ? ManagedResourceStatus.DEPROVISION : ManagedResourceStatus.ACCEPTED;
Processor processor = Fixtures.createProcessor(bridge, status);
metricsService.onOperationStart(processor, metricsOperation);
List<Tag> expectedTags = createdExpectedTags(processor, metricsOperation);
assertThat(meterRegistry.counter(operationTotalCountMetricName, expectedTags).count()).isEqualTo(1.0);
}
use of com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class MetricsServiceImplTest method onOperationComplete_forBridge.
@ParameterizedTest
@EnumSource(MetricsOperation.class)
public void onOperationComplete_forBridge(MetricsOperation metricsOperation) {
Bridge bridge = Fixtures.createBridge();
ManagedResourceStatus status = metricsOperation == MetricsOperation.DELETE ? ManagedResourceStatus.DELETED : ManagedResourceStatus.READY;
bridge.setSubmittedAt(ZonedDateTime.now().minusMinutes(4));
bridge.setPublishedAt(ZonedDateTime.now().minusMinutes(3));
bridge.setModifiedAt(ZonedDateTime.now().minusMinutes(3));
bridge.setDeletionRequestedAt(ZonedDateTime.now().minusMinutes(1));
bridge.setStatus(status);
metricsService.onOperationComplete(bridge, metricsOperation);
List<Tag> expectedTags = createdExpectedTags(bridge, metricsOperation);
assertThat(meterRegistry.counter(operationTotalSuccessCountMetricName, expectedTags).count()).isEqualTo(1.0);
assertThat(meterRegistry.timer(operatonDurationMetricName, expectedTags).totalTime(TimeUnit.MINUTES)).isNotEqualTo(0);
}
Aggregations