Search in sources :

Example 36 with Bridge

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

the class BridgesAPITest method testGetBridgesFilterByMultipleStatuses.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetBridgesFilterByMultipleStatuses() {
    Bridge bridge1 = Fixtures.createBridge();
    bridge1.setName(DEFAULT_BRIDGE_NAME + "1");
    bridge1.setStatus(READY);
    bridgeDAO.persist(bridge1);
    Bridge bridge2 = Fixtures.createBridge();
    bridge2.setName(DEFAULT_BRIDGE_NAME + "2");
    bridge2.setStatus(ACCEPTED);
    bridgeDAO.persist(bridge2);
    BridgeListResponse bridgeListResponse = TestUtils.getBridgesFilterByStatus(READY, ACCEPTED).as(BridgeListResponse.class);
    // The default sorting is by submission date descending; so Bridge2 will be first
    assertThat(bridgeListResponse.getItems().size()).isEqualTo(2);
    BridgeResponse bridgeResponse1 = bridgeListResponse.getItems().get(0);
    assertThat(bridgeResponse1.getName()).isEqualTo(bridge2.getName());
    assertThat(bridgeResponse1.getStatus()).isEqualTo(bridge2.getStatus());
    assertThat(bridgeResponse1.getHref()).isEqualTo(USER_API_BASE_PATH + bridgeResponse1.getId());
    assertThat(bridgeResponse1.getSubmittedAt()).isNotNull();
    assertThat(bridgeResponse1.getEndpoint()).isNotNull();
    BridgeResponse bridgeResponse2 = bridgeListResponse.getItems().get(1);
    assertThat(bridgeResponse2.getName()).isEqualTo(bridge1.getName());
    assertThat(bridgeResponse2.getStatus()).isEqualTo(bridge1.getStatus());
    assertThat(bridgeResponse2.getHref()).isEqualTo(USER_API_BASE_PATH + bridgeResponse2.getId());
    assertThat(bridgeResponse2.getSubmittedAt()).isNotNull();
    assertThat(bridgeResponse2.getEndpoint()).isNotNull();
}
Also used : BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Bridge(com.redhat.service.smartevents.manager.models.Bridge) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 37 with Bridge

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

the class BridgesAPITest method testDeleteBridge.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testDeleteBridge() {
    Bridge bridge = Fixtures.createBridge();
    bridge.setStatus(READY);
    bridgeDAO.persist(bridge);
    TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
    BridgeResponse response = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
    assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
}
Also used : BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Bridge(com.redhat.service.smartevents.manager.models.Bridge) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 38 with Bridge

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

the class ProcessorAPITest method updateProcessorWhenBridgeNotInReadyState.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWhenBridgeNotInReadyState() {
    Bridge bridge = Fixtures.createBridge();
    bridge.setStatus(ManagedResourceStatus.PROVISIONING);
    bridgeDAO.persist(bridge);
    Response response = TestUtils.updateProcessor(bridge.getId(), "anything", new ProcessorRequest("myProcessor", Collections.emptySet(), null, TestUtils.createKafkaAction()));
    assertThat(response.getStatusCode()).isEqualTo(400);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) TestSecurity(io.quarkus.test.security.TestSecurity) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 39 with Bridge

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

the class AbstractWorkerTest method workIsCompletedWhenTimedOut.

@Test
@Transactional
void workIsCompletedWhenTimedOut() {
    Bridge bridge = Fixtures.createBridge();
    // Persist Bridge so that it can be found by the Worker
    bridgeDAO.persist(bridge);
    Work work = workManager.schedule(bridge);
    assertThat(workManager.exists(work)).isTrue();
    work.setSubmittedAt(ZonedDateTime.now().minusSeconds(timeoutSeconds * 2L));
    worker.handleWork(work);
    assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.FAILED);
    assertThat(workManager.exists(work)).isFalse();
}
Also used : Work(com.redhat.service.smartevents.manager.models.Work) 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 40 with Bridge

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

the class AbstractWorkerTest method workIsCompletedWhenMaxRetriedExceeded.

@Test
@Transactional
void workIsCompletedWhenMaxRetriedExceeded() {
    Bridge bridge = Fixtures.createBridge();
    // Persist Bridge so that it can be found by the Worker
    bridgeDAO.persist(bridge);
    Work work = workManager.schedule(bridge);
    assertThat(workManager.exists(work)).isTrue();
    work.setAttempts(maxRetries + 1);
    worker.handleWork(work);
    assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.FAILED);
    assertThat(workManager.exists(work)).isFalse();
}
Also used : Work(com.redhat.service.smartevents.manager.models.Work) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Aggregations

Bridge (com.redhat.service.smartevents.manager.models.Bridge)99 QuarkusTest (io.quarkus.test.junit.QuarkusTest)68 Test (org.junit.jupiter.api.Test)68 Processor (com.redhat.service.smartevents.manager.models.Processor)45 Transactional (javax.transaction.Transactional)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 TestSecurity (io.quarkus.test.security.TestSecurity)14 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)13 Work (com.redhat.service.smartevents.manager.models.Work)13 QueryProcessorResourceInfo (com.redhat.service.smartevents.infra.models.QueryProcessorResourceInfo)12 QueryResourceInfo (com.redhat.service.smartevents.infra.models.QueryResourceInfo)11 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)11 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)10 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)9 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)8 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)8 Response (io.restassured.response.Response)8 Connector (com.openshift.cloud.api.connector.models.Connector)7 Action (com.redhat.service.smartevents.infra.models.gateways.Action)7 ConnectorEntity (com.redhat.service.smartevents.manager.models.ConnectorEntity)7