Skip to content

Commit

Permalink
AYS-555 | Refactored "ALREADY EXIST" errors to standardize as "CONFLI…
Browse files Browse the repository at this point in the history
…CT ERROR" (#417)
  • Loading branch information
gunesakkayaa authored Dec 21, 2024
1 parent f7f8445 commit d556f9a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ AysErrorResponse handleNotExistError(final AysNotExistException exception) {

@ExceptionHandler(AysConflictException.class)
@ResponseStatus(HttpStatus.CONFLICT)
AysErrorResponse handleAlreadyExistError(final AysConflictException exception) {
AysErrorResponse handleConflictError(final AysConflictException exception) {
log.error(exception.getMessage(), exception);

return AysErrorResponse.builder()
.header(AysErrorResponse.Header.ALREADY_EXIST.getName())
.header(AysErrorResponse.Header.CONFLICT_ERROR.getName())
.message(exception.getMessage())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public enum Header {
*/
API_ERROR("API ERROR"),
/**
* ALREADY_EXIST header.
* CONFLICT_ERROR header.
*/
ALREADY_EXIST("ALREADY EXIST"),
CONFLICT_ERROR("CONFLICT ERROR"),
/**
* NOT_FOUND header.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void givenValidAdminRegistrationApplicationId_whenApproveAdminRegistrationApplic
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.post(endpoint, superAdminToken.getAccessToken());

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down Expand Up @@ -555,7 +555,7 @@ void givenValidAdminRegistrationApplicationId_whenApproveAdminRegistrationApplic
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.post(endpoint, superAdminToken.getAccessToken());

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down Expand Up @@ -739,7 +739,7 @@ void givenValidAdminRegistrationApplicationRejectRequest_whenRejectAdminRegistra
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.post(endpoint, superAdminToken.getAccessToken(), rejectRequest);

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down Expand Up @@ -779,7 +779,7 @@ void givenValidAdminRegistrationApplicationRejectRequest_whenRejectAdminRegistra
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.post(endpoint, superAdminToken.getAccessToken(), rejectRequest);

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ void givenValidIdForPassivation_whenRoleUsing_thenReturnConflict() throws Except
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.patch(endpoint, mockSuperAdminToken.getAccessToken());

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down Expand Up @@ -986,7 +986,7 @@ void givenValidId_whenRoleAlreadyDeleted_thenReturnConflict() throws Exception {
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.delete(endpoint, mockAdminToken.getAccessToken());

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down Expand Up @@ -1014,7 +1014,7 @@ void givenValidId_whenRoleUsing_thenReturnConflict() throws Exception {
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = AysMockMvcRequestBuilders
.delete(endpoint, mockAdminToken.getAccessToken());

AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.ALREADY_EXIST;
AysErrorResponse mockErrorResponse = AysErrorResponseBuilder.CONFLICT_ERROR;

aysMockMvc.perform(mockHttpServletRequestBuilder, mockErrorResponse)
.andExpect(AysMockResultMatchersBuilders.status()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class AysErrorResponseBuilder {
.header(AysErrorResponse.Header.AUTH_ERROR.getName())
.isSuccess(false).build();

public static final AysErrorResponse ALREADY_EXIST = AysErrorResponse.builder()
.header(AysErrorResponse.Header.ALREADY_EXIST.getName())
public static final AysErrorResponse CONFLICT_ERROR = AysErrorResponse.builder()
.header(AysErrorResponse.Header.CONFLICT_ERROR.getName())
.isSuccess(false).build();

public static final AysErrorResponse NOT_FOUND = AysErrorResponse.builder()
Expand Down

0 comments on commit d556f9a

Please sign in to comment.