HMSLocalRestService { @RequestMapping( value = { "/inventory", "/switches", "/switches/{switch_id}/**" } ) @ResponseBody public ResponseEntity<Object> getMirrorHostInfo( @RequestBody( required = false ) String body, HttpMethod method, HttpServletRequest request, HttpServletResponse response ) throws HMSRestException, JsonParseException, JsonMappingException, IOException { ResponseEntity<Object> nodes; String path = null; try { path = request.getServletPath() + request.getPathInfo(); 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 = { "/inventory", "/switches", "/switches/{switch_id}/**" } ) @ResponseBody ResponseEntity<Object> getMirrorHostInfo( @RequestBody( required = false ) String body, HttpMethod method,
                                                     HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/event/switches/{switch_id}/{event_source}", method = RequestMethod.GET ) @ResponseBody List<Event> getSwitchEvents( @PathVariable( "switch_id" ) String switch_id,
                                        @PathVariable( "event_source" ) EventComponent event_source ); @RequestMapping( value = "/switches/{switch_id}", method = RequestMethod.GET ) @ResponseBody SwitchInfo getSwitchInfo( @RequestBody( required = false ) String body, HttpMethod method,
                                     HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/switches/{switch_id}", method = RequestMethod.PUT ) @ResponseBody ResponseEntity<Object> updateSwitchNode( @RequestBody( required = false ) String body, HttpMethod method,
                                                    HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/about", method = RequestMethod.GET ) @ResponseBody Map<String, AboutResponse> getAboutResponse(); @RequestMapping( value = "/nodes", method = RequestMethod.GET ) @ResponseBody Map<String, Object[]> getAllNodes( @RequestBody( required = false ) String body, HttpMethod method,
                                              HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/host/cache", method = RequestMethod.GET ) @ResponseBody Map<String, ServerInfo> getAllHostCache( @RequestBody( required = false ) String body, HttpMethod method,
                                                    HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/switch/cache", method = RequestMethod.GET ) @ResponseBody Map<String, NBSwitchInfo> getAllSwitchCache( @RequestBody( required = false ) String body, HttpMethod method,
                                                        HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/discover", method = RequestMethod.GET ) @ResponseBody NodeDiscoveryResponse getDiscoveryStatus( @RequestBody( required = false ) String body, HttpMethod method,
                                                     HttpServletRequest request, HttpServletResponse response ); @RequestMapping( value = "/topology", method = RequestMethod.GET ) @ResponseBody List<NetTopElement> getNetTop( @RequestBody( required = false ) String body, HttpMethod method,
                                          HttpServletRequest request, HttpServletResponse response ); @PostConstruct void initialize(); BaseResponse initializeInventory(); @RequestMapping( value = "/refreshinventory", method = RequestMethod.POST ) @ResponseBody ResponseEntity<BaseResponse> refreshInventory( @RequestBody( required = false ) String body,
                                                          HttpMethod method ); void updateHmsCacheOnRefreshInventory(); void createHmsInMemoryCacheOnBootUp(); @RequestMapping( value = { "/host/inventory" }, method = RequestMethod.PUT ) @ResponseBody ResponseEntity<Object> updateInventory( @RequestBody( required = false ) String body ); @RequestMapping( value = { "/handshake" } ) @ResponseBody ResponseEntity<Object> handshake( @RequestBody( required = false ) String body, HttpMethod method,
                                             HttpServletRequest request, HttpServletResponse response ); @SuppressWarnings( "unchecked" ) @RequestMapping( value = { "/newhosts" }, method = RequestMethod.GET ) @ResponseBody ResponseEntity<T> getNewHosts(); @RequestMapping( value = "/handshake/{aggregator_ip}", method = RequestMethod.POST ) @ResponseBody ResponseEntity<Object> handshake( @PathVariable( "aggregator_ip" ) String aggregatorIp );  }
@SuppressWarnings( { "unchecked", "rawtypes" } ) @Test public void getMirrorHostInfo_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 ); HMSLocalRestService hmsLocalRestService = new HMSLocalRestService(); 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( "GET" ); ResponseEntity response = hmsLocalRestService.getMirrorHostInfo( null, HttpMethod.GET, requestMock, responseMock ); assertSame( responseEntityMock, response ); }