Search in sources :

Example 91 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByIdBridgeIdAndCustomerId_doesNotExist.

@Test
public void findByIdBridgeIdAndCustomerId_doesNotExist() {
    Bridge b = createBridge();
    createProcessor(b, "foo");
    Processor found = processorDAO.findByIdBridgeIdAndCustomerId(b.getId(), "doesntExist", b.getCustomerId());
    assertThat(found).isNull();
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 92 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method testGetProcessorsFilterByStatusAndType.

@Test
@Transactional
void testGetProcessorsFilterByStatusAndType() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo", SOURCE);
    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.getStatus()).by(p.getType()).build()));
    assertThat(results.getPage()).isZero();
    assertThat(results.getSize()).isEqualTo(1L);
    assertThat(results.getTotal()).isEqualTo(1L);
    assertThat(results.getItems().get(0).getId()).isEqualTo(p.getId());
}
Also used : QueryProcessorResourceInfo(com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo) Processor(com.redhat.service.smartevents.manager.models.Processor) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 93 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method testGetProcessorsFilterByMoreStatuses.

@Test
@Transactional
public void testGetProcessorsFilterByMoreStatuses() {
    Bridge b = createBridge();
    Processor p1 = createProcessor(b, "foo");
    p1.setStatus(ACCEPTED);
    processorDAO.persist(p1);
    Processor p2 = createProcessor(b, "bar");
    p2.setStatus(READY);
    processorDAO.persist(p2);
    ListResult<Processor> results = processorDAO.findByBridgeIdAndCustomerId(b.getId(), b.getCustomerId(), new QueryProcessorResourceInfo(0, 100, filter().by(ACCEPTED).by(READY).build()));
    assertThat(results.getPage()).isZero();
    assertThat(results.getSize()).isEqualTo(2L);
    assertThat(results.getTotal()).isEqualTo(2L);
    assertThat(results.getItems().get(0).getId()).isEqualTo(p2.getId());
    assertThat(results.getItems().get(1).getId()).isEqualTo(p1.getId());
}
Also used : QueryProcessorResourceInfo(com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo) Processor(com.redhat.service.smartevents.manager.models.Processor) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 94 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByBridgeIdAndName.

@Test
public void findByBridgeIdAndName() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor byBridgeIdAndName = processorDAO.findByBridgeIdAndName(b.getId(), p.getName());
    assertThat(byBridgeIdAndName).isNotNull();
    assertThat(byBridgeIdAndName.getName()).isEqualTo(p.getName());
    assertThat(byBridgeIdAndName.getBridge().getId()).isEqualTo(b.getId());
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 95 with Bridge

use of com.redhat.service.smartevents.manager.models.Bridge 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);
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ManagedResourceStatus(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus) Tag(io.micrometer.core.instrument.Tag) Bridge(com.redhat.service.smartevents.manager.models.Bridge) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Bridge (com.redhat.service.smartevents.manager.models.Bridge)99 QuarkusTest (io.quarkus.test.junit.QuarkusTest)68 Test (org.junit.jupiter.api.Test)68 Processor (com.redhat.service.smartevents.manager.models.Processor)45 Transactional (javax.transaction.Transactional)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 TestSecurity (io.quarkus.test.security.TestSecurity)14 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)13 Work (com.redhat.service.smartevents.manager.models.Work)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 QueryResourceInfo (com.redhat.service.smartevents.infra.models.QueryResourceInfo)11 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)11 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)10 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)9 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)8 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)8 Response (io.restassured.response.Response)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Action (com.redhat.service.smartevents.infra.models.gateways.Action)7 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)7