Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @GetMapping("/homepage")
- public ResponseEntity getHomePageCollections(@RequestHeader(value = HEADER_APP_TOKEN) String headerAppToken) {
- CollectionObject homepageCollections = null;
- String errorMessage = null;
- HttpStatus httpStatus;
- try {
- homepageCollections = collectionService.getHomePageCollections();
- if (nonNull(homepageCollections)) {
- httpStatus = HttpStatus.OK;
- LOGGER.info("{} Response Status from CollectionController -- getHomePageCollections !! {}", TRANSACTION_SUCCESS_CODE, TRANSACTION_SUCCESS);
- } else {
- httpStatus = HttpStatus.NO_CONTENT;
- LOGGER.info("{} Response Status from CollectionController -- getHomePageCollections !! {}", NO_CONTENT_CODE, NO_CONTENT);
- }
- } // catch logic
- return ResponseEntity.status(httpStatus).contentType(MediaType.APPLICATION_JSON).body(httpStatus == HttpStatus.OK || httpStatus == HttpStatus.NO_CONTENT ? homepageCollections : errorMessage);
- }
- @Test
- public void testGetHomePageCollection() {
- when(collectionService.getHomePageCollections()).thenReturn(null);
- ResponseEntity responseEntity = collectionController.getHomePageCollections(HEADER_APP_TOKEN);
- assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement