@Test public void getLicense_should_fail_if_version_less_than_7_9() throws Exception { Licenses underTest = newLicenses(true); Throwable thrown = catchThrowable(() -> underTest.getLicense(Edition.DEVELOPER, Version.create("7.2.0.10000"))); assertThat(thrown).hasMessage("Commercial licenses of SonarQube 7.2.0.10000 are no longer supported").isInstanceOf(IllegalArgumentException.class); thrown = catchThrowable(() -> underTest.getLicense(Edition.DEVELOPER, Version.create("6.7"))); assertThat(thrown).hasMessage("Commercial licenses of SonarQube 6.7 are no longer supported").isInstanceOf(IllegalArgumentException.class); }
public String getLicense(Edition edition, Version version) { if (!version.isGreaterThanOrEquals(7, 9)) { throw new IllegalArgumentException(String.format("Commercial licenses of SonarQube %s are no longer supported", version)); } return licensesPerEdition.computeIfAbsent(edition, e -> { String filename; switch (e) { case DEVELOPER: filename = "de.txt"; break; case ENTERPRISE: filename = "ee.txt"; break; case DATACENTER: filename = "dce.txt"; break; default: throw new IllegalStateException("License does not exist for edition " + e); } return download(baseUrl + "master/edition_testing/" + filename); }); }
Licenses { public String getLicense(Edition edition, Version version) { if (!version.isGreaterThanOrEquals(7, 9)) { throw new IllegalArgumentException(String.format("Commercial licenses of SonarQube %s are no longer supported", version)); } return licensesPerEdition.computeIfAbsent(edition, e -> { String filename; switch (e) { case DEVELOPER: filename = "de.txt"; break; case ENTERPRISE: filename = "ee.txt"; break; case DATACENTER: filename = "dce.txt"; break; default: throw new IllegalStateException("License does not exist for edition " + e); } return download(baseUrl + "master/edition_testing/" + filename); }); } }
Licenses { public String getLicense(Edition edition, Version version) { if (!version.isGreaterThanOrEquals(7, 9)) { throw new IllegalArgumentException(String.format("Commercial licenses of SonarQube %s are no longer supported", version)); } return licensesPerEdition.computeIfAbsent(edition, e -> { String filename; switch (e) { case DEVELOPER: filename = "de.txt"; break; case ENTERPRISE: filename = "ee.txt"; break; case DATACENTER: filename = "dce.txt"; break; default: throw new IllegalStateException("License does not exist for edition " + e); } return download(baseUrl + "master/edition_testing/" + filename); }); } Licenses(Configuration configuration, String baseUrl);  Licenses(Configuration configuration); }
Licenses { public String getLicense(Edition edition, Version version) { if (!version.isGreaterThanOrEquals(7, 9)) { throw new IllegalArgumentException(String.format("Commercial licenses of SonarQube %s are no longer supported", version)); } return licensesPerEdition.computeIfAbsent(edition, e -> { String filename; switch (e) { case DEVELOPER: filename = "de.txt"; break; case ENTERPRISE: filename = "ee.txt"; break; case DATACENTER: filename = "dce.txt"; break; default: throw new IllegalStateException("License does not exist for edition " + e); } return download(baseUrl + "master/edition_testing/" + filename); }); } Licenses(Configuration configuration, String baseUrl);  Licenses(Configuration configuration); String getLicense(Edition edition, Version version); }
Licenses { public String getLicense(Edition edition, Version version) { if (!version.isGreaterThanOrEquals(7, 9)) { throw new IllegalArgumentException(String.format("Commercial licenses of SonarQube %s are no longer supported", version)); } return licensesPerEdition.computeIfAbsent(edition, e -> { String filename; switch (e) { case DEVELOPER: filename = "de.txt"; break; case ENTERPRISE: filename = "ee.txt"; break; case DATACENTER: filename = "dce.txt"; break; default: throw new IllegalStateException("License does not exist for edition " + e); } return download(baseUrl + "master/edition_testing/" + filename); }); } Licenses(Configuration configuration, String baseUrl);  Licenses(Configuration configuration); String getLicense(Edition edition, Version version);  }