From 902a46e07c7b51e01e04e3838f1330d112fa9efb Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 24 Jun 2022 12:07:27 +0300 Subject: [PATCH] =?UTF-8?q?867=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=82=D0=B5=D1=81=D1=82=20=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D1=87=D0=B8=D1=8F=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B2=20Markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - добавлены недостающие описания - исправлены переименованные описания --- .../markdown/module-empty-method.md | 11 +++ .../markdown/module-unused-local-variable.md | 11 +++ .../markdown/module-unused-method.md | 11 +++ .../markdown/ru/module-empty-method.md | 10 ++ .../ru/module-unused-local-variable.md | 10 ++ .../markdown/ru/module-unused-method.md | 10 ++ .../{isinrole-using.md => using-isinrole.md} | 0 .../{isinrole-using.md => using-isinrole.md} | 0 ...=> md-standard-attribute-synonym-empty.md} | 0 .../check/MdScheduledJobPeriodicityCheck.java | 2 +- .../check/itests/CheckDescriptionTest.java | 92 ++++++++++++++++++ .../check/itests/CheckDescriptionTest.java | 92 ++++++++++++++++++ .../md/check/itests/CheckDescriptionTest.java | 93 +++++++++++++++++++ .../MdScheduledJobPeriodicityCheckTest.java | 55 +++++------ .../ql/check/itests/CheckDescriptionTest.java | 92 ++++++++++++++++++ .../check/itests/CheckDescriptionTest.java | 92 ++++++++++++++++++ 16 files changed, 546 insertions(+), 35 deletions(-) create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/module-empty-method.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-local-variable.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-method.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-empty-method.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-local-variable.md create mode 100644 bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-method.md rename bundles/com.e1c.v8codestyle.bsl/markdown/ru/{isinrole-using.md => using-isinrole.md} (100%) rename bundles/com.e1c.v8codestyle.bsl/markdown/{isinrole-using.md => using-isinrole.md} (100%) rename bundles/com.e1c.v8codestyle.md/markdown/ru/{md-standard-attribure-synonym-empty.md => md-standard-attribute-synonym-empty.md} (100%) create mode 100644 tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/check/itests/CheckDescriptionTest.java create mode 100644 tests/com.e1c.v8codestyle.form.itests/src/com/e1c/v8codestyle/form/check/itests/CheckDescriptionTest.java create mode 100644 tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/CheckDescriptionTest.java create mode 100644 tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/check/itests/CheckDescriptionTest.java create mode 100644 tests/com.e1c.v8codestyle.right.itests/src/com/e1c/v8codestyle/right/check/itests/CheckDescriptionTest.java diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/module-empty-method.md b/bundles/com.e1c.v8codestyle.bsl/markdown/module-empty-method.md new file mode 100644 index 00000000..77c8352c --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/module-empty-method.md @@ -0,0 +1,11 @@ +# Empty method check + +Empty module method check + +## Noncompliant Code Example + +## Compliant Solution + + +## See + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-local-variable.md b/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-local-variable.md new file mode 100644 index 00000000..9e310283 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-local-variable.md @@ -0,0 +1,11 @@ +# Unused local variable check + +Unused module local variable check + +## Noncompliant Code Example + +## Compliant Solution + + +## See + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-method.md b/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-method.md new file mode 100644 index 00000000..f477ff40 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/module-unused-method.md @@ -0,0 +1,11 @@ +# Unused method check + +Unused module method check + +## Noncompliant Code Example + +## Compliant Solution + + +## See + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-empty-method.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-empty-method.md new file mode 100644 index 00000000..bef5de67 --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-empty-method.md @@ -0,0 +1,10 @@ +# Проверка пустых методов + +Проверка модуля на наличие пустых методов + +## Неправильно + +## Правильно + +## См. + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-local-variable.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-local-variable.md new file mode 100644 index 00000000..9c5297cb --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-local-variable.md @@ -0,0 +1,10 @@ +# Проверка неиспользуемых локальных переменных + +Проверка модуля на наличие неиспользуемых локальных переменных + +## Неправильно + +## Правильно + +## См. + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-method.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-method.md new file mode 100644 index 00000000..7fe9dc5a --- /dev/null +++ b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/module-unused-method.md @@ -0,0 +1,10 @@ +# Проверка неиспользуемых методов + +Проверка модуля на наличие неиспользуемых методов + +## Неправильно + +## Правильно + +## См. + diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/ru/isinrole-using.md b/bundles/com.e1c.v8codestyle.bsl/markdown/ru/using-isinrole.md similarity index 100% rename from bundles/com.e1c.v8codestyle.bsl/markdown/ru/isinrole-using.md rename to bundles/com.e1c.v8codestyle.bsl/markdown/ru/using-isinrole.md diff --git a/bundles/com.e1c.v8codestyle.bsl/markdown/isinrole-using.md b/bundles/com.e1c.v8codestyle.bsl/markdown/using-isinrole.md similarity index 100% rename from bundles/com.e1c.v8codestyle.bsl/markdown/isinrole-using.md rename to bundles/com.e1c.v8codestyle.bsl/markdown/using-isinrole.md diff --git a/bundles/com.e1c.v8codestyle.md/markdown/ru/md-standard-attribure-synonym-empty.md b/bundles/com.e1c.v8codestyle.md/markdown/ru/md-standard-attribute-synonym-empty.md similarity index 100% rename from bundles/com.e1c.v8codestyle.md/markdown/ru/md-standard-attribure-synonym-empty.md rename to bundles/com.e1c.v8codestyle.md/markdown/ru/md-standard-attribute-synonym-empty.md diff --git a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdScheduledJobPeriodicityCheck.java b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdScheduledJobPeriodicityCheck.java index 6b04182b..4e8b0c8f 100644 --- a/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdScheduledJobPeriodicityCheck.java +++ b/bundles/com.e1c.v8codestyle.md/src/com/e1c/v8codestyle/md/check/MdScheduledJobPeriodicityCheck.java @@ -46,7 +46,7 @@ public final class MdScheduledJobPeriodicityCheck extends BasicCheck { - private static final String CHECK_ID = "shceduled-job-periodicity-too-short"; //$NON-NLS-1$ + private static final String CHECK_ID = "scheduled-job-periodicity-too-short"; //$NON-NLS-1$ private static final String MINIMUM_JOB_INTERVAL = "minimum-job-interval"; //$NON-NLS-1$ private static final String MINIMUM_JOB_INTERVAL_DEFAULT = "60"; //$NON-NLS-1$ diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/check/itests/CheckDescriptionTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/check/itests/CheckDescriptionTest.java new file mode 100644 index 00000000..4adb49be --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/check/itests/CheckDescriptionTest.java @@ -0,0 +1,92 @@ +/** + * + */ +package com.e1c.v8codestyle.bsl.check.itests; + +import static com.e1c.v8codestyle.internal.bsl.BslPlugin.PLUGIN_ID; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.e1c.g5.v8.dt.check.settings.CheckUid; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.internal.bsl.BslPlugin; + +/** + * The test of existing all markdown description for every check of the bundle. + * Note! That maven tycho run test only for HTML files which creates from markdown. + * + * @author Dmitriy Marmyshev + */ +public class CheckDescriptionTest + extends SingleProjectReadOnlyCheckTestBase +{ + private static final String HTML_PATH_PREFIX = "/check.descriptions/"; + + private static final String MD_PATH_PREFIX = "/markdown/"; + + private static final String HTML_DESCRIPTION_EXT = ".html"; + + private static final String MD_DESCRIPTION_EXT = ".md"; + + private static final String MESSAGE = "Checks in bundle {0} has no description files:\n- {1}"; + + private static final List LANGUAGE_CODES = List.of("", "ru"); + + private static final String PROJECT_NAME = "CommonModule"; + + @Test + public void testCheckDefaultDescriptionExist() throws Exception + { + Set checks = checkRepository.getChecksWithDescriptions() + .entrySet() + .stream() + .filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId())) + .map(Entry::getKey) + .collect(Collectors.toSet()); + + assertFalse(checks.isEmpty()); + + Collection notFound = new ArrayList<>(); + Class bundleClass = BslPlugin.getDefault().getClass(); + + for (CheckUid check : checks) + { + for (String languageCode : LANGUAGE_CODES) + { + String langFolder = languageCode.isEmpty() ? "" : languageCode + "/"; + String path = HTML_PATH_PREFIX + langFolder + check.getCheckId() + HTML_DESCRIPTION_EXT; + String mdPath = MD_PATH_PREFIX + langFolder + check.getCheckId() + MD_DESCRIPTION_EXT; + + if (bundleClass.getResource(path) == null && bundleClass.getResource(mdPath) == null) + { + notFound.add(PLUGIN_ID + mdPath); + } + } + } + + assertTrue(MessageFormat.format(MESSAGE, PLUGIN_ID, String.join("\n- ", notFound)), notFound.isEmpty()); + } + + @Override + protected String getTestConfigurationName() + { + // The project is need to initialize check repository + return PROJECT_NAME; + } + + @Override + protected boolean enableCleanUp() + { + return true; + } +} diff --git a/tests/com.e1c.v8codestyle.form.itests/src/com/e1c/v8codestyle/form/check/itests/CheckDescriptionTest.java b/tests/com.e1c.v8codestyle.form.itests/src/com/e1c/v8codestyle/form/check/itests/CheckDescriptionTest.java new file mode 100644 index 00000000..3f3b65de --- /dev/null +++ b/tests/com.e1c.v8codestyle.form.itests/src/com/e1c/v8codestyle/form/check/itests/CheckDescriptionTest.java @@ -0,0 +1,92 @@ +/** + * + */ +package com.e1c.v8codestyle.form.check.itests; + +import static com.e1c.v8codestyle.internal.form.CorePlugin.PLUGIN_ID; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.e1c.g5.v8.dt.check.settings.CheckUid; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.internal.form.CorePlugin; + +/** + * The check of existing all markdown description for every check of the bundle. + * Note! That maven tycho run test only for HTML files which creates from markdown. + * + * @author Dmitriy Marmyshev + */ +public class CheckDescriptionTest + extends SingleProjectReadOnlyCheckTestBase +{ + private static final String HTML_PATH_PREFIX = "/check.descriptions/"; + + private static final String MD_PATH_PREFIX = "/markdown/"; + + private static final String HTML_DESCRIPTION_EXT = ".html"; + + private static final String MD_DESCRIPTION_EXT = ".md"; + + private static final String MESSAGE = "Checks in bundle {0} has no description files:\n- {1}"; + + private static final List LANGUAGE_CODES = List.of("", "ru"); + + private static final String PROJECT_NAME = "InputFieldListChoiceMode"; + + @Test + public void testCheckDefaultDescriptionExist() throws Exception + { + Set checks = checkRepository.getChecksWithDescriptions() + .entrySet() + .stream() + .filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId())) + .map(Entry::getKey) + .collect(Collectors.toSet()); + + assertFalse(checks.isEmpty()); + + Collection notFound = new ArrayList<>(); + Class bundleClass = CorePlugin.getDefault().getClass(); + + for (CheckUid check : checks) + { + for (String languageCode : LANGUAGE_CODES) + { + String langFolder = languageCode.isEmpty() ? "" : languageCode + "/"; + String path = HTML_PATH_PREFIX + langFolder + check.getCheckId() + HTML_DESCRIPTION_EXT; + String mdPath = MD_PATH_PREFIX + langFolder + check.getCheckId() + MD_DESCRIPTION_EXT; + + if (bundleClass.getResource(path) == null && bundleClass.getResource(mdPath) == null) + { + notFound.add(PLUGIN_ID + mdPath); + } + } + } + + assertTrue(MessageFormat.format(MESSAGE, PLUGIN_ID, String.join("\n- ", notFound)), notFound.isEmpty()); + } + + @Override + protected String getTestConfigurationName() + { + // The project is need to initialize check repository + return PROJECT_NAME; + } + + @Override + protected boolean enableCleanUp() + { + return true; + } +} diff --git a/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/CheckDescriptionTest.java b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/CheckDescriptionTest.java new file mode 100644 index 00000000..671f68a8 --- /dev/null +++ b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/CheckDescriptionTest.java @@ -0,0 +1,93 @@ +/** + * + */ +package com.e1c.v8codestyle.md.check.itests; + +import static com.e1c.v8codestyle.internal.md.CorePlugin.PLUGIN_ID; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.e1c.g5.v8.dt.check.settings.CheckUid; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.internal.md.CorePlugin; + +/** + * The test of existing all markdown description for every check of the bundle. + * Note! That maven tycho run test only for HTML files which creates from markdown. + * + * @author Dmitriy Marmyshev + */ +public class CheckDescriptionTest + extends SingleProjectReadOnlyCheckTestBase +{ + private static final String HTML_PATH_PREFIX = "/check.descriptions/"; + + private static final String MD_PATH_PREFIX = "/markdown/"; + + private static final String HTML_DESCRIPTION_EXT = ".html"; + + private static final String MD_DESCRIPTION_EXT = ".md"; + + private static final String MESSAGE = "Checks in bundle {0} has no description files:\n- {1}"; + + private static final List LANGUAGE_CODES = List.of("", "ru"); + + private static final String PROJECT_NAME = "CommonModuleName"; + + @Test + public void testCheckDefaultDescriptionExist() throws Exception + { + Set checks = checkRepository.getChecksWithDescriptions() + .entrySet() + .stream() + .filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId())) + .map(Entry::getKey) + .collect(Collectors.toSet()); + + assertFalse(checks.isEmpty()); + + Collection notFound = new ArrayList<>(); + Class bundleClass = CorePlugin.getDefault().getClass(); + + for (CheckUid check : checks) + { + for (String languageCode : LANGUAGE_CODES) + { + String langFolder = languageCode.isEmpty() ? "" : languageCode + "/"; + String path = HTML_PATH_PREFIX + langFolder + check.getCheckId() + HTML_DESCRIPTION_EXT; + String mdPath = MD_PATH_PREFIX + langFolder + check.getCheckId() + MD_DESCRIPTION_EXT; + + if (bundleClass.getResource(path) == null && bundleClass.getResource(mdPath) == null) + { + notFound.add(PLUGIN_ID + mdPath); + } + } + } + + assertTrue(MessageFormat.format(MESSAGE, PLUGIN_ID, String.join("\n- ", notFound)), + notFound.isEmpty()); + } + + @Override + protected String getTestConfigurationName() + { + // The project is need to initialize check repository + return PROJECT_NAME; + } + + @Override + protected boolean enableCleanUp() + { + return true; + } +} diff --git a/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdScheduledJobPeriodicityCheckTest.java b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdScheduledJobPeriodicityCheckTest.java index 8bbecac2..2eca3e05 100644 --- a/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdScheduledJobPeriodicityCheckTest.java +++ b/tests/com.e1c.v8codestyle.md.itests/src/com/e1c/v8codestyle/md/check/itests/MdScheduledJobPeriodicityCheckTest.java @@ -21,11 +21,10 @@ import org.eclipse.emf.common.util.EList; import org.junit.Test; import com._1c.g5.v8.bm.core.IBmObject; -import com._1c.g5.v8.dt.core.platform.IDtProject; import com._1c.g5.v8.dt.schedule.model.DailySchedule; import com._1c.g5.v8.dt.schedule.model.Schedule; import com._1c.g5.v8.dt.validation.marker.Marker; -import com.e1c.g5.v8.dt.testing.check.CheckTestBase; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; import com.e1c.v8codestyle.md.check.MdScheduledJobPeriodicityCheck; /** @@ -35,9 +34,9 @@ import com.e1c.v8codestyle.md.check.MdScheduledJobPeriodicityCheck; * */ public final class MdScheduledJobPeriodicityCheckTest - extends CheckTestBase + extends SingleProjectReadOnlyCheckTestBase { - private static final String CHECK_ID = "shceduled-job-periodicity-too-short"; //$NON-NLS-1$ + private static final String CHECK_ID = "scheduled-job-periodicity-too-short"; //$NON-NLS-1$ private static final String PROJECT_NAME = "MdScheduledJobPeriodicity"; @@ -49,18 +48,15 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobDetailedRepeatPeriodLessOneMinute() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - IBmObject object = - getTopObjectByFqn("ScheduledJob.ScheduledJobWithDetailedRepeatPeriodLessOneMinute.Schedule", dtProject); + getTopObjectByFqn("ScheduledJob.ScheduledJobWithDetailedRepeatPeriodLessOneMinute.Schedule", getProject()); if (object instanceof Schedule) { Marker marker = null; EList dailySchedules = ((Schedule)object).getDailySchedules(); for (DailySchedule dailySchedule : dailySchedules) { - marker = getFirstMarker(CHECK_ID, ((IBmObject)dailySchedule).bmGetId(), dtProject); + marker = getFirstMarker(CHECK_ID, ((IBmObject)dailySchedule).bmGetId(), getProject()); assertNotNull(marker); } } @@ -74,18 +70,15 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobDetailedRepeatPeriodMoreOneMinute() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - IBmObject object = - getTopObjectByFqn("ScheduledJob.ScheduledJobWithDetailedRepeatPeriodMoreOneMinute.Schedule", dtProject); + getTopObjectByFqn("ScheduledJob.ScheduledJobWithDetailedRepeatPeriodMoreOneMinute.Schedule", getProject()); if (object instanceof Schedule) { Marker marker = null; EList dailySchedules = ((Schedule)object).getDailySchedules(); for (DailySchedule dailySchedule : dailySchedules) { - marker = getFirstMarker(CHECK_ID, ((IBmObject)dailySchedule).bmGetId(), dtProject); + marker = getFirstMarker(CHECK_ID, ((IBmObject)dailySchedule).bmGetId(), getProject()); assertNull(marker); } } @@ -99,11 +92,8 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobEmptySchedule() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - - long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithEmptySchedule.Schedule", dtProject); - Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithEmptySchedule.Schedule", getProject()); + Marker marker = getFirstMarker(CHECK_ID, id, getProject()); assertNull(marker); } @@ -115,11 +105,8 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobRepeatPauseLessOneMinute() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - - long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPauseLessOneMinute.Schedule", dtProject); - Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPauseLessOneMinute.Schedule", getProject()); + Marker marker = getFirstMarker(CHECK_ID, id, getProject()); assertNotNull(marker); } @@ -131,11 +118,8 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobRepeatPeriodLessOneMinute() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - - long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPeriodLessOneMinute.Schedule", dtProject); - Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPeriodLessOneMinute.Schedule", getProject()); + Marker marker = getFirstMarker(CHECK_ID, id, getProject()); assertNotNull(marker); } @@ -147,11 +131,14 @@ public final class MdScheduledJobPeriodicityCheckTest @Test public void testMdScheduledJobRepeatPeriodMoreOneMinute() throws Exception { - IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME); - assertNotNull(dtProject); - - long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPeriodMoreOneMinute.Schedule", dtProject); - Marker marker = getFirstMarker(CHECK_ID, id, dtProject); + long id = getTopObjectIdByFqn("ScheduledJob.ScheduledJobWithRepeatPeriodMoreOneMinute.Schedule", getProject()); + Marker marker = getFirstMarker(CHECK_ID, id, getProject()); assertNull(marker); } + + @Override + protected String getTestConfigurationName() + { + return PROJECT_NAME; + } } diff --git a/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/check/itests/CheckDescriptionTest.java b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/check/itests/CheckDescriptionTest.java new file mode 100644 index 00000000..f848eded --- /dev/null +++ b/tests/com.e1c.v8codestyle.ql.itests/src/com/e1c/v8codestyle/ql/check/itests/CheckDescriptionTest.java @@ -0,0 +1,92 @@ +/** + * + */ +package com.e1c.v8codestyle.ql.check.itests; + +import static com.e1c.v8codestyle.internal.ql.CorePlugin.PLUGIN_ID; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.e1c.g5.v8.dt.check.settings.CheckUid; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.internal.ql.CorePlugin; + +/** + * The test of existing all markdown description for every check of the bundle. + * Note! That maven tycho run test only for HTML files which creates from markdown. + * + * @author Dmitriy Marmyshev + */ +public class CheckDescriptionTest + extends SingleProjectReadOnlyCheckTestBase +{ + private static final String HTML_PATH_PREFIX = "/check.descriptions/"; + + private static final String MD_PATH_PREFIX = "/markdown/"; + + private static final String HTML_DESCRIPTION_EXT = ".html"; + + private static final String MD_DESCRIPTION_EXT = ".md"; + + private static final String MESSAGE = "Checks in bundle {0} has no description files:\n- {1}"; + + private static final List LANGUAGE_CODES = List.of("", "ru"); + + private static final String PROJECT_NAME = "CastToMaxNumber"; + + @Test + public void testCheckDefaultDescriptionExist() throws Exception + { + Set checks = checkRepository.getChecksWithDescriptions() + .entrySet() + .stream() + .filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId())) + .map(Entry::getKey) + .collect(Collectors.toSet()); + + assertFalse(checks.isEmpty()); + + Collection notFound = new ArrayList<>(); + Class bundleClass = CorePlugin.getDefault().getClass(); + + for (CheckUid check : checks) + { + for (String languageCode : LANGUAGE_CODES) + { + String langFolder = languageCode.isEmpty() ? "" : languageCode + "/"; + String path = HTML_PATH_PREFIX + langFolder + check.getCheckId() + HTML_DESCRIPTION_EXT; + String mdPath = MD_PATH_PREFIX + langFolder + check.getCheckId() + MD_DESCRIPTION_EXT; + + if (bundleClass.getResource(path) == null && bundleClass.getResource(mdPath) == null) + { + notFound.add(PLUGIN_ID + mdPath); + } + } + } + + assertTrue(MessageFormat.format(MESSAGE, PLUGIN_ID, String.join("\n- ", notFound)), notFound.isEmpty()); + } + + @Override + protected String getTestConfigurationName() + { + // The project is need to initialize check repository + return PROJECT_NAME; + } + + @Override + protected boolean enableCleanUp() + { + return true; + } +} diff --git a/tests/com.e1c.v8codestyle.right.itests/src/com/e1c/v8codestyle/right/check/itests/CheckDescriptionTest.java b/tests/com.e1c.v8codestyle.right.itests/src/com/e1c/v8codestyle/right/check/itests/CheckDescriptionTest.java new file mode 100644 index 00000000..7c9c9b6e --- /dev/null +++ b/tests/com.e1c.v8codestyle.right.itests/src/com/e1c/v8codestyle/right/check/itests/CheckDescriptionTest.java @@ -0,0 +1,92 @@ +/** + * + */ +package com.e1c.v8codestyle.right.check.itests; + +import static com.e1c.v8codestyle.internal.right.CorePlugin.PLUGIN_ID; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; + +import com.e1c.g5.v8.dt.check.settings.CheckUid; +import com.e1c.g5.v8.dt.testing.check.SingleProjectReadOnlyCheckTestBase; +import com.e1c.v8codestyle.internal.right.CorePlugin; + +/** + * The test of existing all markdown description for every check of the bundle. + * Note! That maven tycho run test only for HTML files which creates from markdown. + * + * @author Dmitriy Marmyshev + */ +public class CheckDescriptionTest + extends SingleProjectReadOnlyCheckTestBase +{ + private static final String HTML_PATH_PREFIX = "/check.descriptions/"; + + private static final String MD_PATH_PREFIX = "/markdown/"; + + private static final String HTML_DESCRIPTION_EXT = ".html"; + + private static final String MD_DESCRIPTION_EXT = ".md"; + + private static final String MESSAGE = "Checks in bundle {0} has no description files:\n- {1}"; + + private static final List LANGUAGE_CODES = List.of("", "ru"); + + private static final String PROJECT_NAME = "RoleRightHasRls"; + + @Test + public void testCheckDefaultDescriptionExist() throws Exception + { + Set checks = checkRepository.getChecksWithDescriptions() + .entrySet() + .stream() + .filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId())) + .map(Entry::getKey) + .collect(Collectors.toSet()); + + assertFalse(checks.isEmpty()); + + Collection notFound = new ArrayList<>(); + Class bundleClass = CorePlugin.getDefault().getClass(); + + for (CheckUid check : checks) + { + for (String languageCode : LANGUAGE_CODES) + { + String langFolder = languageCode.isEmpty() ? "" : languageCode + "/"; + String path = HTML_PATH_PREFIX + langFolder + check.getCheckId() + HTML_DESCRIPTION_EXT; + String mdPath = MD_PATH_PREFIX + langFolder + check.getCheckId() + MD_DESCRIPTION_EXT; + + if (bundleClass.getResource(path) == null && bundleClass.getResource(mdPath) == null) + { + notFound.add(PLUGIN_ID + mdPath); + } + } + } + + assertTrue(MessageFormat.format(MESSAGE, PLUGIN_ID, String.join("\n- ", notFound)), notFound.isEmpty()); + } + + @Override + protected String getTestConfigurationName() + { + // The project is need to initialize check repository + return PROJECT_NAME; + } + + @Override + protected boolean enableCleanUp() + { + return true; + } +}