Skip to content

Commit

Permalink
fix: Refactor message
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenzo-ingenito committed Apr 16, 2024
1 parent ae36074 commit 75f08f5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ public ResponseWifDTO delete(String idDoc, HttpServletRequest request) {
IniTraceResponseDTO iniResponse = iniClient.delete(deleteRequestDTO);

// Check mock errors
boolean iniMockMessage = !isNullOrEmpty(iniResponse.getErrorMessage()) && iniResponse.getErrorMessage().contains("Invalid region ip");
boolean iniMockMessage = !isNullOrEmpty(iniResponse.getMessage()) && iniResponse.getMessage().contains("Invalid region ip");
// Exit if necessary
if (iniMockMessage) {
throw new MockEnabledException(iniResponse.getErrorMessage(), edsResponse.getMessageError());
throw new MockEnabledException(iniResponse.getMessage(), edsResponse.getMessageError());
}

// Check response errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class IniTraceResponseDTO extends ResponseDTO {

private Boolean esito;

private String errorMessage;
private String message;

public IniTraceResponseDTO() {
super();
}

public IniTraceResponseDTO(final LogTraceInfoDTO traceInfo, final Boolean inEsito, final String inErrorMessage) {
public IniTraceResponseDTO(final LogTraceInfoDTO traceInfo, final Boolean inEsito, final String inMessage) {
super(traceInfo);
esito = inEsito;
errorMessage = inErrorMessage;
message = inMessage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void mockIniClient(final HttpStatus status, boolean esito) {
response.setSpanID(StringUtility.generateUUID());
response.setTraceID(StringUtility.generateUUID());
response.setEsito(true);
response.setErrorMessage(null);
response.setMessage(null);
referenceResponse.setSpanID(StringUtility.generateUUID());
referenceResponse.setTraceID(StringUtility.generateUUID());
referenceResponse.setErrorMessage(null);
Expand All @@ -147,7 +147,7 @@ void mockIniClient(final HttpStatus status, boolean esito) {
response.setSpanID(StringUtility.generateUUID());
response.setTraceID(StringUtility.generateUUID());
response.setEsito(false);
response.setErrorMessage("Generic error from INI");
response.setMessage("Generic error from INI");
Mockito.doReturn(new ResponseEntity<>(response, HttpStatus.OK)).when(restTemplate).exchange(anyString(), eq(HttpMethod.POST), any(HttpEntity.class), ArgumentMatchers.eq(IniReferenceResponseDTO.class));
Mockito.doReturn(new ResponseEntity<>(response, HttpStatus.OK)).when(restTemplate).exchange(anyString(), eq(HttpMethod.DELETE), any(HttpEntity.class), ArgumentMatchers.eq(IniTraceResponseDTO.class));
} else if (status.is4xxClientError()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void updateConnectionRefusedErrorTest() {
@DisplayName("Update - updateRecordGenericErrorTest")
void updateRecordGenericErrorTest() {
IniTraceResponseDTO responseMock = new IniTraceResponseDTO();
responseMock.setErrorMessage("Failed to update on INI");
responseMock.setMessage("Failed to update on INI");
Mockito.doReturn(new ResponseEntity<>(responseMock, HttpStatus.OK))
.when(restTemplate).exchange(anyString(), eq(HttpMethod.PUT), any(HttpEntity.class), ArgumentMatchers.eq(IniTraceResponseDTO.class));
assertEquals("Failed to update on INI", iniClient.update(requestBody).getErrorMessage());
assertEquals("Failed to update on INI", iniClient.update(requestBody).getMessage());
}

@Test
Expand Down Expand Up @@ -112,7 +112,7 @@ void updateRecordHttpErrorTest() {
responseMock.setEsito(true);
Mockito.doReturn(new ResponseEntity<>(responseMock, HttpStatus.BAD_GATEWAY)).when(restTemplate)
.exchange(anyString(), eq(HttpMethod.PUT), any(HttpEntity.class), eq(IniTraceResponseDTO.class));
assertNull(iniClient.update(requestBody).getErrorMessage());
assertNull(iniClient.update(requestBody).getMessage());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void mockIniClient(final HttpStatus status, boolean esito) {
response.setSpanID(StringUtility.generateUUID());
response.setTraceID(StringUtility.generateUUID());
response.setEsito(true);
response.setErrorMessage(null);
response.setMessage(null);
referenceResponse.setSpanID(StringUtility.generateUUID());
referenceResponse.setTraceID(StringUtility.generateUUID());
referenceResponse.setErrorMessage(null);
Expand All @@ -349,7 +349,7 @@ void mockIniClient(final HttpStatus status, boolean esito) {
response.setSpanID(StringUtility.generateUUID());
response.setTraceID(StringUtility.generateUUID());
response.setEsito(false);
response.setErrorMessage("Generic error from INI");
response.setMessage("Generic error from INI");
Mockito.doReturn(new ResponseEntity<>(response, HttpStatus.OK)).when(restTemplate).exchange(anyString(), eq(HttpMethod.POST), any(HttpEntity.class), ArgumentMatchers.eq(IniReferenceResponseDTO.class));
Mockito.doReturn(new ResponseEntity<>(response, HttpStatus.OK)).when(restTemplate).exchange(anyString(), eq(HttpMethod.DELETE), any(HttpEntity.class), ArgumentMatchers.eq(IniTraceResponseDTO.class));
Mockito.doReturn(new ResponseEntity<>(response, status)).when(restTemplate).exchange(anyString(), eq(HttpMethod.PUT), any(HttpEntity.class), ArgumentMatchers.eq(IniTraceResponseDTO.class));
Expand Down

0 comments on commit 75f08f5

Please sign in to comment.