ReleaseGraphManager { public List<List<UpgradeInfo>> getUpgradeInfosList( String fromVersionString) { List<String> endVertices = getEndVertices(); endVertices.remove(fromVersionString); List<List<UpgradeInfo>> upgradeInfosList = new ArrayList<>(); for (String endVertex : endVertices) { List<UpgradeInfo> upgradeInfos = getUpgradeInfos( fromVersionString, endVertex); if (upgradeInfos.isEmpty()) { continue; } upgradeInfosList.add(upgradeInfos); } return upgradeInfosList; } ReleaseGraphManager(final List<UpgradeInfo> upgradeInfos); List<UpgradeInfo> getUpgradeInfos(
		String fromVersionString, String toVersionString); List<List<UpgradeInfo>> getUpgradeInfosList(
		String fromVersionString);  }
@Test public void testGetAutoUpgradePath() { UpgradeInfo upgradeInfo1 = createUpgradeInfo("0.0.0", "0.1.0"); UpgradeInfo upgradeInfo2 = createUpgradeInfo("0.1.0", "0.2.0"); UpgradeInfo upgradeInfo3 = createUpgradeInfo("0.2.0", "1.0.0"); UpgradeInfo upgradeInfo4 = createUpgradeInfo("1.0.0", "2.0.0"); ReleaseGraphManager releaseGraphManager = new ReleaseGraphManager( Arrays.asList( upgradeInfo1, upgradeInfo2, upgradeInfo3, upgradeInfo4)); List<List<UpgradeInfo>> upgradeInfosList = releaseGraphManager.getUpgradeInfosList("0.0.0"); Assert.assertEquals( upgradeInfosList.toString(), 1, upgradeInfosList.size()); Assert.assertEquals( Arrays.asList( upgradeInfo1, upgradeInfo2, upgradeInfo3, upgradeInfo4), upgradeInfosList.get(0)); }
@Test public void testGetAutoUpgradePathWhenInEndNode() { UpgradeInfo upgradeInfo1 = createUpgradeInfo("0.0.0", "0.1.0"); UpgradeInfo upgradeInfo2 = createUpgradeInfo("0.1.0", "0.2.0"); UpgradeInfo upgradeInfo3 = createUpgradeInfo("0.2.0", "1.0.0"); UpgradeInfo upgradeInfo4 = createUpgradeInfo("1.0.0", "2.0.0"); UpgradeInfo upgradeInfo5 = createUpgradeInfo("0.1.0", "0.1.0.1"); UpgradeInfo upgradeInfo6 = createUpgradeInfo("0.1.0.1", "0.1.0"); ReleaseGraphManager releaseGraphManager = new ReleaseGraphManager( Arrays.asList( upgradeInfo1, upgradeInfo2, upgradeInfo3, upgradeInfo4, upgradeInfo5, upgradeInfo6)); List<List<UpgradeInfo>> upgradeInfosList = releaseGraphManager.getUpgradeInfosList("0.1.0.1"); Assert.assertEquals( upgradeInfosList.toString(), 1, upgradeInfosList.size()); Assert.assertEquals( Arrays.asList( upgradeInfo6, upgradeInfo2, upgradeInfo3, upgradeInfo4), upgradeInfosList.get(0)); }
@Test public void testGetAutoUpgradePathWhenInEndNodeAndMultipleSinkNodes() { UpgradeInfo upgradeInfo1 = createUpgradeInfo("0.0.0", "0.1.0"); UpgradeInfo upgradeInfo2 = createUpgradeInfo("0.1.0", "0.2.0"); UpgradeInfo upgradeInfo3 = createUpgradeInfo("0.2.0", "1.0.0"); UpgradeInfo upgradeInfo4 = createUpgradeInfo("1.0.0", "2.0.0"); UpgradeInfo upgradeInfo5 = createUpgradeInfo("0.1.0", "0.1.0.1"); UpgradeInfo upgradeInfo6 = createUpgradeInfo("0.1.0.1", "0.1.0"); UpgradeInfo upgradeInfo7 = createUpgradeInfo("0.1.0.1", "0.1.0.2"); ReleaseGraphManager releaseGraphManager = new ReleaseGraphManager( Arrays.asList( upgradeInfo1, upgradeInfo2, upgradeInfo3, upgradeInfo4, upgradeInfo5, upgradeInfo6, upgradeInfo7)); List<List<UpgradeInfo>> upgradeInfosList = releaseGraphManager.getUpgradeInfosList("0.1.0.1"); Assert.assertEquals( upgradeInfosList.toString(), 2, upgradeInfosList.size()); }
@Test public void testGetAutoUpgradePathWhithoutEndNodes() { UpgradeInfo upgradeInfo1 = createUpgradeInfo("0.0.0", "0.1.0"); UpgradeInfo upgradeInfo2 = createUpgradeInfo("0.1.0", "0.0.0"); UpgradeInfo upgradeInfo3 = createUpgradeInfo("0.1.0", "0.2.0"); UpgradeInfo upgradeInfo4 = createUpgradeInfo("0.2.0", "0.1.0"); ReleaseGraphManager releaseGraphManager = new ReleaseGraphManager( Arrays.asList( upgradeInfo1, upgradeInfo2, upgradeInfo3, upgradeInfo4)); List<List<UpgradeInfo>> upgradeInfosList = releaseGraphManager.getUpgradeInfosList("0.0.0"); Assert.assertEquals( upgradeInfosList.toString(), 0, upgradeInfosList.size()); }