mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2024-12-01 10:41:05 +02:00
Merge pull request #1046 from 1C-Company/feature/867-test-markdown-exist
#867 Добавлен тест наличия описаний проверок в Markdown
This commit is contained in:
commit
c6ca984efc
@ -0,0 +1,11 @@
|
||||
# Empty method check
|
||||
|
||||
Empty module method check
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
|
||||
## See
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Unused local variable check
|
||||
|
||||
Unused module local variable check
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
|
||||
## See
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Unused method check
|
||||
|
||||
Unused module method check
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
|
||||
## See
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Проверка пустых методов
|
||||
|
||||
Проверка модуля на наличие пустых методов
|
||||
|
||||
## Неправильно
|
||||
|
||||
## Правильно
|
||||
|
||||
## См.
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Проверка неиспользуемых локальных переменных
|
||||
|
||||
Проверка модуля на наличие неиспользуемых локальных переменных
|
||||
|
||||
## Неправильно
|
||||
|
||||
## Правильно
|
||||
|
||||
## См.
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Проверка неиспользуемых методов
|
||||
|
||||
Проверка модуля на наличие неиспользуемых методов
|
||||
|
||||
## Неправильно
|
||||
|
||||
## Правильно
|
||||
|
||||
## См.
|
||||
|
@ -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$
|
||||
|
||||
|
@ -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<String> LANGUAGE_CODES = List.of("", "ru");
|
||||
|
||||
private static final String PROJECT_NAME = "CommonModule";
|
||||
|
||||
@Test
|
||||
public void testCheckDefaultDescriptionExist() throws Exception
|
||||
{
|
||||
Set<CheckUid> checks = checkRepository.getChecksWithDescriptions()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId()))
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(checks.isEmpty());
|
||||
|
||||
Collection<String> 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;
|
||||
}
|
||||
}
|
@ -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<String> LANGUAGE_CODES = List.of("", "ru");
|
||||
|
||||
private static final String PROJECT_NAME = "InputFieldListChoiceMode";
|
||||
|
||||
@Test
|
||||
public void testCheckDefaultDescriptionExist() throws Exception
|
||||
{
|
||||
Set<CheckUid> checks = checkRepository.getChecksWithDescriptions()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId()))
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(checks.isEmpty());
|
||||
|
||||
Collection<String> 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;
|
||||
}
|
||||
}
|
@ -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<String> LANGUAGE_CODES = List.of("", "ru");
|
||||
|
||||
private static final String PROJECT_NAME = "CommonModuleName";
|
||||
|
||||
@Test
|
||||
public void testCheckDefaultDescriptionExist() throws Exception
|
||||
{
|
||||
Set<CheckUid> checks = checkRepository.getChecksWithDescriptions()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId()))
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(checks.isEmpty());
|
||||
|
||||
Collection<String> 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;
|
||||
}
|
||||
}
|
@ -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<DailySchedule> 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<DailySchedule> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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<String> LANGUAGE_CODES = List.of("", "ru");
|
||||
|
||||
private static final String PROJECT_NAME = "CastToMaxNumber";
|
||||
|
||||
@Test
|
||||
public void testCheckDefaultDescriptionExist() throws Exception
|
||||
{
|
||||
Set<CheckUid> checks = checkRepository.getChecksWithDescriptions()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId()))
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(checks.isEmpty());
|
||||
|
||||
Collection<String> 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;
|
||||
}
|
||||
}
|
@ -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<String> LANGUAGE_CODES = List.of("", "ru");
|
||||
|
||||
private static final String PROJECT_NAME = "RoleRightHasRls";
|
||||
|
||||
@Test
|
||||
public void testCheckDefaultDescriptionExist() throws Exception
|
||||
{
|
||||
Set<CheckUid> checks = checkRepository.getChecksWithDescriptions()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> PLUGIN_ID.equals(e.getKey().getContributorId()))
|
||||
.map(Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(checks.isEmpty());
|
||||
|
||||
Collection<String> 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user