diff --git a/url-updater/src/main/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUrlUpdater.java b/url-updater/src/main/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUrlUpdater.java new file mode 100644 index 0000000000..b6033a7e71 --- /dev/null +++ b/url-updater/src/main/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUrlUpdater.java @@ -0,0 +1,85 @@ +package com.devonfw.tools.ide.url.tool.soapui; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.devonfw.tools.ide.url.model.folder.UrlVersion; +import com.devonfw.tools.ide.url.updater.GithubUrlReleaseUpdater; +import com.devonfw.tools.ide.version.VersionIdentifier; + +/** + * {@link GithubUrlReleaseUpdater} for SoapUI. + */ +public class SoapUiUrlUpdater extends GithubUrlReleaseUpdater { + + private static final String DOWNLOAD_BASE_URL = "https://dl.eviware.com"; + + private static final VersionIdentifier MIN_VERSION = VersionIdentifier.of("5.8.0"); + + private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+\\.\\d+\\.\\d+)"); + + /** + * The constructor. + */ + public SoapUiUrlUpdater() { + super(DOWNLOAD_BASE_URL); + } + + /** + * Package-private constructor used for testing {@link SoapUiUrlUpdater}. + * + * @param baseUrl mock url used as download and version base. + */ + public SoapUiUrlUpdater(String baseUrl) { + super(baseUrl, baseUrl); + } + + @Override + public String getTool() { + return "soapui"; + } + + @Override + protected String getGithubOrganization() { + return "SmartBear"; + } + + @Override + protected String getGithubRepository() { + return "soapui"; + } + + @Override + public String mapVersion(String version) { + if (version == null) { + return null; + } + Matcher matcher = VERSION_PATTERN.matcher(version); + if (matcher.find()) { + return super.mapVersion(matcher.group(1)); + } + return null; + } + + @Override + protected void addVersion(UrlVersion urlVersion) { + if (urlVersion.getVersionIdentifier().compareVersion(MIN_VERSION).isLess()) { + return; + } + String base = getDownloadBaseUrl() + "/soapuios/${version}/SoapUI-${version}-"; + doAddVersion(urlVersion, base + "windows-bin.zip", WINDOWS, X64); + doAddVersion(urlVersion, base + "linux-bin.tar.gz", LINUX, X64); + doAddVersion(urlVersion, base + "mac-x64-bin.zip", MAC, X64); + doAddVersion(urlVersion, base + "mac-arm64-bin.zip", MAC, ARM64); + } + + @Override + public String getCpeVendor() { + return "smartbear"; + } + + @Override + public String getCpeProduct() { + return "soapui"; + } +} diff --git a/url-updater/src/main/java/com/devonfw/tools/ide/url/updater/UpdateManager.java b/url-updater/src/main/java/com/devonfw/tools/ide/url/updater/UpdateManager.java index e3370dda23..b924537e21 100644 --- a/url-updater/src/main/java/com/devonfw/tools/ide/url/updater/UpdateManager.java +++ b/url-updater/src/main/java/com/devonfw/tools/ide/url/updater/UpdateManager.java @@ -52,6 +52,7 @@ import com.devonfw.tools.ide.url.tool.python.PythonUrlUpdater; import com.devonfw.tools.ide.url.tool.quarkus.QuarkusUrlUpdater; import com.devonfw.tools.ide.url.tool.rust.RustUrlUpdater; +import com.devonfw.tools.ide.url.tool.soapui.SoapUiUrlUpdater; import com.devonfw.tools.ide.url.tool.sonar.SonarUrlUpdater; import com.devonfw.tools.ide.url.tool.squirrelsql.SquirrelSqlUrlUpdater; import com.devonfw.tools.ide.url.tool.terraform.TerraformUrlUpdater; @@ -83,7 +84,7 @@ public class UpdateManager extends AbstractProcessorWithTimeout { new KotlincNativeUrlUpdater(), new LazyDockerUrlUpdater(), new MvnUrlUpdater(), new MvndUrlUpdater(), new NgUrlUpdater(), new NodeUrlUpdater(), new NpmUrlUpdater(), new OcUrlUpdater(), new PgAdminUrlUpdater(), new PipUrlUpdater(), new PycharmUrlUpdater(), new PythonUrlUpdater(), new QuarkusUrlUpdater(), new RustUrlUpdater(), new DockerRancherDesktopUrlUpdater(), new SonarUrlUpdater(), - new SquirrelSqlUrlUpdater(), + new SquirrelSqlUrlUpdater(), new SoapUiUrlUpdater(), new TerraformUrlUpdater(), new TomcatUrlUpdater(), new UvUrlUpdater(), new VsCodeUrlUpdater(), new VsCodiumUrlUpdater()); /** diff --git a/url-updater/src/test/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUpdaterTest.java b/url-updater/src/test/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUpdaterTest.java new file mode 100644 index 0000000000..4e60e8da50 --- /dev/null +++ b/url-updater/src/test/java/com/devonfw/tools/ide/url/tool/soapui/SoapUiUpdaterTest.java @@ -0,0 +1,54 @@ +package com.devonfw.tools.ide.url.tool.soapui; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.any; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; + +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import com.devonfw.tools.ide.url.model.folder.UrlRepository; +import com.devonfw.tools.ide.url.updater.AbstractUrlUpdaterTest; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; + +/** + * Tests for (@link SoapUiUrlUpdater}. + */ +@WireMockTest +public class SoapUiUpdaterTest extends AbstractUrlUpdaterTest { + + /** + * Test of {@link SoapUiUrlUpdater} creating the per-OS/arch download URLs and checksums. + * + * @param tempDir temporary directory to use. + * @param wmRuntimeInfo the {@link com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo}. + */ + @Test + void testSoapUiUrlUpdater(@TempDir Path tempDir, WireMockRuntimeInfo wmRuntimeInfo) { + + //arrange + stubFor(get(urlMatching("/repos/SmartBear/soapui/releases")) + .willReturn(aResponse().withStatus(200).withBody(readAndResolve(PATH_INTEGRATION_TEST.resolve("SoapUiUpdater") + .resolve("soapui-releases.json"), wmRuntimeInfo)))); + + stubFor(any(urlMatching("/soapuios/.*/SoapUI-.*-(windows-bin\\.zip|linux-bin\\.tar\\.gz|mac-x64-bin\\.zip|mac-arm64-bin\\.zip)")) + .willReturn(aResponse().withStatus(200).withBody("aBody"))); + + UrlRepository urlRepository = UrlRepository.load(tempDir); + SoapUiUrlUpdater updater = new SoapUiUrlUpdater(wmRuntimeInfo.getHttpBaseUrl()); + + //act + updater.update(urlRepository); + + //assert + Path soapUiVersionDir = tempDir.resolve("soapui").resolve("soapui"); + assertUrlVersionOsX64MacArm(soapUiVersionDir.resolve("5.10.0")); + assertUrlVersionOsX64MacArm(soapUiVersionDir.resolve("5.8.0")); + } + +} diff --git a/url-updater/src/test/resources/integrationtest/SoapUiUpdater/soapui-releases.json b/url-updater/src/test/resources/integrationtest/SoapUiUpdater/soapui-releases.json new file mode 100644 index 0000000000..535fc34df2 --- /dev/null +++ b/url-updater/src/test/resources/integrationtest/SoapUiUpdater/soapui-releases.json @@ -0,0 +1,22 @@ +[ + { + "tag_name": "v5.10.0", + "name": "SoapUI 5.10.0", + "prerelease": false + }, + { + "tag_name": "v5.9.1", + "name": "SoapUI 5.9.1", + "prerelease": false + }, + { + "tag_name": "v5.8.0", + "name": "SoapUI 5.8.0", + "prerelease": false + }, + { + "tag_name": "v5.7.2", + "name": "SoapUI 5.7.2", + "prerelease": false + } +]