HmsUpgradeUtil { public static boolean saveUpgradeStatus( final String fileNameAbsPath, final UpgradeStatus upgradeStatus ) { if ( StringUtils.isBlank( fileNameAbsPath ) || upgradeStatus == null ) { return false; } return HmsUpgradeUtil.saveUpgradeStatus( new File( fileNameAbsPath ), upgradeStatus ); } private  HmsUpgradeUtil(); static boolean saveUpgradeStatus( final String fileNameAbsPath, final UpgradeStatus upgradeStatus ); static boolean saveUpgradeStatus( final File upgradeStatusFile, final UpgradeStatus upgradeStatus ); static UpgradeStatus loadUpgradeStatus( final String fileNameAbsPath ); static UpgradeStatus loadUpgradeStatus( final File upgradeStatusFile );  }
@Test public void testSaveUpgradeStatus() { UpgradeStatus upgradeStatus = null; String upgradeStatusFileName = null; Calendar cal = Calendar.getInstance(); String timeInMillis = Long.toString( cal.getTimeInMillis() ); assertFalse( HmsUpgradeUtil.saveUpgradeStatus( upgradeStatusFileName, null ) ); String id = UUID.randomUUID().toString(); UpgradeStatusCode statusCode = UpgradeStatusCode.HMS_UPGRADE_INITIATED; upgradeStatus = new UpgradeStatus(); upgradeStatus.setId( id ); upgradeStatus.setStatusCode( statusCode ); assertFalse( HmsUpgradeUtil.saveUpgradeStatus( upgradeStatusFileName, upgradeStatus ) ); upgradeStatusFileName = upgradeDir + File.separator + timeInMillis + ".json"; assertFalse( HmsUpgradeUtil.saveUpgradeStatus( upgradeStatusFileName, null ) ); assertTrue( HmsUpgradeUtil.saveUpgradeStatus( upgradeStatusFileName, upgradeStatus ) ); File upgradeStatusFile = new File( upgradeStatusFileName ); assertTrue( upgradeStatusFile.exists() && upgradeStatusFile.isFile() ); assertTrue( upgradeStatusFile.delete() ); File upgradeDirFile = new File( upgradeDir ); if ( upgradeDirFile.exists() && upgradeDirFile.isDirectory() ) { upgradeDirFile.delete(); } }