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");
}
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;
}
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());
}
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());
}
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);
}
Aggregations