Search in sources :

Example 6 with QueryProcessorResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo 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());
}
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 7 with QueryProcessorResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByBridgeIdAndCustomerId.

@Test
public void findByBridgeIdAndCustomerId() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor p1 = createProcessor(b, "bar");
    ListResult<Processor> listResult = processorDAO.findByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryProcessorResourceInfo(0, 100));
    assertThat(listResult.getPage()).isZero();
    assertThat(listResult.getSize()).isEqualTo(2L);
    assertThat(listResult.getTotal()).isEqualTo(2L);
    listResult.getItems().forEach((px) -> assertThat(px.getId()).isIn(p.getId(), 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)

Example 8 with QueryProcessorResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method testGetProcessorsFilterByNameWildcard.

@Test
public void testGetProcessorsFilterByNameWildcard() {
    Bridge b = createBridge();
    Processor p1 = createProcessor(b, "foo1");
    Processor p2 = createProcessor(b, "foo2");
    ListResult<Processor> results = processorDAO.findByBridgeIdAndCustomerId(b.getId(), b.getCustomerId(), new QueryProcessorResourceInfo(0, 100, filter().by("foo").build()));
    assertThat(results.getPage()).isZero();
    assertThat(results.getSize()).isEqualTo(2L);
    assertThat(results.getTotal()).isEqualTo(2L);
    // Newest instances come first
    assertThat(results.getItems().get(1).getId()).isEqualTo(p1.getId());
    assertThat(results.getItems().get(0).getId()).isEqualTo(p2.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)

Example 9 with QueryProcessorResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method testGetProcessorsFilterByType.

@Test
void testGetProcessorsFilterByType() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo", SOURCE);
    createProcessor(b, "bar");
    ListResult<Processor> results = processorDAO.findByBridgeIdAndCustomerId(b.getId(), b.getCustomerId(), new QueryProcessorResourceInfo(0, 100, filter().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)

Example 10 with QueryProcessorResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByBridgeIdAndCustomerId_pageOffset.

@Test
public void findByBridgeIdAndCustomerId_pageOffset() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor p1 = createProcessor(b, "bar");
    ListResult<Processor> listResult = processorDAO.findByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryProcessorResourceInfo(1, 1));
    assertThat(listResult.getPage()).isEqualTo(1L);
    assertThat(listResult.getSize()).isEqualTo(1L);
    assertThat(listResult.getTotal()).isEqualTo(2L);
    assertThat(listResult.getItems().get(0).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)

Aggregations

QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 Bridge (com.redhat.service.smartevents.manager.models.Bridge)12 Processor (com.redhat.service.smartevents.manager.models.Processor)12 QuarkusTest (io.quarkus.test.junit.QuarkusTest)12 Test (org.junit.jupiter.api.Test)12 Transactional (javax.transaction.Transactional)5