@Test @SuppressWarnings("unchecked") public void createDomainExceptionTest() throws Exception { byte[] domainDetailsContent = toJson(getDomainDetailsRequest()); when(domainService.createDomain(any(), any())).thenThrow(Exception.class); mockMvc.perform(post("/domains/create") .content(domainDetailsContent) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isExpectationFailed()) .andExpect(jsonPath("$.message", is(AdminConstants.UNEXPECTED_ERROR_OCCURRED))); }
@ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user, @ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails) { try { return ResponseUtils.buildSucessResponse(domainService.createDomain(createUpdateDomainDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }
DomainController { @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user, @ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails) { try { return ResponseUtils.buildSucessResponse(domainService.createDomain(createUpdateDomainDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } } }
DomainController { @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user, @ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails) { try { return ResponseUtils.buildSucessResponse(domainService.createDomain(createUpdateDomainDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  }
DomainController { @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user, @ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails) { try { return ResponseUtils.buildSucessResponse(domainService.createDomain(createUpdateDomainDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  @ApiOperation(httpMethod = "GET", value = "API to get all domains", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomains(); @ApiOperation(httpMethod = "GET", value = "API to get all domain details", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-details", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomainDetails(
		@ApiParam(value = "provide valid page number", required = true) @RequestParam("page") Integer page,
		@ApiParam(value = "provide valid page size", required = true) @RequestParam("size") Integer size,
		@ApiParam(value = "provide valid search term", required = false) @RequestParam(defaultValue="", name = "searchTerm", required = false) String searchTerm); @ApiOperation(httpMethod = "GET", value = "API to get domain details by name", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-domain-name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDomainByName(
		@ApiParam(value = "provide valid domain name", required = true) @RequestParam(name = "domainName", required = true) String domainName); @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user,
			@ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails); @ApiOperation(httpMethod = "POST", value = "API to update domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/update", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updateDomain(@AuthenticationPrincipal Principal user,
			@ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails); @ApiOperation(httpMethod = "GET", value = "API to get all domain names", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/domain-names", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomainNames(); }
DomainController { @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user, @ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails) { try { return ResponseUtils.buildSucessResponse(domainService.createDomain(createUpdateDomainDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  @ApiOperation(httpMethod = "GET", value = "API to get all domains", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomains(); @ApiOperation(httpMethod = "GET", value = "API to get all domain details", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-details", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomainDetails(
		@ApiParam(value = "provide valid page number", required = true) @RequestParam("page") Integer page,
		@ApiParam(value = "provide valid page size", required = true) @RequestParam("size") Integer size,
		@ApiParam(value = "provide valid search term", required = false) @RequestParam(defaultValue="", name = "searchTerm", required = false) String searchTerm); @ApiOperation(httpMethod = "GET", value = "API to get domain details by name", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-domain-name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDomainByName(
		@ApiParam(value = "provide valid domain name", required = true) @RequestParam(name = "domainName", required = true) String domainName); @ApiOperation(httpMethod = "POST", value = "API to create new domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createDomain(@AuthenticationPrincipal Principal user,
			@ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails); @ApiOperation(httpMethod = "POST", value = "API to update domain", response = Response.class, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/update", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updateDomain(@AuthenticationPrincipal Principal user,
			@ApiParam(value = "provide valid domain details", required = true) @RequestBody(required = true) CreateUpdateDomain createUpdateDomainDetails); @ApiOperation(httpMethod = "GET", value = "API to get all domain names", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/domain-names", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllDomainNames();  }