Skip to content

Commit

Permalink
1071: Ложное срабатывание проверки: У реквизита "Ссылка" динамического
Browse files Browse the repository at this point in the history
списка выключен признак "Использовать всегда"
  • Loading branch information
vadimeg committed Jul 26, 2022
1 parent f4af383 commit e5912f3
Show file tree
Hide file tree
Showing 8 changed files with 1,321 additions and 112 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
- Ложное срабатывание проверки: statement-type-change для типов общего модуля #994
- Некорректное сообщение об ошибке в строгих типах. Не существует типа "Таблица" #1055
- Ложное сообщение об ошибке о неиспользовании составных типов для стандартных объектов метаданных #1069
- Ложное срабатывание проверки для динамических списков с произвольным запросом: У реквизита "Ссылка" динамического списка выключен признак "Использовать всегда" #1071

## 0.2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public class FormListRefUseAlwaysFlagDisabledCheck
extends BasicCheck
{
private static final String CHECK_ID = "form-list-ref-use-always-flag-disabled"; //$NON-NLS-1$
private static final List<String> REF_ABSTRACT_DATA_PATH = List.of("Ref", "Список"); //$NON-NLS-1$ //$NON-NLS-2$
private static final List<String> REF_SEGMENT = List.of("Ref", "Ссылка"); //$NON-NLS-1$ //$NON-NLS-2$

private static final Predicate<? super DbViewFieldDef> NAME_CHECK =
name -> name.getName().equals(REF_ABSTRACT_DATA_PATH.get(0));
name -> name.getName().equals(REF_SEGMENT.get(0));

private static Predicate<AbstractDataPath> pathCheck = path -> {
EList<String> segments = path.getSegments();
Expand All @@ -57,8 +57,7 @@ public class FormListRefUseAlwaysFlagDisabledCheck
return false;
}

return segments.get(1).equals(REF_ABSTRACT_DATA_PATH.get(0))
|| segments.get(1).equals(REF_ABSTRACT_DATA_PATH.get(1));
return segments.get(1).equals(REF_SEGMENT.get(0)) || segments.get(1).equals(REF_SEGMENT.get(1));
};

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
*******************************************************************************/
package com.e1c.v8codestyle.form.check.itests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.eclipse.core.runtime.IProgressMonitor;
import org.junit.Test;

Expand Down Expand Up @@ -46,12 +47,13 @@ public class FormListRefUseAlwaysFlagDisabledCheckTest
private static final String CHECK_ID = "form-list-ref-use-always-flag-disabled";
private static final String PROJECT_NAME = "FormListRefUseAlwaysFlagDisabled";
private static final String FQN_FORM_EN = "Catalog.TestCatalog.Form.TestListForm.Form";
private static final String FQN_FORM_CUSTOM_EN = "Catalog.TestCatalog.Form.TestCustomListForm.Form";
private static final String FQN_FORM_RU = "Catalog.TestCatalog.Form.TestListFormRu.Form";
private static final String FQN_FORM_CUSTOM_RU = "Catalog.TestCatalog.Form.TestCustomListFormRu.Form";
private static final String FQN_NON_OBJECT = "InformationRegister.TestInformationRegister.Form.TestListForm.Form";


/**
* Test Use Always flag is disabled for the Reference attribute in dynamic list (En variant).
* Test Use Always flag is disabled for the Reference attribute in dynamic list.
*
* @throws Exception the exception
*/
Expand All @@ -61,18 +63,20 @@ public void testUseAlwaysDisabledForRef() throws Exception
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_EN, dtProject);
assertTrue(object instanceof Form);
List.of(FQN_FORM_EN, FQN_FORM_CUSTOM_EN, FQN_FORM_RU, FQN_FORM_CUSTOM_RU).forEach(formFqn -> {
IBmObject object = getTopObjectByFqn(formFqn, dtProject);
assertTrue(object instanceof Form);

Form form = (Form)object;
assertTrue(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());
Form form = (Form)object;
assertTrue(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
});
}

/**
* Test Use Always flag is enabled for the Reference attribute in dynamic list (En variant).
* Test Use Always flag is enabled for the Reference attribute in dynamic list.
*
* @throws Exception the exception
*/
Expand All @@ -83,85 +87,31 @@ public void testUseAlwaysEnabledForRef() throws Exception
assertNotNull(dtProject);

IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change mode")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM_EN);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
AbstractDataPath path = (DataPath)table.getItems().get(0).eContents().get(1);
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().add(path);
assertFalse(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());
return null;
}
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_EN, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNull(marker);
}

/**
* Test Use Always flag is disabled for the Reference attribute in dynamic list (Ru variant).
*
* @throws Exception the exception
*/
@Test
public void testUseAlwaysDisabledForRefRu() throws Exception
{
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_RU, dtProject);
assertTrue(object instanceof Form);

Form form = (Form)object;
assertTrue(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
}

/**
* Test Use Always flag is enabled for the Reference attribute in dynamic list (Ru variant).
*
* @throws Exception the exception
*/
@Test
public void testUseAlwaysEnabledForRefRu() throws Exception
{
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);

IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change mode")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
List.of(FQN_FORM_EN, FQN_FORM_CUSTOM_EN, FQN_FORM_RU, FQN_FORM_CUSTOM_RU).forEach(formFqn -> {
model.execute(new AbstractBmTask<Void>("change mode")
{
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM_RU);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
AbstractDataPath path = (DataPath)table.getItems().get(0).eContents().get(1);
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().add(path);
assertFalse(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());
return null;
}
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
Form form = (Form)transaction.getTopObjectByFqn(formFqn);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
AbstractDataPath path = (DataPath)table.getItems().get(0).eContents().get(1);
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().add(path);
assertFalse(form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().isEmpty());
return null;
}
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(formFqn, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNull(marker);
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_RU, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNull(marker);
}

/**
Expand Down Expand Up @@ -197,29 +147,32 @@ public void testUseAlwaysEnabledForAttributeWithNonStandardDataPath() throws Exc
assertNotNull(dtProject);

IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change mode")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)

List.of(FQN_FORM_RU, FQN_FORM_CUSTOM_RU).forEach(formFqn -> {
model.execute(new AbstractBmTask<Void>("change mode")
{
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM_EN);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
AbstractDataPath path = (DataPath)table.getItems().get(0).eContents().get(1);
path.getSegments().add(0, "SomeExtraSegment");
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().add(path);
assertEquals("/SomeExtraSegment/List/Ref",
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().get(0).toString());
return null;
}
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
Form form = (Form)transaction.getTopObjectByFqn(formFqn);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
AbstractDataPath path = (DataPath)table.getItems().get(0).eContents().get(1);
path.getSegments().add(0, "SomeExtraSegment");
form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().add(path);
String fqn = form.getAttributes().get(0).getNotDefaultUseAlwaysAttributes().get(0).toString();
assertTrue(fqn.equals("/SomeExtraSegment/List/Ref") || fqn.equals("/SomeExtraSegment/Список/Ref"));
return null;
}
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(formFqn, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_EN, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Settings xmlns="http://v8.1c.ru/8.1/data-composition-system/settings" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:v8="http://v8.1c.ru/8.1/data/core" xmlns:v8ui="http://v8.1c.ru/8.1/data/ui" xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows" xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core">
<filter>
<viewMode>Normal</viewMode>
<userSettingID>5b8df703-aa76-49b5-9df8-b98ce3915698</userSettingID>
</filter>
<order>
<viewMode>Normal</viewMode>
<userSettingID>251d7356-8af3-4d63-8006-801adca5fa31</userSettingID>
</order>
<conditionalAppearance>
<viewMode>Normal</viewMode>
<userSettingID>443cbe90-2a6a-4955-9899-78c80f24cc24</userSettingID>
</conditionalAppearance>
<itemsViewMode>Normal</itemsViewMode>
<itemsUserSettingID>2884db82-c045-4ce4-b91f-ff27564759be</itemsUserSettingID>
</Settings>
Loading

0 comments on commit e5912f3

Please sign in to comment.