Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. @GetMapping("/homepage")
  2. public ResponseEntity getHomePageCollections(@RequestHeader(value = HEADER_APP_TOKEN) String headerAppToken) {
  3. CollectionObject homepageCollections = null;
  4. String errorMessage = null;
  5. HttpStatus httpStatus;
  6. try {
  7. homepageCollections = collectionService.getHomePageCollections();
  8. if (nonNull(homepageCollections)) {
  9. httpStatus = HttpStatus.OK;
  10. LOGGER.info("{} Response Status from CollectionController -- getHomePageCollections !! {}", TRANSACTION_SUCCESS_CODE, TRANSACTION_SUCCESS);
  11. } else {
  12. httpStatus = HttpStatus.NO_CONTENT;
  13. LOGGER.info("{} Response Status from CollectionController -- getHomePageCollections !! {}", NO_CONTENT_CODE, NO_CONTENT);
  14. }
  15. } // catch logic
  16. return ResponseEntity.status(httpStatus).contentType(MediaType.APPLICATION_JSON).body(httpStatus == HttpStatus.OK || httpStatus == HttpStatus.NO_CONTENT ? homepageCollections : errorMessage);
  17. }
  18.  
  19. @Test
  20. public void testGetHomePageCollection() {
  21. when(collectionService.getHomePageCollections()).thenReturn(null);
  22.  
  23. ResponseEntity responseEntity = collectionController.getHomePageCollections(HEADER_APP_TOKEN);
  24. assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement