APIVersionResolver { public String resolveAPIVersion() { final String sysprop = System.getProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); if (sysprop != null) { return sysprop; } final String platformVersion = PlatformVersion.getVersion(); return platformVersion; }  String resolveAPIVersion(); String resolveOldAPIVersion();  }
@Test public void testResolveAPIVersionFromSysProp() throws Exception { APIVersionResolver fixture = new APIVersionResolver(); final String sysPropBefore = System.getProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); String value = "10.0.0"; System.setProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION, value); String result = fixture.resolveAPIVersion(); try { Assert.assertEquals(value, result); } finally { if (sysPropBefore == null) { System.clearProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); } else { System.setProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION, sysPropBefore); } } }
@Test public void testResolveAPIVersionByPlatformVersion() throws Exception { APIVersionResolver fixture = new APIVersionResolver(); final String sysPropBefore = System.getProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); System.clearProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); String result = fixture.resolveAPIVersion(); try { Assert.assertEquals(PlatformVersion.getVersion(), result); } finally { if (sysPropBefore == null) { System.clearProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION); } else { System.setProperty(CloudifyConstants.SYSTEM_PROPERTY_CLI_REST_API_VERSION, sysPropBefore); } } }