HMSManagementRestService { @POST @Path( "/handshake" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) public BaseResponse handshake() throws HMSRestException { BaseResponse response = new BaseResponse(); response.setStatusCode( Status.ACCEPTED.getStatusCode() ); response.setStatusMessage( "Handshake request accepted." ); return response; }  @GET @Path( "/nodes" ) @Produces( "application/json" ) Map<String, Object[]> getHMSNodes(); @GET @Path( "/discover" ) @Produces( "application/json" ) NodeDiscoveryResponse discoverNodes(); @POST @Path( "/handshake" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse handshake(); @POST @Path( "/handshake/{aggregator_ip}/{source}" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse handshake( @PathParam( "aggregator_ip" ) String aggregatorIp,
                                   @PathParam( "source" ) String source ); @GET @Path( "/service/operations" ) @Produces( "application/json" ) Map<String, List<HmsApi>> getSupportedOOBOperations(); @GET @Path( "/debug/threads" ) @Produces( "application/json" ) Map<String, String> executeThreadStackLogger(); @PUT @Path( "/refreshinventory" ) @Produces( MediaType.APPLICATION_JSON ) @Deprecated Response refreshInventory( final String inventory ); @GET @Path( "/hmslogs" ) @Produces( MediaType.APPLICATION_OCTET_STREAM ) Response getHmsLogs(); @DELETE @Path( "/hmslogs" ) @Produces( "application/json" ) BaseResponse deleteTemporaryHmsLogFile(); boolean isFileDeleteable( File logArchiveName ); @GET @Path( "/newhosts" ) @Produces( MediaType.APPLICATION_JSON ) Response getNewHosts(); static final String GRANT_EXECUTE_RIGHTS; final String TIMESTAMP_FORMAT; }
@Test( expected = HMSRestException.class ) public void testHandshakeOnInvalidInput() throws Exception { HMSManagementRestService service = new HMSManagementRestService(); service.handshake( "", "VRM" ); }
@Test public void testHandshakeOnSuccessCase() throws Exception { PowerMockito.mockStatic( HmsConfigHolder.class ); when( HmsConfigHolder.getProperty( any( String.class ), any( String.class ) ) ).thenReturn( "false" ); PowerMockito.mockStatic( OobUtil.class ); when( OobUtil.getProperty( any( String.class ), any( String.class ), any( String.class ) ) ).thenReturn( "192.168.100.40" ).thenReturn( "192.168.100.108" ); HMSManagementRestService service = new HMSManagementRestService(); BaseResponse response = service.handshake( "192.168.100.108", "VRM" ); assertNotNull( response ); assertEquals( response.getStatusCode().intValue(), 202 ); }