InventoryUtil { public static boolean createOrUpdateInventoryFile( final String inventoryFilePath, final String inventoryFileContent ) throws HmsException { return InventoryUtil.createOrUpdateInventoryFile( inventoryFilePath, inventoryFileContent, false ); }  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 public void testCreateInventoryFile() throws HmsException { Map<String, Object[]> inventory = new HashMap<String, Object[]>(); String nodeId = "N" + TestUtil.getDateTimeStamp(); ServerNode serverNode = TestUtil.getServerNode( nodeId ); List<ServerNode> serverNodes = new ArrayList<ServerNode>(); serverNodes.add( serverNode ); inventory.put( Constants.HOSTS, serverNodes.toArray( new ServerNode[serverNodes.size()] ) ); String tempDir = TestUtil.getTemporaryDirectory(); String invFileName = FilenameUtils.concat( tempDir, TestUtil.getDateTimeStamp() + ".json" ); String invContent = TestUtil.getValueAsString( inventory ); boolean createdOrUpdated = InventoryUtil.createOrUpdateInventoryFile( invFileName, invContent ); assertTrue( createdOrUpdated ); assertTrue( FileUtil.deleteDirectory( tempDir ) ); }