diff --git a/modules/util/source-formatter/src/main/java/com/liferay/source/formatter/check/JSONUpgradeLiferayThemePackageJSONCheck.java b/modules/util/source-formatter/src/main/java/com/liferay/source/formatter/check/JSONUpgradeLiferayThemePackageJSONCheck.java index ccc13b5defe3b4..e0b3241b9c239d 100644 --- a/modules/util/source-formatter/src/main/java/com/liferay/source/formatter/check/JSONUpgradeLiferayThemePackageJSONCheck.java +++ b/modules/util/source-formatter/src/main/java/com/liferay/source/formatter/check/JSONUpgradeLiferayThemePackageJSONCheck.java @@ -31,6 +31,10 @@ */ public class JSONUpgradeLiferayThemePackageJSONCheck extends BaseUpgradeCheck { + public static void setTestMode(boolean testMode) { + _testMode = testMode; + } + @Override protected String format( String fileName, String absolutePath, String content) @@ -152,6 +156,11 @@ private Map _getDevDependenciesLatestVersions() { JSONObject jsonObject = new JSONObjectImpl(content); + if (_testMode) { + jsonObject = new JSONObjectImpl( + "{\"versions\":{\"2.0.0\":{}}}"); + } + String latestVersion = _getLatestVersion(jsonObject); if (latestVersion.equals("")) { @@ -199,4 +208,6 @@ private String _getLatestVersion(JSONObject jsonObject) { private static final Log _log = LogFactoryUtil.getLog( JSONUpgradeLiferayThemePackageJSONCheck.class); + private static boolean _testMode; + } \ No newline at end of file diff --git a/modules/util/source-formatter/src/test/java/com/liferay/source/formatter/processor/UpgradeSourceProcessorTest.java b/modules/util/source-formatter/src/test/java/com/liferay/source/formatter/processor/UpgradeSourceProcessorTest.java index f621e3e9f4daa6..fb1a40f3ed917b 100644 --- a/modules/util/source-formatter/src/test/java/com/liferay/source/formatter/processor/UpgradeSourceProcessorTest.java +++ b/modules/util/source-formatter/src/test/java/com/liferay/source/formatter/processor/UpgradeSourceProcessorTest.java @@ -7,6 +7,7 @@ import com.liferay.petra.string.StringBundler; import com.liferay.source.formatter.SourceFormatterArgs; +import com.liferay.source.formatter.check.JSONUpgradeLiferayThemePackageJSONCheck; import com.liferay.source.formatter.check.UpgradeCatchAllCheck; import java.util.ArrayList; @@ -26,6 +27,8 @@ public void testGradleUpgradeReleaseDxpCheck() throws Exception { @Test public void testJSONUpgradeLiferayThemePackageJSONCheck() throws Exception { + JSONUpgradeLiferayThemePackageJSONCheck.setTestMode(true); + test( "upgrade/json-upgrade-liferay-theme-package-json-check/package." + "testjson"); diff --git a/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/expected/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson b/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/expected/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson index f4c4a7d5794e3f..10aebce94a63e4 100644 --- a/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/expected/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson +++ b/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/expected/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson @@ -1,12 +1,12 @@ { "devDependencies": { - "compass-mixins": "0.12.12", - "gulp": "4.0.2", - "liferay-font-awesome": "3.5.2", - "liferay-frontend-css-common": "6.0.8", - "liferay-frontend-theme-styled": "6.0.68", - "liferay-frontend-theme-unstyled": "6.0.56", - "liferay-theme-tasks": "^11.5.3" + "compass-mixins": "2.0.0", + "gulp": "2.0.0", + "liferay-font-awesome": "2.0.0", + "liferay-frontend-css-common": "2.0.0", + "liferay-frontend-theme-styled": "2.0.0", + "liferay-frontend-theme-unstyled": "2.0.0", + "liferay-theme-tasks": "^2.0.0" }, "liferayTheme": { "version": "7.4" diff --git a/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson b/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson index 002a356662fb4e..ca3d9bd3291a5a 100644 --- a/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson +++ b/modules/util/source-formatter/src/test/resources/com/liferay/source/formatter/dependencies/upgrade/json-upgrade-liferay-theme-package-json-check/package.testjson @@ -1,10 +1,10 @@ { "devDependencies": { - "gulp": "4.0.2", - "liferay-font-awesome": "3.4.1", - "liferay-frontend-css-common": "5.0.4", - "liferay-frontend-theme-styled": "4.0.10", - "liferay-theme-tasks": "^11.2.2" + "gulp": "2.0.0", + "liferay-font-awesome": "1.0.0", + "liferay-frontend-css-common": "1.0.0", + "liferay-frontend-theme-styled": "1.0.0", + "liferay-theme-tasks": "^1.0.0" }, "liferayTheme": { "version": "7.3"