HmsLocalRestServiceMgmt { @RequestMapping( value = "/debug/switch/{switch_id}", method = RequestMethod.PUT ) @ResponseBody public BaseResponse performLogArchivingForSwitch( @PathVariable final String switch_id, @RequestBody( required = false ) final String body, HttpMethod method ) throws HMSRestException { BaseResponse response = new BaseResponse(); if ( !InventoryLoader.getInstance().getSwitchNodeMap().containsKey( switch_id ) ) { throw new HMSRestException( Status.NOT_FOUND.getStatusCode(), "Invalid Request", "Can't find switch with id " + switch_id ); } int noOfLines = hmsLogLineExtractLimit; if ( body != null ) { ObjectMapper mapper = new ObjectMapper(); try { HmsLogExtractOptions options = mapper.readValue( body, HmsLogExtractOptions.class ); noOfLines = options.getNoOfLines(); } catch ( Exception e ) { logger.warn( "Cannot find number of lines to read from node [ " + switch_id + " ] IB and OOB logs, in request body. So using default value [ " + noOfLines + " ]" ); } } if ( noOfLines <= 500 ) { noOfLines = hmsLogLineExtractLimit; } try { String targetArchive = debuggerUtil.archiveHmsDebugLogs( switch_id, hmsIpAddr, hmsOobUsername, hmsLogArchiverScript, hmsLogArchiveLocation, hmsOobLogLocation, hmsIbLogLocation, noOfLines, EventComponent.SWITCH ); response.setStatusCode( Status.OK.getStatusCode() ); response.setStatusMessage( "Hms debug logs archive will be created shortly at " + targetArchive ); return response; } catch ( IllegalArgumentException e ) { String err = "Exception occured during Log archiving for node [ " + switch_id + " ]"; String debugString = String.format( "host_id [ %s ], hmsIpAddr [ %s ], hmsOobUsername [ %s ], hmsLogArchiverScript [ %s ], hmsLogArchiveLocation [ %s ], hmsOobLogLocation [ %s ], hmsIbLogLocation [ %s ], noOfLines[ %s ]", switch_id, hmsIpAddr, hmsOobUsername, hmsLogArchiverScript, hmsLogArchiveLocation, hmsOobLogLocation, hmsIbLogLocation, noOfLines ); logger.error( err + debugString ); response.setStatusCode( Status.INTERNAL_SERVER_ERROR.getStatusCode() ); response.setStatusMessage( err ); return response; } }  @RequestMapping( value = "/debug/host/{host_id}", method = RequestMethod.PUT ) @ResponseBody BaseResponse performLogArchiving( @PathVariable
    final String host_id, @RequestBody( required = false )
    final String body, HttpMethod method ); @RequestMapping( value = "/debug/host", method = RequestMethod.DELETE ) @ResponseBody BaseResponse cleanUpLogs( @RequestBody( required = false )
    final String body, HttpMethod method ); @RequestMapping( value = "/debug/switch/{switch_id}", method = RequestMethod.PUT ) @ResponseBody BaseResponse performLogArchivingForSwitch( @PathVariable
    final String switch_id, @RequestBody( required = false )
    final String body, HttpMethod method );  }
@Test public void performLogArchivingForSwitchTest() throws Exception, IllegalArgumentException { Mockito.doReturn( "logs archive directory" ).when( debuggerUtil ).archiveHmsDebugLogs( anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyInt(), Matchers.any( EventComponent.class ) ); BaseResponse responseMock = new BaseResponse(); responseMock.setStatusCode( 200 ); responseMock.setStatusMessage( "Hms debug logs archive will be created shortly at logs archive directory" ); BaseResponse response = hmsLocalRestServiceMgmt.performLogArchivingForSwitch( "S1", "100", HttpMethod.PUT ); assertNotNull( response ); assertEquals( response.getStatusCode(), responseMock.getStatusCode() ); }