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());
}
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());
}
Aggregations