Search in sources :

Example 1 with BridgeListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesAPITest method testGetBridgesFilterByNameAndStatus.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetBridgesFilterByNameAndStatus() {
    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(READY);
    bridgeDAO.persist(bridge2);
    BridgeListResponse bridgeListResponse = TestUtils.getBridgesFilterByNameAndStatus(DEFAULT_BRIDGE_NAME + "1", READY).as(BridgeListResponse.class);
    assertThat(bridgeListResponse.getItems().size()).isEqualTo(1);
    BridgeResponse bridgeResponse = bridgeListResponse.getItems().get(0);
    assertThat(bridgeResponse.getName()).isEqualTo(bridge1.getName());
    assertThat(bridgeResponse.getStatus()).isEqualTo(bridge1.getStatus());
    assertThat(bridgeResponse.getHref()).isEqualTo(USER_API_BASE_PATH + bridgeResponse.getId());
    assertThat(bridgeResponse.getSubmittedAt()).isNotNull();
    assertThat(bridgeResponse.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 2 with BridgeListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse 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 3 with BridgeListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeSteps method listOfBridgeInstancesIsContainingBridge.

@And("^the list of Bridge instances is containing the Bridge \"([^\"]*)\"$")
public void listOfBridgeInstancesIsContainingBridge(String testBridgeName) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    BridgeListResponse response = BridgeResource.getBridgeList(context.getManagerToken());
    assertThat(response.getItems()).anyMatch(b -> b.getId().equals(bridgeContext.getId()));
    BridgeResponse bridge = response.getItems().stream().filter(b -> b.getId().equals(bridgeContext.getId())).findFirst().orElseThrow();
    assertThat(bridge.getName()).isEqualTo(bridgeContext.getName());
}
Also used : BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) And(io.cucumber.java.en.And)

Example 4 with BridgeListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesAPITest method testCreateAndGetBridge.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testCreateAndGetBridge() {
    TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).then().statusCode(202);
    BridgeListResponse bridgeListResponse = TestUtils.getBridges().as(BridgeListResponse.class);
    assertThat(bridgeListResponse.getItems().size()).isEqualTo(1);
    BridgeResponse bridgeResponse = bridgeListResponse.getItems().get(0);
    assertThat(bridgeResponse.getName()).isEqualTo(DEFAULT_BRIDGE_NAME);
    assertThat(bridgeResponse.getStatus()).isEqualTo(ACCEPTED);
    assertThat(bridgeResponse.getHref()).isEqualTo(USER_API_BASE_PATH + bridgeResponse.getId());
    assertThat(bridgeResponse.getSubmittedAt()).isNotNull();
    assertThat(bridgeResponse.getEndpoint()).isNull();
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 5 with BridgeListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesAPITest method testGetEmptyBridges.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetEmptyBridges() {
    BridgeListResponse response = TestUtils.getBridges().as(BridgeListResponse.class);
    assertThat(response.getItems().size()).isZero();
}
Also used : BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BridgeListResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse)7 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)6 QuarkusTest (io.quarkus.test.junit.QuarkusTest)6 TestSecurity (io.quarkus.test.security.TestSecurity)6 Test (org.junit.jupiter.api.Test)6 Bridge (com.redhat.service.smartevents.manager.models.Bridge)4 BridgeContext (com.redhat.service.smartevents.integration.tests.context.BridgeContext)1 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)1 And (io.cucumber.java.en.And)1