diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java index 914083d0ca9..bfb0c87db0c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java @@ -103,6 +103,11 @@ public String createApplication(ApplicationModel application) throws IOException try (CloseableHttpResponse response = getResponseOfHttpPost(applicationManagementApiBasePath, jsonRequest, getHeaders())) { + + if (response.getStatusLine().getStatusCode() >= 400) { + String responseBody = EntityUtils.toString(response.getEntity()); + throw new RuntimeException("Error occurred while creating the application. Response: " + responseBody); + } String[] locationElements = response.getHeaders(LOCATION_HEADER)[0].toString().split(PATH_SEPARATOR); return locationElements[locationElements.length - 1]; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java index 4cd191ac59d..537b51842a2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/saml/RegistryMountTestCase.java @@ -285,7 +285,7 @@ private Tenant getRegistryMountTenantInfo() { return registryMountTenant; } - private void createApplication() throws Exception{ + private void createApplication() throws Exception { ApplicationModel applicationCreationModel = new ApplicationModel() .name(APPLICATION_NAME) @@ -294,7 +294,12 @@ private void createApplication() throws Exception{ .saml(getSAMLConfigurations())) .claimConfiguration(getClaimConfiguration()); - appId = applicationMgtRestClient.createApplication(applicationCreationModel); + try { + appId = applicationMgtRestClient.createApplication(applicationCreationModel); + } catch (RuntimeException e) { + log.error("Error while creating the application", e); + throw new Exception("Error while creating the application", e); + } } private void deleteApplication() throws Exception{