Search in sources :

Example 41 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class SendToBridgeActionTransformerTest method requestWithAction.

private ProcessorRequest requestWithAction(BaseAction action) {
    ProcessorRequest request = new ProcessorRequest();
    request.setName("testProcessor");
    request.setAction(action);
    return request;
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)

Example 42 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testDeleteProcessor.

@Test
public void testDeleteProcessor() {
    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);
    });
    processorService.deleteProcessor(b.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.DELETED);
        assertThat(p.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
        assertShardAsksForProcessorToBeDeletedIncludes(processor);
    });
}
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 43 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method createProcessor_bridgeNotActive.

@Test
public void createProcessor_bridgeNotActive() {
    Bridge b = createPersistBridge(ManagedResourceStatus.PROVISIONING);
    assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> processorService.createProcessor(b.getId(), b.getCustomerId(), new ProcessorRequest()));
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 44 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method getProcessor.

@Test
public void getProcessor() {
    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);
    });
    Processor found = processorService.getProcessor(processor.getId(), b.getId(), b.getCustomerId());
    assertThat(found).isNotNull();
    assertThat(found.getId()).isEqualTo(processor.getId());
    assertThat(found.getBridge().getId()).isEqualTo(b.getId());
    assertThat(found.getBridge().getCustomerId()).isEqualTo(b.getCustomerId());
}
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 45 with ProcessorRequest

use of com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method createConnectorFailureOnKafkaTopicCreation.

@Test
public void createConnectorFailureOnKafkaTopicCreation() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    BaseAction slackAction = createSlackAction();
    ProcessorRequest processorRequest = new ProcessorRequest("ManagedConnectorProcessor", slackAction);
    when(rhoasService.createTopicAndGrantAccessFor(anyString(), any())).thenThrow(new InternalPlatformException(createFailureErrorMessageFor("errorTopic"), new RuntimeException("error")));
    when(connectorsApiClient.createConnector(any(ConnectorRequest.class))).thenReturn(new Connector());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), processorRequest);
    waitForProcessorAndConnectorToFail(processor);
    verify(rhoasService, atLeast(1)).createTopicAndGrantAccessFor(anyString(), eq(RhoasTopicAccessType.PRODUCER));
    verify(connectorsApiClient, never()).createConnector(any(ConnectorRequest.class));
}
Also used : Connector(com.openshift.cloud.api.connector.models.Connector) ConnectorRequest(com.openshift.cloud.api.connector.models.ConnectorRequest) Processor(com.redhat.service.bridge.manager.models.Processor) InternalPlatformException(com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)48 QuarkusTest (io.quarkus.test.junit.QuarkusTest)46 Test (org.junit.jupiter.api.Test)46 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)22 TestSecurity (io.quarkus.test.security.TestSecurity)22 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)17 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)16 Bridge (com.redhat.service.bridge.manager.models.Bridge)15 Processor (com.redhat.service.bridge.manager.models.Processor)14 Response (io.restassured.response.Response)14 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)9 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)8 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)8 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)5 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)5 List (java.util.List)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)3