Skip to content

Commit

Permalink
BLADE-742 fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjhy committed Jan 3, 2024
1 parent eda701b commit f3d568c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class WorkspaceConstants {

public static final String DEFAULT_WORKSPACE_PRODUCT_PROPERTY = "liferay.workspace.product";

public static final Pattern dxpQuarterlyVersionPattern = Pattern.compile(
public static final Pattern dxpQuarterReleaseVersionPattern = Pattern.compile(
"(\\d{4})\\.q([1234])\\.((\\d+)(-(\\d+))?)?");
public static final List<String> originalLiferayVersions = Arrays.asList("7.0", "7.1", "7.2", "7.3", "7.4");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ protected ProjectTemplatesArgs getProjectTemplateArgs(

projectTemplatesArgs.setTemplate(template);

Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterlyVersionPattern.matcher(
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterReleaseVersionPattern.matcher(
liferayVersion.get());

if (dxpQuarterlyVersionMatcher.matches()) {
Expand Down Expand Up @@ -487,7 +487,8 @@ private String _checkTemplateVersionRange(File templateFile, ProjectTemplatesArg

String versionString = projectTemplatesArgs.getLiferayVersion();

Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterlyVersionPattern.matcher(versionString);
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterReleaseVersionPattern.matcher(
versionString);

if (dxpQuarterlyVersionMatcher.matches()) {
return "";
Expand Down
20 changes: 16 additions & 4 deletions cli/src/main/java/com/liferay/blade/cli/command/InitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.liferay.blade.cli.BladeCLI;
import com.liferay.blade.cli.BladeSettings;
import com.liferay.blade.cli.WorkspaceConstants;
import com.liferay.blade.cli.WorkspaceProvider;
import com.liferay.blade.cli.gradle.GradleExec;
import com.liferay.blade.cli.util.BladeUtil;
Expand Down Expand Up @@ -36,6 +37,7 @@
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;

/**
* @author Gregory Amerson
Expand Down Expand Up @@ -214,11 +216,21 @@ public void execute() throws Exception {

ProductInfo productInfo = new ProductInfo((Map<String, String>)productInfoObject);

Version targetPlatformVersion = _makeCompatibleVersion(productInfo.getTargetPlatformVersion());
String targetPlatformVersion = productInfo.getTargetPlatformVersion();

liferayVersion = new String(
targetPlatformVersion.getMajor() + "." + targetPlatformVersion.getMinor() + "." +
targetPlatformVersion.getMicro());
Matcher targetPlatformMatcher = WorkspaceConstants.dxpQuarterReleaseVersionPattern.matcher(
targetPlatformVersion);

if (targetPlatformMatcher.matches()) {
liferayVersion = "7.4";
}
else {
Version normalTargetPlatformVersion = _makeCompatibleVersion(targetPlatformVersion);

liferayVersion =
normalTargetPlatformVersion.getMajor() + "." + normalTargetPlatformVersion.getMinor() + "." +
normalTargetPlatformVersion.getMicro();
}
}
else {
workspaceProductKey = _setProductAndVersionForMaven(productInfos, initArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ else if (dockerImageProperty.contains("dxp")) {
}
}
else {
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterlyVersionPattern.matcher(
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterReleaseVersionPattern.matcher(
targetPlatformVersion);

if (dxpQuarterlyVersionMatcher.matches()) {
Expand Down
4 changes: 3 additions & 1 deletion cli/src/test/java/com/liferay/blade/cli/BladeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class BladeTest extends BladeCLI {

public static final String PRODUCT_VERSION_PORTAL_74 = "portal-7.4-ga4";

public static final String PRODUCT_VERSION_PORTAL_QUARTER_RELEASE = "dxp-2023.q3.2";

public static BladeTestBuilder builder() {
return new BladeTestBuilder();
}
Expand Down Expand Up @@ -119,7 +121,7 @@ public void run(String[] args) throws Exception {
while (scanner.hasNextLine() && !bridj) {
String line = scanner.nextLine();

if ((line != null) && (line.length() > 0)) {
if ((line != null) && !line.isEmpty()) {
if (line.contains("org/bridj/Platform$DeleteFiles")) {
bridj = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,33 @@ public void testCreateMVCPortletInteractive() throws Exception {
_checkGradleBuildFiles(projectDir.getAbsolutePath());
}

@Test
public void testCreateMVCPortletQuarterRelease() throws Exception {
File workspace = new File(_rootDir, "workspace");

_makeWorkspaceVersion(workspace, BladeTest.PRODUCT_VERSION_PORTAL_QUARTER_RELEASE);

String[] gradleArgs = {"create", "--base", workspace.getAbsolutePath(), "-t", "mvc-portlet", "foo"};

File projectDir = new File(workspace, "modules/foo");

String projectPath = projectDir.getAbsolutePath();

TestUtil.runBlade(workspace, _extensionsDir, gradleArgs);

_checkGradleBuildFiles(projectPath);

_contains(
_checkFileExists(projectPath + "/src/main/java/foo/portlet/FooPortlet.java"),
".*^public class FooPortlet extends MVCPortlet.*$");

_checkFileExists(projectPath + "/build.gradle");

_checkFileExists(projectPath + "/src/main/resources/META-INF/resources/view.jsp");

_checkFileExists(projectPath + "/src/main/resources/META-INF/resources/init.jsp");
}

@Test
public void testCreateNpmAngular71() throws Exception {
File workspace = new File(_rootDir, "workspace");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ public void testBladeInitEmptyDirectoryHandleTwoDots() throws Exception {
Assert.assertNotNull(bladeTest.getWorkspaceProvider(emptyDir));
}

@Test
public void testBladeInitQuarterRelease() throws Exception {
File emptyDir = temporaryFolder.newFolder();

String[] args = {"--base", emptyDir.getPath(), "init", "-v", BladeTest.PRODUCT_VERSION_PORTAL_QUARTER_RELEASE};

BladeTest bladeTest = _getBladeTestCustomWorkspace(emptyDir);

bladeTest.run(args);

Assert.assertNotNull(bladeTest.getWorkspaceProvider(emptyDir));
}

@Test
public void testBladeInitUpgradePluginsSDKTo70() throws Exception {
File testdir = new File(temporaryFolder.getRoot(), "build/testUpgradePluginsSDKTo70");
Expand Down Expand Up @@ -347,7 +360,7 @@ public void testInitCommandListPromoted() throws Exception {

String firstLine = lines.get(0);

Assert.assertTrue(firstLine, firstLine.contains("dxp-7.4-"));
Assert.assertTrue(firstLine, firstLine.contains("dxp-"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public String getProduct(File workspaceDir) {
return "portal";
}

Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterlyVersionPattern.matcher(
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterReleaseVersionPattern.matcher(
targetPlatformVersion);

if (dxpQuarterlyVersionMatcher.matches()) {
Expand Down

0 comments on commit f3d568c

Please sign in to comment.