use of com.redhat.cloud.notifications.routers.internal.models.AddAccessRequest in project notifications-backend by RedHatInsights.
the class CrudTestHelpers method createInternalRoleAccess.
public static Optional<String> createInternalRoleAccess(Header identity, String role, String appId, int expected) {
AddAccessRequest request = new AddAccessRequest();
request.applicationId = UUID.fromString(appId);
request.role = role;
String responseBody = given().header(identity).when().contentType(JSON).body(request).post("internal/access").then().statusCode(expected).extract().asString();
if (familyOf(expected) == SUCCESSFUL) {
JsonObject jsonInternalRoleAccess = new JsonObject(responseBody);
jsonInternalRoleAccess.mapTo(InternalRoleAccess.class);
assertNotNull(jsonInternalRoleAccess.getString("id"));
assertEquals(appId, jsonInternalRoleAccess.getString("application_id"));
assertEquals(role, jsonInternalRoleAccess.getString("role"));
assertNull(jsonInternalRoleAccess.getString("internal_role"));
return Optional.of(jsonInternalRoleAccess.getString("id"));
}
return Optional.empty();
}
Aggregations