Search in sources :

Example 31 with Application

use of com.redhat.cloud.notifications.models.Application in project notifications-backend by RedHatInsights.

the class NotificationResourceTest method testEventTypeFetchingByBundleApplicationAndEventTypeName.

@Test
void testEventTypeFetchingByBundleApplicationAndEventTypeName() {
    helpers.createTestAppAndEventTypes();
    List<Application> apps = applicationRepository.getApplications(TEST_BUNDLE_NAME);
    Application app = apps.stream().filter(a -> a.getName().equals(TEST_APP_NAME_2)).findFirst().get();
    UUID myOtherTesterApplicationId = app.getId();
    UUID myBundleId = app.getBundleId();
    Header identityHeader = initRbacMock(TENANT, ORG_ID, USERNAME, RbacAccess.FULL_ACCESS);
    Response response = given().when().header(identityHeader).queryParam("bundleId", myBundleId).queryParam("applicationIds", myOtherTesterApplicationId).queryParam("eventTypeName", "50").get("/notifications/eventTypes").then().statusCode(200).contentType(JSON).extract().response();
    JsonObject page = new JsonObject(response.getBody().asString());
    JsonArray eventTypes = page.getJsonArray("data");
    for (int i = 0; i < eventTypes.size(); i++) {
        JsonObject ev = eventTypes.getJsonObject(i);
        ev.mapTo(EventType.class);
        assertEquals(myBundleId.toString(), ev.getJsonObject("application").getString("bundle_id"));
        assertEquals(myOtherTesterApplicationId.toString(), ev.getJsonObject("application").getString("id"));
        assertTrue(ev.getString("display_name").contains("50") || ev.getString("name").contains("50"));
    }
    assertEquals(1, page.getJsonObject("meta").getInteger("count"));
    assertEquals(1, eventTypes.size());
}
Also used : Response(io.restassured.response.Response) JsonArray(io.vertx.core.json.JsonArray) Header(io.restassured.http.Header) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) Application(com.redhat.cloud.notifications.models.Application) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Example 32 with Application

use of com.redhat.cloud.notifications.models.Application in project notifications-backend by RedHatInsights.

the class NotificationResourceTest method testEventTypeFetchingByBundleAndApplicationId.

@Test
void testEventTypeFetchingByBundleAndApplicationId() {
    helpers.createTestAppAndEventTypes();
    List<Application> apps = applicationRepository.getApplications(TEST_BUNDLE_NAME);
    Application app = apps.stream().filter(a -> a.getName().equals(TEST_APP_NAME_2)).findFirst().get();
    UUID myOtherTesterApplicationId = app.getId();
    UUID myBundleId = app.getBundleId();
    Header identityHeader = initRbacMock(TENANT, ORG_ID, USERNAME, RbacAccess.FULL_ACCESS);
    Response response = given().when().header(identityHeader).queryParam("bundleId", myBundleId).queryParam("applicationIds", myOtherTesterApplicationId).get("/notifications/eventTypes").then().statusCode(200).contentType(JSON).extract().response();
    JsonObject page = new JsonObject(response.getBody().asString());
    JsonArray eventTypes = page.getJsonArray("data");
    for (int i = 0; i < eventTypes.size(); i++) {
        JsonObject ev = eventTypes.getJsonObject(i);
        ev.mapTo(EventType.class);
        assertEquals(myBundleId.toString(), ev.getJsonObject("application").getString("bundle_id"));
        assertEquals(myOtherTesterApplicationId.toString(), ev.getJsonObject("application").getString("id"));
    }
    assertEquals(100, page.getJsonObject("meta").getInteger("count"));
    assertEquals(20, eventTypes.size());
}
Also used : Response(io.restassured.response.Response) JsonArray(io.vertx.core.json.JsonArray) Header(io.restassured.http.Header) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) Application(com.redhat.cloud.notifications.models.Application) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

Application (com.redhat.cloud.notifications.models.Application)32 Bundle (com.redhat.cloud.notifications.models.Bundle)15 EventType (com.redhat.cloud.notifications.models.EventType)14 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 Transactional (javax.transaction.Transactional)11 Test (org.junit.jupiter.api.Test)11 DbIsolatedTest (com.redhat.cloud.notifications.db.DbIsolatedTest)9 BehaviorGroup (com.redhat.cloud.notifications.models.BehaviorGroup)7 Header (io.restassured.http.Header)5 Response (io.restassured.response.Response)4 JsonArray (io.vertx.core.json.JsonArray)4 JsonObject (io.vertx.core.json.JsonObject)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 RhIdPrincipal (com.redhat.cloud.notifications.auth.principal.rhid.RhIdPrincipal)3 ApplicationRepository (com.redhat.cloud.notifications.db.repositories.ApplicationRepository)3 EmailSubscription (com.redhat.cloud.notifications.models.EmailSubscription)3 Endpoint (com.redhat.cloud.notifications.models.Endpoint)3 List (java.util.List)3 UUID (java.util.UUID)3