use of com.redhat.cloud.notifications.MockServerConfig.RbacAccess.READ_ACCESS in project notifications-backend by RedHatInsights.
the class NotificationResourceTest method testGetBundlesFacets.
@Test
void testGetBundlesFacets() {
// no children by default
Header identityHeader = initRbacMock("test", "test2", "user", READ_ACCESS);
List<Facet> bundles = given().header(identityHeader).when().contentType(JSON).get("/notifications/facets/bundles").then().statusCode(200).contentType(JSON).extract().response().jsonPath().getList(".", Facet.class);
assertTrue(bundles.size() > 0);
Optional<Facet> rhel = bundles.stream().filter(facet -> facet.getName().equals("rhel")).findFirst();
assertTrue(rhel.isPresent());
assertEquals("Red Hat Enterprise Linux", rhel.get().getDisplayName());
assertNull(rhel.get().getChildren());
// with children
bundles = given().header(identityHeader).when().contentType(JSON).queryParam("includeApplications", "true").get("/notifications/facets/bundles").then().statusCode(200).contentType(JSON).extract().response().jsonPath().getList(".", Facet.class);
assertTrue(bundles.size() > 0);
rhel = bundles.stream().filter(facet -> facet.getName().equals("rhel")).findFirst();
assertTrue(rhel.isPresent());
assertEquals("Red Hat Enterprise Linux", rhel.get().getDisplayName());
assertNotNull(rhel.get().getChildren());
Optional<Facet> policies = rhel.get().getChildren().stream().filter(facet -> facet.getName().equals("policies")).findFirst();
assertTrue(policies.isPresent());
assertEquals("Policies", policies.get().getDisplayName());
}
use of com.redhat.cloud.notifications.MockServerConfig.RbacAccess.READ_ACCESS in project notifications-backend by RedHatInsights.
the class NotificationResourceTest method testGetApplicationFacets.
@Test
void testGetApplicationFacets() {
Header identityHeader = initRbacMock("test", "test2", "user", READ_ACCESS);
List<Facet> applications = given().header(identityHeader).when().get("/notifications/facets/applications?bundleName=rhel").then().statusCode(200).contentType(JSON).extract().response().jsonPath().getList(".", Facet.class);
assertTrue(applications.size() > 0);
Optional<Facet> policies = applications.stream().filter(facet -> facet.getName().equals("policies")).findFirst();
assertTrue(policies.isPresent());
assertEquals("Policies", policies.get().getDisplayName());
// Without bundle returns all applications across bundles
applications = given().header(identityHeader).when().get("/notifications/facets/applications").then().statusCode(200).contentType(JSON).extract().response().jsonPath().getList(".", Facet.class);
assertTrue(applications.size() > 0);
policies = applications.stream().filter(facet -> facet.getName().equals("policies")).findFirst();
assertTrue(policies.isPresent());
assertEquals("Policies", policies.get().getDisplayName());
}
Aggregations