Skip to content

Commit 2c454ad

Browse files
committed
Тест, когда у метаданного несколько модулей
1 parent 28a0cdc commit 2c454ad

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnosticTest.java

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.diagnostics;
2323

24+
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
25+
import com.github._1c_syntax.bsl.languageserver.context.ServerContext;
2426
import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod;
2527
import com.github._1c_syntax.bsl.types.MDOType;
2628
import com.github._1c_syntax.bsl.types.MdoReference;
@@ -30,6 +32,7 @@
3032
import com.github._1c_syntax.utils.Absolute;
3133
import org.junit.jupiter.api.Test;
3234

35+
import java.io.File;
3336
import java.util.Collections;
3437
import java.util.Optional;
3538
import java.util.Set;
@@ -45,15 +48,36 @@ class DenyIncompleteValuesDiagnosticTest extends AbstractDiagnosticTest<DenyInco
4548
}
4649

4750
private static final String PATH_TO_METADATA = "src/test/resources/metadata/designer";
51+
private static final String PATH_TO_MANAGER_MODULE_FILE = "InformationRegisters/РегистрСведений1/Ext/ManagerModule.bsl";
52+
private static final String PATH_TO_OBJECT_MODULE_FILE = "InformationRegisters/РегистрСведений1/Ext/RecordSetModule.bsl";
4853

4954
@Test
50-
void testMdoWithModule() {
51-
checkMockHandler(ModuleType.RecordSetModule, false);
55+
void testMdoWithoutModule() {
56+
checkMockHandler(ModuleType.SessionModule, true);
5257
}
5358

5459
@Test
55-
void testMdoWithoutModule() {
56-
checkMockHandler(ModuleType.SessionModule, true);
60+
void testMdoWithOneModule() {
61+
checkMockHandler(ModuleType.ManagerModule, false);
62+
}
63+
64+
@Test
65+
void testMdoWithModules() {
66+
var path = Absolute.path(PATH_TO_METADATA);
67+
context.setConfigurationRoot(path);
68+
69+
var managerDocumentContext = addDocumentContext(context, PATH_TO_MANAGER_MODULE_FILE);
70+
var recordSetDocumentContext = addDocumentContext(context, PATH_TO_OBJECT_MODULE_FILE);
71+
72+
final var diagnostics = getDiagnostics(managerDocumentContext);
73+
74+
assertThat(diagnostics, true)
75+
.hasMessageOnRange("Не указан флаг \"Запрет незаполненных значений\" у измерения \"Справочник1\" метаданного \"РегистрСведений.РегистрСведений1\"",
76+
0, 0, 9)
77+
.hasSize(1);
78+
79+
final var diagnostics2 = getDiagnostics(recordSetDocumentContext);
80+
assertThat(diagnostics2, true).isEmpty();
5781
}
5882

5983
private void checkMockHandler(ModuleType type, boolean noneModules) {
@@ -88,4 +112,12 @@ private void checkMockHandler(ModuleType type, boolean noneModules) {
88112
0, 0, 9)
89113
.hasSize(1);
90114
}
115+
116+
private DocumentContext addDocumentContext(ServerContext serverContext, String path) {
117+
var file = new File(PATH_TO_METADATA, path);
118+
var uri = Absolute.uri(file);
119+
var documentContext = serverContext.addDocument(uri);
120+
serverContext.rebuildDocument(documentContext);
121+
return documentContext;
122+
}
91123
}

0 commit comments

Comments
 (0)