### Question:
UpgradeHelper { public UpgradePack suggestUpgradePack(String clusterName, StackId sourceStackId, StackId targetStackId, Direction direction, UpgradeType upgradeType, String preferredUpgradePackName) throws AmbariException { Cluster cluster = m_clusters.get().getCluster(clusterName); StackId currentStack = cluster.getCurrentStackVersion(); StackId stackForUpgradePack = targetStackId; if (direction.isDowngrade()) { stackForUpgradePack = sourceStackId; } Map<String, UpgradePack> packs = m_ambariMetaInfoProvider.get().getUpgradePacks( currentStack.getStackName(), currentStack.getStackVersion()); UpgradePack pack = null; if (StringUtils.isNotEmpty(preferredUpgradePackName) && packs.containsKey(preferredUpgradePackName)) { pack = packs.get(preferredUpgradePackName); LOG.warn("Upgrade pack '{}' not found for stack {}", preferredUpgradePackName, currentStack); } if (null == pack) { for (UpgradePack upgradePack : packs.values()) { if (null != upgradePack.getTargetStack() && StringUtils.equals(upgradePack.getTargetStack(), stackForUpgradePack.getStackId()) && upgradeType == upgradePack.getType()) { if (null == pack) { pack = upgradePack; } else { throw new AmbariException( String.format( "Unable to perform %s. Found multiple upgrade packs for type %s and stack %s", direction.getText(false), upgradeType.toString(), stackForUpgradePack)); } } } } if (null == pack) { throw new AmbariException( String.format("Unable to perform %s. Could not locate %s upgrade pack for stack %s", direction.getText(false), upgradeType.toString(), stackForUpgradePack)); } return pack; }  UpgradePack suggestUpgradePack(String clusterName,
      StackId sourceStackId, StackId targetStackId, Direction direction, UpgradeType upgradeType,
      String preferredUpgradePackName); List<UpgradeGroupHolder> createSequence(UpgradePack upgradePack,
      UpgradeContext context); Resource getTaskResource(String clusterName, Long requestId, Long stageId, Long taskId); @Transactional @Experimental(feature = ExperimentalFeature.PATCH_UPGRADES) void updateDesiredRepositoriesAndConfigs(UpgradeContext upgradeContext); void publishDesiredRepositoriesUpdates(UpgradeContext upgradeContext);  }### Answer:
@Test public void testSuggestUpgradePack() throws Exception{ final String clusterName = "c1"; final StackId sourceStackId = new StackId("HDP", "2.1.1"); final StackId targetStackId = new StackId("HDP", "2.2.0"); final Direction upgradeDirection = Direction.UPGRADE; final UpgradeType upgradeType = UpgradeType.ROLLING; makeCluster(); try { String preferredUpgradePackName = "upgrade_test"; UpgradePack up = m_upgradeHelper.suggestUpgradePack(clusterName, sourceStackId, targetStackId, upgradeDirection, upgradeType, preferredUpgradePackName); assertEquals(upgradeType, up.getType()); } catch (AmbariException e){ assertTrue(false); } }