Search in sources :

Example 26 with Processor

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

the class ProcessorDAOTest method findProcessorsToBeDeployedOrDeleteWithConnectors.

@Test
@Transactional
public void findProcessorsToBeDeployedOrDeleteWithConnectors() {
    Bridge b = createBridge();
    // To be provisioned
    Processor withProvisionedConnectors = createProcessor(b, "withProvisionedConnectors");
    withProvisionedConnectors.setStatus(ManagedResourceStatus.PREPARING);
    withProvisionedConnectors.setDependencyStatus(ManagedResourceStatus.READY);
    processorDAO.getEntityManager().merge(withProvisionedConnectors);
    ConnectorEntity provisionedConnector = Fixtures.createSinkConnector(withProvisionedConnectors, ManagedResourceStatus.READY);
    provisionedConnector.setName("connectorProvisioned");
    processorDAO.getEntityManager().merge(provisionedConnector);
    // Not to be provisioned as Connector is not ready
    Processor nonProvisioned = createProcessor(b, "withUnprovisionedConnector");
    nonProvisioned.setStatus(ManagedResourceStatus.PREPARING);
    nonProvisioned.setDependencyStatus(ManagedResourceStatus.PROVISIONING);
    processorDAO.getEntityManager().merge(nonProvisioned);
    ConnectorEntity nonProvisionedConnector = Fixtures.createSinkConnector(nonProvisioned, ManagedResourceStatus.PROVISIONING);
    nonProvisionedConnector.setName("nonProvisionedConnector");
    processorDAO.getEntityManager().merge(nonProvisionedConnector);
    // Not to be de-provisioned as there's a connector yet to be deleted
    Processor toBeDeleted = createProcessor(b, "notToBeDeletedYet");
    toBeDeleted.setStatus(ManagedResourceStatus.DEPROVISION);
    toBeDeleted.setDependencyStatus(ManagedResourceStatus.DELETING);
    processorDAO.getEntityManager().merge(nonProvisioned);
    ConnectorEntity toBeDeletedConnector = Fixtures.createSinkConnector(toBeDeleted, ManagedResourceStatus.DELETING);
    toBeDeletedConnector.setName("toBeDeletedConnector");
    processorDAO.getEntityManager().merge(toBeDeletedConnector);
    List<Processor> processors = processorDAO.findByShardIdWithReadyDependencies(TestConstants.SHARD_ID);
    assertThat(processors.stream().map(Processor::getName)).contains("withProvisionedConnectors");
}
Also used : Processor(com.redhat.service.smartevents.manager.models.Processor) ConnectorEntity(com.redhat.service.smartevents.manager.models.ConnectorEntity) 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 27 with Processor

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

the class ProcessorDAOTest method createProcessor.

private Processor createProcessor(Bridge bridge, String name, ProcessorType type) {
    Processor p = new Processor();
    p.setType(type);
    p.setBridge(bridge);
    p.setName(name);
    p.setStatus(ManagedResourceStatus.ACCEPTED);
    p.setSubmittedAt(ZonedDateTime.now());
    p.setPublishedAt(ZonedDateTime.now());
    p.setShardId(TestConstants.SHARD_ID);
    p.setOwner(TestConstants.DEFAULT_USER_NAME);
    Action a = new Action();
    a.setType(KafkaTopicAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
    a.setMapParameters(params);
    ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), null, a);
    p.setDefinition(definition);
    processorDAO.persist(p);
    return p;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) Processor(com.redhat.service.smartevents.manager.models.Processor) HashMap(java.util.HashMap) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)

Example 28 with Processor

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

the class ProcessorDAOTest method findByIdBridgeIdAndCustomerId.

@Test
public void findByIdBridgeIdAndCustomerId() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor found = processorDAO.findByIdBridgeIdAndCustomerId(b.getId(), p.getId(), b.getCustomerId());
    assertThat(found).isNotNull();
    assertThat(found.getId()).isEqualTo(p.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 29 with Processor

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

the class ProcessorDAOTest method testGetProcessorsFilterByStatus.

@Test
@Transactional
void testGetProcessorsFilterByStatus() {
    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.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 30 with Processor

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

the class ProcessorDAOTest method testCountByBridgeIdAndCustomerId.

@Test
public void testCountByBridgeIdAndCustomerId() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor p1 = createProcessor(b, "bar");
    Long result = processorDAO.countByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(result).isEqualTo(2L);
}
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)

Aggregations

Processor (com.redhat.service.smartevents.manager.models.Processor)82 Bridge (com.redhat.service.smartevents.manager.models.Bridge)45 QuarkusTest (io.quarkus.test.junit.QuarkusTest)36 Test (org.junit.jupiter.api.Test)36 Transactional (javax.transaction.Transactional)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 Action (com.redhat.service.smartevents.infra.models.gateways.Action)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)9 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)8 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Work (com.redhat.service.smartevents.manager.models.Work)7 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)6 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)6 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)6 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)5 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)5 SlackAction (com.redhat.service.smartevents.processor.actions.slack.SlackAction)5