### Question:
DefaultUpgradeService implements UpgradeService { @Override public UpgradeMetaData getUpgradeType(Resource resource) { UpgradeMetaData metaData = new UpgradeMetaData(); String version = loadProjectVersion(resource); metaData.setProjectVersion(version); metaData.setSupportedVersion(String.valueOf(Project.VERSION)); int c1 = VersionComparator.INSTANCE.compare(version, MIN_SUPPORTED_VERSION); if (c1 < 0) { metaData.setIntermediateUpgradeVersion(MIN_SUPPORTED_VERSION); metaData.setUpgradeType(UpgradeType.INTERMEDIATE_UPGRADE_NEEDED); return metaData; } int c2 = VersionComparator.INSTANCE.compare(String.valueOf(Project.VERSION), version); if (c2 < 0) { metaData.setUpgradeType(UpgradeType.DOWNGRADE_NEEDED); } else if (c2 == 0) { metaData.setUpgradeType(UpgradeType.UPGRADE_NOT_NEEDED); } else { metaData.setUpgradeType(UpgradeType.UPGRADE_NEEDED); } return metaData; } DefaultUpgradeService(@Inject List<UpgradeHandler> handlerList); @Override UpgradeMetaData getUpgradeType(Resource resource); @Override Resource upgradeProject(Resource resource); static final String UNKNOWN_VERSION; static final String MIN_SUPPORTED_VERSION; }### Answer:
@Test public void getUpgradeType() throws Exception { UpgradeMetaData metaData = upgradeService.getUpgradeType(getResourceForVersion("5")); assertEquals(UpgradeType.INTERMEDIATE_UPGRADE_NEEDED, metaData.getUpgradeType()); metaData = upgradeService.getUpgradeType(getResourceForVersion("6")); assertEquals(UpgradeType.UPGRADE_NEEDED, metaData.getUpgradeType()); metaData = upgradeService.getUpgradeType(getResourceForVersion("10")); assertEquals(UpgradeType.UPGRADE_NOT_NEEDED, metaData.getUpgradeType()); metaData = upgradeService.getUpgradeType(getResourceForVersion("11")); assertEquals(UpgradeType.DOWNGRADE_NEEDED, metaData.getUpgradeType()); }