Search in sources :

Example 31 with Processor

use of com.redhat.service.bridge.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.ACCEPTED);
    withProvisionedConnectors.setDependencyStatus(ManagedResourceStatus.READY);
    processorDAO.getEntityManager().merge(withProvisionedConnectors);
    ConnectorEntity provisionedConnector = Fixtures.createConnector(withProvisionedConnectors, "connectorProvisioned", ManagedResourceStatus.READY, "");
    processorDAO.getEntityManager().merge(provisionedConnector);
    // Not to be provisioned as Connector is not ready
    Processor nonProvisioned = createProcessor(b, "withUnprovisionedConnector");
    nonProvisioned.setStatus(ManagedResourceStatus.ACCEPTED);
    nonProvisioned.setDependencyStatus(ManagedResourceStatus.PROVISIONING);
    processorDAO.getEntityManager().merge(nonProvisioned);
    ConnectorEntity nonProvisionedConnector = Fixtures.createConnector(nonProvisioned, "nonProvisionedConnector", ManagedResourceStatus.READY, "");
    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.READY);
    processorDAO.getEntityManager().merge(nonProvisioned);
    ConnectorEntity toBeDeletedConnector = Fixtures.createConnector(toBeDeleted, "toBeDeletedConnector", ManagedResourceStatus.ACCEPTED, "");
    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.bridge.manager.models.Processor) ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 32 with Processor

use of com.redhat.service.bridge.manager.models.Processor 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 QueryInfo(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 : Processor(com.redhat.service.bridge.manager.models.Processor) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 33 with Processor

use of com.redhat.service.bridge.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.bridge.manager.models.Processor) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 34 with Processor

use of com.redhat.service.bridge.manager.models.Processor 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 QueryInfo(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 : Processor(com.redhat.service.bridge.manager.models.Processor) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 35 with Processor

use of com.redhat.service.bridge.manager.models.Processor 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("doesntExist", b.getId(), b.getCustomerId());
    assertThat(found).isNull();
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

Processor (com.redhat.service.bridge.manager.models.Processor)52 Bridge (com.redhat.service.bridge.manager.models.Bridge)34 QuarkusTest (io.quarkus.test.junit.QuarkusTest)32 Test (org.junit.jupiter.api.Test)32 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)14 ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)9 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)7 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)6 QueryInfo (com.redhat.service.bridge.infra.models.QueryInfo)6 Transactional (javax.transaction.Transactional)6 Connector (com.openshift.cloud.api.connector.models.Connector)5 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)5 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)4 InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)4 Work (com.redhat.service.bridge.manager.models.Work)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ZonedDateTime (java.time.ZonedDateTime)3 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2 AlreadyExistingItemException (com.redhat.service.bridge.infra.exceptions.definitions.user.AlreadyExistingItemException)2 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)2