InventoryUtil { public static HashMap<String, List<HmsApi>> getOOBSupportedOperations( String path, String contentType ) throws HMSRestException { logger.debug( String.format( "Trying to get inventory OOB. Url for OOB operation - Path: %s, Content Type: %s ", path, contentType ) ); ResponseEntity<HashMap<String, List<HmsApi>>> oobResponse = null; if ( path != null ) { try { HmsOobAgentRestTemplate<Object> restTemplate = new HmsOobAgentRestTemplate<Object>( null, contentType ); ParameterizedTypeReference<HashMap<String, List<HmsApi>>> typeRef = new ParameterizedTypeReference<HashMap<String, List<HmsApi>>>() { }; oobResponse = restTemplate.exchange( HttpMethod.GET, path, typeRef ); } catch ( HttpStatusCodeException e ) { HttpHeaders headers = new HttpHeaders(); headers.setContentType( MediaType.APPLICATION_JSON ); logger.error( "Http Status Code Exception when trying to get oob operations: " + e ); } catch ( Exception e ) { logger.error( "Error while trying to get nodes: " + e ); throw new HMSRestException( HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server Error", "Exception while connecting to hms." + ( ( path != null ) ? path.toString() : "" ) ); } } else { logger.error( String.format( "Unable to get OOB supported operations because some Final OOB Url cannot be constructed. " + "Url for OOB operation is Path: %s, Content Type: %s ", path, contentType ) ); throw new HMSRestException( HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server Error", "Exception while connecting to hms. Unable to create Url" ); } return oobResponse.getBody(); }  static boolean initializeInventory( String inventoryFilePath, String path ); static Map<String, Object[]> initializeInventory( String inventoryFilePath ); static ResponseEntity<HashMap<String, Object[]>> getInventoryOOB( String path, String contentType ); static void putInventoryOOB( String path, String contentType, HmsInventoryConfiguration conf ); static HashMap<String, List<HmsApi>> getOOBSupportedOperations( String path, String contentType ); @SuppressWarnings( "unchecked" ) static Map<String, Object> getUpdatedServerInfos( Object[] hostsToBeUpdated,
                                                             List<ServerInfo> requestServerInfoList ); @SuppressWarnings( "unchecked" ) static List<String> getInvalidHostsinRequest( Object[] inventoryHosts,
                                                         List<ServerInfo> requestServerInfoList ); static boolean createOrUpdateInventoryFile( final String inventoryFilePath,
                                                       final String inventoryFileContent ); static boolean createOrUpdateInventoryFile( final String inventoryFilePath,
                                                       final String inventoryFileContent, final boolean createBackup ); static boolean removeServer( final String inventoryFilePath, final String hostId ); static boolean updateInventoryNodeMap( final String inventoryFileAbsPath ); static boolean isOobAgentInventoryLoaded(); static boolean isInventoryLoaded(); static boolean refreshInventoryOnOutOfBand(); static final String NODE_ID; static final String IB_IP_ADDRESS; static final String USERNAME; static final String PASSWORD; }
@Test( expected = HmsException.class ) public void getOOBSupportedOperations_OOBUnavailable() throws HMSRestException { HashMap<String, List<HmsApi>> oobOperations = InventoryUtil.getOOBSupportedOperations( "/samplePath", "application/json" ); assertNull( oobOperations ); }