Skip to content

Commit

Permalink
Feature/fix error message (#1050)
Browse files Browse the repository at this point in the history
* fix warning

* fix error message
  • Loading branch information
swaroopar committed Nov 17, 2023
1 parent c2d37bd commit 647a51a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private ServiceQueryModel getServiceQueryModel(Category category, Csp csp,
query.setServiceState(state);
}
Optional<String> userIdOptional = identityProviderManager.getCurrentLoginUserId();
if (!userIdOptional.isPresent()) {
if (userIdOptional.isEmpty()) {
throw new UserNotLoggedInException("Unable to get current login information");
}
query.setUserId(userIdOptional.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void deleteUserCloudCredential(

private String getUserId() {
Optional<String> userIdOptional = identityProviderManager.getCurrentLoginUserId();
if (!userIdOptional.isPresent()) {
if (userIdOptional.isEmpty()) {
throw new UserNotLoggedInException("Unable to get current login information");
}
return userIdOptional.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ private void checkIfPolicyIsDuplicate(Csp csp, String policy) {
List<PolicyEntity> policyEntityList = policyStorage.listPolicies(queryModel);
if (!CollectionUtils.isEmpty(policyEntityList)) {
String policyKey = policyEntityList.get(0).getId().toString();
String errMsg = String.format("The same policy already created by you for the Csp: %s."
+ " id: %s", csp, policyKey);
String errMsg = String.format("The same policy already exists for Csp: %s."
+ " with id: %s", csp, policyKey);
throw new PolicyDuplicateException(errMsg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ void testAddPolicy_ThrowsPolicyDuplicateException() throws Exception {

// Setup
mockPoliciesValidateRequest(true);
String errMsg = String.format("The same policy already created by you for the Csp: %s."
+ " id: %s", policyVo.getCsp(), policyVo.getId());
String errMsg = String.format("The same policy already exists for Csp: %s."
+ " with id: %s", policyVo.getCsp(), policyVo.getId());
Response result = Response.errorResponse(ResultType.POLICY_DUPLICATE, List.of(errMsg));
String exceptedResult = objectMapper.writeValueAsString(result);

Expand Down Expand Up @@ -331,8 +331,8 @@ void testUpdatePolicy() throws Exception {
void testUpdatePolicy_ThrowsPolicyDuplicateException() throws Exception {
// Setup
mockPoliciesValidateRequest(true);
String errMsg = String.format("The same policy already created by you for the Csp: %s."
+ " id: %s", openStackPolicyVo.getCsp(), openStackPolicyVo.getId());
String errMsg = String.format("The same policy already exists for Csp: %s."
+ " with id: %s", openStackPolicyVo.getCsp(), openStackPolicyVo.getId());
Response result = Response.errorResponse(ResultType.POLICY_DUPLICATE, List.of(errMsg));
String exceptedResult = objectMapper.writeValueAsString(result);

Expand Down

0 comments on commit 647a51a

Please sign in to comment.