@Test @SuppressWarnings("unchecked") public void createAssetGroupDetailsExceptionTest() throws Exception { byte[] assetGroupDetailsContent = toJson(getCreateUpdateAssetGroupDetailsRequest()); when(assetGroupService.createAssetGroupDetails(any(), any())).thenThrow(Exception.class); mockMvc.perform(post("/asset-group/create").principal(principal) .content(assetGroupDetailsContent) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isExpectationFailed()) .andExpect(jsonPath("$.message", is(UNEXPECTED_ERROR_OCCURRED))); }
@ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user, @RequestBody CreateUpdateAssetGroupDetails assetGroupDetails) { try { return ResponseUtils .buildSucessResponse(assetGroupService.createAssetGroupDetails(assetGroupDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }
AssetGroupController { @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user, @RequestBody CreateUpdateAssetGroupDetails assetGroupDetails) { try { return ResponseUtils .buildSucessResponse(assetGroupService.createAssetGroupDetails(assetGroupDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } } }
AssetGroupController { @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user, @RequestBody CreateUpdateAssetGroupDetails assetGroupDetails) { try { return ResponseUtils .buildSucessResponse(assetGroupService.createAssetGroupDetails(assetGroupDetails, user.getName())); } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage()); } }  }
AssetGroupController { @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user, @RequestBody CreateUpdateAssetGroupDetails assetGroupDetails) { try { return ResponseUtils .buildSucessResponse(assetGroupService.createAssetGroupDetails(assetGroupDetails, 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 asset group names", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-names", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllAssetGroupNames(); @ApiOperation(httpMethod = "POST", value = "API to update new asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updateAssetGroupDetails(@AuthenticationPrincipal Principal user,
			@RequestBody CreateUpdateAssetGroupDetails assetGroupDetails); @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user,
			@RequestBody CreateUpdateAssetGroupDetails assetGroupDetails); @ApiOperation(httpMethod = "GET", value = "API to get all asset group details", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllAssetGroupDetails(
			@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 all asset group details by id and datasource", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-id-and-datasource", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAssetGroupDetailsByNameAndDataSource(
			@ApiParam(value = "provide valid id", required = true) @RequestParam(defaultValue = "", name = "assetGroupId", required = true) String assetGroupId,
			@ApiParam(value = "provide valid datasource", required = true) @RequestParam(defaultValue = "", name = "dataSource", required = true) String dataSource); @ApiOperation(httpMethod = "GET", value = "API to get asset group details by name", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> findByGroupName(
			@ApiParam(value = "provide valid name", required = true) @RequestParam(defaultValue = "", name = "assetGroupName", required = true) String assetGroupName); @ApiOperation(httpMethod = "POST", value = "API to delete asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> deleteAssetGroup(@AuthenticationPrincipal Principal user,
			@RequestBody DeleteAssetGroupRequest assetGroupDetails); }
AssetGroupController { @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user, @RequestBody CreateUpdateAssetGroupDetails assetGroupDetails) { try { return ResponseUtils .buildSucessResponse(assetGroupService.createAssetGroupDetails(assetGroupDetails, 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 asset group names", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-names", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllAssetGroupNames(); @ApiOperation(httpMethod = "POST", value = "API to update new asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> updateAssetGroupDetails(@AuthenticationPrincipal Principal user,
			@RequestBody CreateUpdateAssetGroupDetails assetGroupDetails); @ApiOperation(httpMethod = "POST", value = "API to create asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> createAssetGroupDetails(@AuthenticationPrincipal Principal user,
			@RequestBody CreateUpdateAssetGroupDetails assetGroupDetails); @ApiOperation(httpMethod = "GET", value = "API to get all asset group details", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllAssetGroupDetails(
			@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 all asset group details by id and datasource", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-id-and-datasource", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAssetGroupDetailsByNameAndDataSource(
			@ApiParam(value = "provide valid id", required = true) @RequestParam(defaultValue = "", name = "assetGroupId", required = true) String assetGroupId,
			@ApiParam(value = "provide valid datasource", required = true) @RequestParam(defaultValue = "", name = "dataSource", required = true) String dataSource); @ApiOperation(httpMethod = "GET", value = "API to get asset group details by name", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/list-by-name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> findByGroupName(
			@ApiParam(value = "provide valid name", required = true) @RequestParam(defaultValue = "", name = "assetGroupName", required = true) String assetGroupName); @ApiOperation(httpMethod = "POST", value = "API to delete asset group", response = Response.class, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> deleteAssetGroup(@AuthenticationPrincipal Principal user,
			@RequestBody DeleteAssetGroupRequest assetGroupDetails);  }