Skip to content

Commit

Permalink
Parvathy | BAH-3703 | Add. Test Cases For Odoo Session Expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathy00 committed Mar 25, 2024
1 parent 68605d3 commit 54d2dab
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,28 @@ public void shouldThrowOdooRestExceptionWhenResponseIsEmpty() {
});
assertEquals("Response is empty", exception.getMessage());
}

@Test
public void shouldThrowOdooSessionExpiredExceptionWhenOdooSessionExpires() {
ResponseEntity<String> mockResponseEntity = mock(ResponseEntity.class);
when(mockResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
when(mockResponseEntity.getBody()).thenReturn("{\"error\":{\"message\":\"Error message\",\"code\":100}}");

OdooSessionExpiredException exception = assertThrows(OdooSessionExpiredException.class, () -> {
responseChecker.checkResponse(mockResponseEntity);
});
assertEquals("Odoo Session Expired", exception.getMessage());
}

@Test
public void shouldThrowOdooSessionExpiredExceptionWhenStatusIsForbidden() {
ResponseEntity<String> mockResponseEntity = mock(ResponseEntity.class);
when(mockResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
when(mockResponseEntity.getBody()).thenReturn("{\"error\":{\"message\":\"Error message\",\"status\":403}}");

OdooSessionExpiredException exception = assertThrows(OdooSessionExpiredException.class, () -> {
responseChecker.checkResponse(mockResponseEntity);
});
assertEquals("Odoo Session Expired", exception.getMessage());
}
}

0 comments on commit 54d2dab

Please sign in to comment.