23
23
24
24
import com .github ._1c_syntax .bsl .languageserver .util .TestUtils ;
25
25
import com .github ._1c_syntax .bsl .mdclasses .CF ;
26
+ import com .github ._1c_syntax .bsl .mdo .Form ;
26
27
import com .github ._1c_syntax .utils .Absolute ;
27
28
import org .eclipse .lsp4j .Diagnostic ;
28
29
import org .junit .jupiter .api .BeforeEach ;
29
- import org .junit .jupiter .api .Disabled ;
30
30
import org .junit .jupiter .api .Test ;
31
31
import org .springframework .test .annotation .DirtiesContext ;
32
32
33
33
import java .nio .file .Paths ;
34
+ import java .util .Collections ;
34
35
import java .util .List ;
35
36
36
37
import static com .github ._1c_syntax .bsl .languageserver .util .Assertions .assertThat ;
@@ -55,16 +56,14 @@ void setUp() {
55
56
}
56
57
57
58
@ Test
58
- @ Disabled
59
59
void testNoFormModule () {
60
60
61
61
final var pathToManagedApplicationModuleFile = "/Ext/ManagedApplicationModule.bsl" ;
62
62
63
63
context = spy (context );
64
64
final var configuration = spy (context .getConfiguration ());
65
- when (context .getConfiguration ()).thenReturn (configuration );
66
-
67
65
fillConfigChildrenByFormsWithoutModule (configuration );
66
+ when (context .getConfiguration ()).thenReturn (configuration );
68
67
69
68
List <Diagnostic > diagnostics = getDiagnosticListForMockedFile (pathToManagedApplicationModuleFile );
70
69
@@ -76,7 +75,6 @@ void testNoFormModule() {
76
75
}
77
76
78
77
@ Test
79
- @ Disabled
80
78
void testFormModule () {
81
79
82
80
List <Diagnostic > diagnostics = getDiagnosticListForMockedFile (PATH_TO_ELEMENT_MODULE_FILE );
@@ -88,7 +86,6 @@ void testFormModule() {
88
86
}
89
87
90
88
@ Test
91
- @ Disabled
92
89
void testDynamicListFormModule () {
93
90
94
91
final var pathToDynamicListModuleFile = "/Catalogs/Справочник1/Forms/ФормаВыбора/Ext/Form/Module.bsl" ;
@@ -101,20 +98,23 @@ void testDynamicListFormModule() {
101
98
}
102
99
103
100
private void fillConfigChildrenByFormsWithoutModule (CF configuration ) {
104
- // final var childrenByMdoRefFromConfig = configuration.getChildrenByMdoRef();
105
- // var childrenByMdoRef = childrenByMdoRefFromConfig.entrySet().stream()
106
- // .filter(entry -> entry.getValue() instanceof Form)
107
- // .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
108
- // ((Form) entry.getValue()).setModules(Collections.emptyList());
109
- // return entry.getValue();
110
- // }));
111
- // when(configuration.getChildrenByMdoRef()).thenReturn(childrenByMdoRef);
101
+ var plainChildren = configuration .getPlainChildren ().stream ()
102
+ .filter (md -> md instanceof Form )
103
+ .map (md -> {
104
+ var mockMD = spy (md );
105
+ when (((Form ) mockMD ).getModules ()).thenReturn (Collections .emptyList ());
106
+ return mockMD ;
107
+ })
108
+ .toList ();
109
+
110
+ when (configuration .getPlainChildren ()).thenReturn (plainChildren );
112
111
}
113
112
114
113
private List <Diagnostic > getDiagnosticListForMockedFile (String pathToDynamicListModuleFile ) {
115
114
var testFile = Paths .get (PATH_TO_METADATA + pathToDynamicListModuleFile ).toAbsolutePath ();
116
115
117
- var documentContext = TestUtils .getDocumentContext (testFile .toUri (), getText ());
116
+ var documentContext = spy (TestUtils .getDocumentContext (testFile .toUri (), getText ()));
117
+ when (documentContext .getServerContext ()).thenReturn (context );
118
118
119
119
return getDiagnostics (documentContext );
120
120
}
0 commit comments