use of com.redhat.cloud.notifications.routers.internal.models.AddApplicationRequest in project notifications-backend by RedHatInsights.
the class LifecycleITest method createApp.
private String createApp(Header header, String bundleId) {
AddApplicationRequest request = new AddApplicationRequest();
request.bundleId = UUID.fromString(bundleId);
request.name = APP_NAME;
request.displayName = "The best app in the life";
String responseBody = given().when().basePath(API_INTERNAL).header(header).contentType(JSON).body(Json.encode(request)).post("/applications").then().statusCode(200).contentType(JSON).extract().body().asString();
JsonObject jsonApp = new JsonObject(responseBody);
jsonApp.mapTo(Application.class);
assertNotNull(jsonApp.getString("id"));
assertEquals(request.name, jsonApp.getString("name"));
assertEquals(request.displayName, jsonApp.getString("display_name"));
assertEquals(request.bundleId.toString(), jsonApp.getString("bundle_id"));
assertNotNull(jsonApp.getString("created"));
return jsonApp.getString("id");
}
use of com.redhat.cloud.notifications.routers.internal.models.AddApplicationRequest in project notifications-backend by RedHatInsights.
the class CrudTestHelpers method createApp.
public static Optional<String> createApp(Header identity, @Nullable Application app, @Nullable String ownerRole, int expectedStatusCode) {
AddApplicationRequest request = null;
if (app != null) {
request = new AddApplicationRequest();
request.bundleId = app.getBundleId();
request.displayName = app.getDisplayName();
request.name = app.getName();
request.ownerRole = ownerRole;
}
String responseBody = given().contentType(JSON).header(identity).body(Json.encode(request)).when().post("/internal/applications").then().statusCode(expectedStatusCode).contentType(familyOf(expectedStatusCode) == SUCCESSFUL ? is(JSON_UTF8) : any(String.class)).extract().asString();
if (familyOf(expectedStatusCode) == SUCCESSFUL) {
JsonObject jsonApp = new JsonObject(responseBody);
jsonApp.mapTo(Application.class);
assertNotNull(jsonApp.getString("id"));
assertNotNull(jsonApp.getString("created"));
assertEquals(app.getBundleId().toString(), jsonApp.getString("bundle_id"));
assertEquals(app.getName(), jsonApp.getString("name"));
assertEquals(app.getDisplayName(), jsonApp.getString("display_name"));
getApp(identity, jsonApp.getString("id"), app.getName(), app.getDisplayName(), OK);
return Optional.of(jsonApp.getString("id"));
} else {
return Optional.empty();
}
}
Aggregations