HMSLocalServerRestService { @RequestMapping( value = { "/{host_id}/bootoptions", "/{host_id}/chassisidentify", "/{host_id}/selinfo" }, method = RequestMethod.PUT ) @ResponseBody public ResponseEntity<Object> putMirrorHostInfo( @RequestBody( required = false ) String body, HttpMethod method, HttpServletRequest request, HttpServletResponse response ) throws HMSRestException, URISyntaxException, JsonParseException, JsonMappingException, IOException { ResponseEntity<Object> nodes; String path = request.getServletPath() + request.getPathInfo(); try { String query = request.getQueryString(); HttpMethod httpMethod = HttpMethod.valueOf( request.getMethod() ); String contentType = request.getContentType(); HmsOobAgentRestTemplate<String> restTemplate = new HmsOobAgentRestTemplate<String>( body, contentType ); nodes = restTemplate.exchange( httpMethod, path, query, Object.class ); } catch ( HttpStatusCodeException e ) { HttpHeaders headers = new HttpHeaders(); headers.setContentType( MediaType.APPLICATION_JSON ); nodes = new ResponseEntity<Object>( e.getResponseBodyAsString(), headers, e.getStatusCode() ); } catch ( Exception e ) { throw new HMSRestException( HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server Error", "Exception while connecting to hms." + ( ( path != null ) ? path : "" ) ); } return nodes; }  @RequestMapping( value = { "/{host_id}/selftest", "/{host_id}/bmcusers", "/{host_id}/acpipowerstate", "/{host_id}/bootoptions", "/{host_id}/remoteconsoledetails", "/{host_id}/startremoteconsole" }, method = RequestMethod.GET ) @ResponseBody ResponseEntity<Object> getMirrorHostInfo( @RequestBody( required = false ) String body, HttpMethod method,
                                                     HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = { "", "/" }, method = RequestMethod.GET ) @ResponseBody Map<String, ServerNode> getAllServerNodes( @RequestBody( required = false ) String body, HttpMethod method,
                                                      HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = { "/jnlpRemoteConsoleSupportFiles/{host_id}/**" }, method = RequestMethod.GET ) @ResponseBody void getRemoteConsoleJnlpSupportFiles( HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/{host_id}", method = RequestMethod.GET ) @ResponseBody ServerInfo getHostInfo( @PathVariable String host_id ); @RequestMapping( value = "/{host_id}/powerstatus", method = RequestMethod.GET ) @ResponseBody ServerNodePowerStatus getHostPowerStatus( @PathVariable String host_id ); @RequestMapping( value = "/{hostId}/portname", method = RequestMethod.GET ) @ResponseBody String getPortName( @PathVariable String hostId ); @RequestMapping( value = "/{host_id}/cpuinfo", method = RequestMethod.GET ) @ResponseBody List<CpuInfo> getCpuInfo( @PathVariable String host_id ); @RequestMapping( value = "/{host_id}/storageinfo", method = RequestMethod.GET ) @ResponseBody List<StorageInfo> getHddInfo( @PathVariable String host_id ); @RequestMapping( value = "/{host_id}/storagecontrollerinfo", method = RequestMethod.GET ) @ResponseBody List<StorageController> getStorageControllerInfo( @PathVariable String host_id ); @RequestMapping( value = "/{host_id}/memoryinfo", method = RequestMethod.GET ) @ResponseBody List<MemoryInfo> getMemoryInfo( @PathVariable String host_id ); @RequestMapping( value = "/{host_id}/nicinfo", method = RequestMethod.GET ) @ResponseBody List<EthernetController> getNicInfo( @PathVariable String host_id ); @RequestMapping( value = { "/{host_id}/bootoptions", "/{host_id}/chassisidentify", "/{host_id}/selinfo" }, method = RequestMethod.PUT ) @ResponseBody ResponseEntity<Object> putMirrorHostInfo( @RequestBody( required = false ) String body, HttpMethod method,
                                                     HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = { "/{host_id}" }, method = RequestMethod.PUT ) @ResponseBody ResponseEntity<Object> updateNode( @PathVariable String host_id,
                                                            @RequestParam( "action" ) String action,
                                                            @RequestBody( required = false ) String body,
                                                            HttpMethod method, HttpServletRequest request,
                                                            HttpServletResponse response ); @RequestMapping( value = { "/{host_id}/bmcPassword" }, method = RequestMethod.PUT ) @ResponseBody ResponseEntity<BaseResponse> updateBmcPassword( @PathVariable String host_id,
                                                                         @RequestBody String newPassword ); @RequestMapping( value = { "/{hostId}" }, method = RequestMethod.DELETE ) ResponseEntity<BaseResponse> removeServer( @PathVariable String hostId );  }
@SuppressWarnings( { "rawtypes", "unchecked" } ) @Test public void putMirrorHostInfo_nodeInNodeMap() throws Exception { ResponseEntity responseEntityMock = mock( ResponseEntity.class ); HmsOobAgentRestTemplate restTemplateMock = mock( HmsOobAgentRestTemplate.class ); whenNew( HmsOobAgentRestTemplate.class ).withAnyArguments().thenReturn( restTemplateMock ); when( restTemplateMock.exchange( any( HttpMethod.class ), anyString(), anyString(), any( Class.class ) ) ).thenReturn( responseEntityMock ); HMSLocalServerRestService hmsLocalServerRestService = new HMSLocalServerRestService(); HttpServletRequest requestMock = mock( HttpServletRequest.class ); HttpServletResponse responseMock = mock( HttpServletResponse.class ); when( requestMock.getServletPath() ).thenReturn( "/test" ); when( requestMock.getPathInfo() ).thenReturn( "/test" ); when( requestMock.getQueryString() ).thenReturn( "test" ); when( requestMock.getMethod() ).thenReturn( "PUT" ); ResponseEntity response = hmsLocalServerRestService.putMirrorHostInfo( null, HttpMethod.PUT, requestMock, responseMock ); assertSame( responseEntityMock, response ); }