Search in sources :

Example 46 with Processor

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

the class ProcessorServiceTest method testGetProcessorsCount.

@Test
public void testGetProcessorsCount() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    Long result = processorService.getProcessorsCount(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(result).isEqualTo(1L);
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 47 with Processor

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

the class ProcessorServiceTest method getProcessorByStatuses.

@Test
@Transactional
public void getProcessorByStatuses() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    final Processor processor1 = new Processor();
    processor1.setName("My Processor");
    processor1.setBridge(b);
    processor1.setShardId(TestConstants.SHARD_ID);
    processor1.setStatus(ManagedResourceStatus.ACCEPTED);
    processor1.setDependencyStatus(ManagedResourceStatus.READY);
    processor1.setSubmittedAt(ZonedDateTime.now());
    processor1.setDefinition(new TextNode("definition"));
    processorDAO.persist(processor1);
    final Processor processor2 = new Processor();
    processor2.setName("My Processor 2");
    processor2.setBridge(b);
    processor2.setShardId(TestConstants.SHARD_ID);
    processor2.setStatus(ManagedResourceStatus.READY);
    processor2.setDependencyStatus(ManagedResourceStatus.READY);
    processor2.setSubmittedAt(ZonedDateTime.now());
    processor2.setDefinition(new TextNode("definition"));
    processorDAO.persist(processor2);
    final Processor processor3 = new Processor();
    processor3.setName("My Processor 3");
    processor3.setBridge(b);
    processor3.setShardId(TestConstants.SHARD_ID);
    processor3.setStatus(ManagedResourceStatus.DEPROVISION);
    processor3.setDependencyStatus(ManagedResourceStatus.DELETED);
    processor3.setSubmittedAt(ZonedDateTime.now());
    processor3.setDefinition(new TextNode("definition"));
    processorDAO.persist(processor3);
    List<Processor> processors = processorService.findByShardIdWithReadyDependencies(TestConstants.SHARD_ID);
    assertThat(processors.size()).isEqualTo(2);
    processors.forEach((px) -> assertThat(px.getName()).isIn("My Processor", "My Processor 3"));
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) TextNode(com.fasterxml.jackson.databind.node.TextNode) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Transactional(javax.transaction.Transactional)

Example 48 with Processor

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

the class ProcessorServiceTest method testUpdateProcessorStatusReadyPublishedAt.

@Test
public void testUpdateProcessorStatusReadyPublishedAt() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    processor.setStatus(ManagedResourceStatus.PROVISIONING);
    processorService.updateProcessorStatus(processorService.toDTO(processor));
    Processor retrievedProcessor = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
    assertThat(retrievedProcessor.getStatus()).isEqualTo(ManagedResourceStatus.PROVISIONING);
    assertThat(retrievedProcessor.getPublishedAt()).isNull();
    // Once ready it should have its published date set
    processor.setStatus(ManagedResourceStatus.READY);
    processorService.updateProcessorStatus(processorService.toDTO(processor));
    Processor publishedProcessor = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
    assertThat(publishedProcessor.getStatus()).isEqualTo(ManagedResourceStatus.READY);
    ZonedDateTime publishedAt = publishedProcessor.getPublishedAt();
    assertThat(publishedAt).isNotNull();
    // Check calls to set PublishedAt at idempotent
    processorService.updateProcessorStatus(processorService.toDTO(processor));
    Processor publishedProcessor2 = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
    assertThat(publishedProcessor2.getStatus()).isEqualTo(ManagedResourceStatus.READY);
    assertThat(publishedProcessor2.getPublishedAt()).isEqualTo(publishedAt);
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ZonedDateTime(java.time.ZonedDateTime) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 49 with Processor

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

the class ProcessorServiceTest method waitForConnectorToBeDeleted.

private void waitForConnectorToBeDeleted(final Bridge bridge, final Processor processor) {
    // There will be 2 re-tries at 5s each. Add 5s to be certain everything completes.
    await().atMost(15, SECONDS).untilAsserted(() -> {
        ConnectorEntity foundConnector = connectorsDAO.findByProcessorIdAndName(processor.getId(), "connectorToBeDeleted");
        assertThat(foundConnector).isNull();
        final Processor processorDeleted = processorService.getProcessor(processor.getId(), bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
        assertThat(processorDeleted.getStatus()).isEqualTo(DEPROVISION);
    });
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ConnectorEntity(com.redhat.service.bridge.manager.models.ConnectorEntity)

Example 50 with Processor

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

the class ProcessorServiceTest method reloadAssertProcessorIsInStatus.

private void reloadAssertProcessorIsInStatus(Processor processor, ManagedResourceStatus status) {
    Processor foundProcessor = processorDAO.findById(processor.getId());
    assertThat(foundProcessor.getStatus()).isEqualTo(status);
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor)

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