Search in sources :

Example 1 with CompatibilityMode

use of com.github._1c_syntax.mdclasses.common.CompatibilityMode in project mdclasses by 1c-syntax.

the class ConfigurationTest method testDesignerExt2.

@Test
void testDesignerExt2() {
    File srcPath = new File("src/test/resources/metadata/original_ext2");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isInstanceOf(ConfigurationExtension.class);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.DESIGNER);
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("Русский");
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getObjectAutonumerationMode()).isEmpty();
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(((ConfigurationExtension) configuration).getConfigurationExtensionPurpose()).isEqualTo(ConfigurationExtensionPurpose.ADD_ON);
    assertThat(((ConfigurationExtension) configuration).getNamePrefix()).isEqualTo("Расш1_");
    assertThat(configuration.getModulesByType()).hasSize(2);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModules()).hasSize(2);
    assertThat(configuration.getRoles()).isEmpty();
    assertThat(configuration.getChildren()).hasSize(5);
    checkChildCount(configuration, MDOType.CONFIGURATION, 1);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 1);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(5);
    assertThat(configuration.getCommonModule("ПростойОбщийМодуль")).isPresent();
    assertThat(configuration.getCommonModule("НесуществующийМодуль")).isNotPresent();
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.ADOPTED).hasSize(4);
    assertThat(configuration.getChildren()).filteredOn(mdObjectBase -> mdObjectBase.getObjectBelonging() == ObjectBelonging.OWN).hasSize(1);
}
Also used : ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) ScriptVariant(com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AbstractMDObjectBase(com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase) MDOType(com.github._1c_syntax.mdclasses.mdo.support.MDOType) ConfigurationExtensionPurpose(com.github._1c_syntax.mdclasses.mdo.support.ConfigurationExtensionPurpose) Absolute(com.github._1c_syntax.utils.Absolute) Configuration(com.github._1c_syntax.mdclasses.Configuration) ConfigurationSource(com.github._1c_syntax.mdclasses.common.ConfigurationSource) Form(com.github._1c_syntax.mdclasses.mdo.children.Form) Path(java.nio.file.Path) FormType(com.github._1c_syntax.mdclasses.mdo.support.FormType) DataLockControlMode(com.github._1c_syntax.mdclasses.mdo.support.DataLockControlMode) ApplicationRunMode(com.github._1c_syntax.mdclasses.mdo.support.ApplicationRunMode) AbstractMDOForm(com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm) Set(java.util.Set) ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) Collectors(java.util.stream.Collectors) MDCommonForm(com.github._1c_syntax.mdclasses.mdo.MDCommonForm) File(java.io.File) Test(org.junit.jupiter.api.Test) ObjectBelonging(com.github._1c_syntax.mdclasses.mdo.support.ObjectBelonging) Paths(java.nio.file.Paths) UseMode(com.github._1c_syntax.mdclasses.mdo.support.UseMode) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Configuration(com.github._1c_syntax.mdclasses.Configuration) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with CompatibilityMode

use of com.github._1c_syntax.mdclasses.common.CompatibilityMode in project mdclasses by 1c-syntax.

the class ConfigurationTest method testEDTEn.

@Test
void testEDTEn() {
    File srcPath = new File("src/test/resources/metadata/edt_en");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isNotInstanceOf(ConfigurationExtension.class);
    assertThat(configuration.getName()).isEqualTo("Configuration");
    assertThat(configuration.getUuid()).isEqualTo("04c0322d-92da-49ab-87e5-82c8dcd50888");
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.EDT);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 14))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 14))).isZero();
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.ENGLISH);
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("English");
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC_AND_MANAGED);
    assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getModulesByType()).hasSize(2);
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModulesByObject()).hasSize(2);
    assertThat(configuration.getModules()).hasSize(2);
    assertThat(configuration.getCommonModules()).hasSize(2);
    assertThat(configuration.getLanguages()).hasSize(1);
    assertThat(configuration.getRoles()).isEmpty();
    assertThat(configuration.getChildren()).hasSize(4);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(4);
    assertThat(configuration.getCommonModule("CommonModule")).isPresent();
    assertThat(configuration.getCommonModule("CommonModule3")).isNotPresent();
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with CompatibilityMode

use of com.github._1c_syntax.mdclasses.common.CompatibilityMode in project mdclasses by 1c-syntax.

the class ConfigurationTest method testDesigner.

@Test
void testDesigner() {
    File srcPath = new File("src/test/resources/metadata/original");
    Configuration configuration = Configuration.create(srcPath.toPath());
    assertThat(configuration).isNotInstanceOf(ConfigurationExtension.class);
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(configuration.getConfigurationSource()).isEqualTo(ConfigurationSource.DESIGNER);
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
    assertThat(configuration.getDefaultLanguage().getName()).isEqualTo("Русский");
    assertThat(configuration.getDefaultRunMode()).isEqualTo(ApplicationRunMode.MANAGED_APPLICATION);
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.isUseManagedFormInOrdinaryApplication()).isTrue();
    assertThat(configuration.isUseOrdinaryFormInManagedApplication()).isFalse();
    assertThat(configuration.getModulesByType()).hasSize(18);
    assertThat(configuration.getCopyrights()).hasSize(2).anyMatch(copyright -> copyright.getContent().equals("Моя Программа") && copyright.getLanguage().equals("ru")).anyMatch(copyright -> copyright.getContent().equals("My program") && copyright.getLanguage().equals("en"));
    assertThat(configuration.getBriefInformation()).hasSize(2).anyMatch(briefInfo -> briefInfo.getLanguage().equals("ru") && briefInfo.getContent().equals("Краткая информация")).anyMatch(briefInfo -> briefInfo.getLanguage().equals("en") && briefInfo.getContent().equals("Short info"));
    assertThat(configuration.getDetailedInformation()).hasSize(2).anyMatch(briefInfo -> briefInfo.getLanguage().equals("ru") && briefInfo.getContent().equals("Подробная информация")).anyMatch(briefInfo -> briefInfo.getLanguage().equals("en") && briefInfo.getContent().equals("Detailed info"));
    assertThat(configuration.getModulesBySupport()).isEmpty();
    assertThat(configuration.getModulesByObject()).hasSize(18);
    assertThat(configuration.getModules()).hasSize(18);
    assertThat(configuration.getCommonModules()).hasSize(6);
    assertThat(configuration.getLanguages()).hasSize(3);
    assertThat(configuration.getRoles()).hasSize(1);
    assertThat(configuration.getChildren()).hasSize(112);
    checkChildCount(configuration, MDOType.CONFIGURATION, 1);
    checkChildCount(configuration, MDOType.COMMAND, 1);
    checkChildCount(configuration, MDOType.FORM, 8);
    checkChildCount(configuration, MDOType.TEMPLATE, 2);
    checkChildCount(configuration, MDOType.ATTRIBUTE, 34);
    checkChildCount(configuration, MDOType.WS_OPERATION, 2);
    checkChildCount(configuration, MDOType.HTTP_SERVICE_URL_TEMPLATE, 1);
    checkChildCount(configuration, MDOType.HTTP_SERVICE_METHOD, 2);
    checkChildCount(configuration, MDOType.ACCOUNTING_REGISTER, 1);
    checkChildCount(configuration, MDOType.ACCUMULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.BUSINESS_PROCESS, 1);
    checkChildCount(configuration, MDOType.CALCULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.CATALOG, 1);
    checkChildCount(configuration, MDOType.CHART_OF_ACCOUNTS, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CALCULATION_TYPES, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CHARACTERISTIC_TYPES, 1);
    checkChildCount(configuration, MDOType.COMMAND_GROUP, 1);
    checkChildCount(configuration, MDOType.COMMON_ATTRIBUTE, 1);
    checkChildCount(configuration, MDOType.COMMON_COMMAND, 1);
    checkChildCount(configuration, MDOType.COMMON_FORM, 1);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 6);
    checkChildCount(configuration, MDOType.COMMON_PICTURE, 1);
    checkChildCount(configuration, MDOType.COMMON_TEMPLATE, 10);
    checkChildCount(configuration, MDOType.CONSTANT, 1);
    checkChildCount(configuration, MDOType.DATA_PROCESSOR, 1);
    checkChildCount(configuration, MDOType.DEFINED_TYPE, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_JOURNAL, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_NUMERATOR, 1);
    checkChildCount(configuration, MDOType.DOCUMENT, 1);
    checkChildCount(configuration, MDOType.ENUM, 1);
    checkChildCount(configuration, MDOType.EVENT_SUBSCRIPTION, 1);
    checkChildCount(configuration, MDOType.EXCHANGE_PLAN, 1);
    checkChildCount(configuration, MDOType.FILTER_CRITERION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTIONS_PARAMETER, 1);
    checkChildCount(configuration, MDOType.HTTP_SERVICE, 1);
    checkChildCount(configuration, MDOType.INFORMATION_REGISTER, 2);
    checkChildCount(configuration, MDOType.INTERFACE, 1);
    checkChildCount(configuration, MDOType.LANGUAGE, 3);
    checkChildCount(configuration, MDOType.REPORT, 1);
    checkChildCount(configuration, MDOType.ROLE, 1);
    checkChildCount(configuration, MDOType.SCHEDULED_JOB, 1);
    checkChildCount(configuration, MDOType.SEQUENCE, 1);
    checkChildCount(configuration, MDOType.SESSION_PARAMETER, 1);
    checkChildCount(configuration, MDOType.SETTINGS_STORAGE, 1);
    checkChildCount(configuration, MDOType.STYLE_ITEM, 1);
    checkChildCount(configuration, MDOType.STYLE, 1);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 1);
    checkChildCount(configuration, MDOType.TASK, 1);
    checkChildCount(configuration, MDOType.WEB_SERVICE, 1);
    checkChildCount(configuration, MDOType.WS_REFERENCE, 1);
    checkChildCount(configuration, MDOType.XDTO_PACKAGE, 1);
    assertThat(configuration.getChildrenByMdoRef()).hasSize(111);
    assertThat(configuration.getCommonModule("ГлобальныйОбщийМодуль")).isPresent();
    assertThat(configuration.getCommonModule("ГлобальныйОбщийМодуль3")).isNotPresent();
    checkFillPath(configuration.getChildren());
    checkFormData(configuration.getChildren());
    var modulesByType = configuration.getModulesByMDORef("CommonModule.ГлобальныйОбщийМодуль");
    assertThat(modulesByType).hasSize(1).containsKey(ModuleType.CommonModule);
    modulesByType = configuration.getModulesByMDORef("WSReference.WSСсылка");
    assertThat(modulesByType).isEmpty();
    modulesByType = configuration.getModulesByMDORef(configuration.getCommonModule("ГлобальныйОбщийМодуль").get().getMdoReference());
    assertThat(modulesByType).hasSize(1).containsKey(ModuleType.CommonModule);
}
Also used : ScriptVariant(com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AbstractMDObjectBase(com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase) MDOType(com.github._1c_syntax.mdclasses.mdo.support.MDOType) ConfigurationExtensionPurpose(com.github._1c_syntax.mdclasses.mdo.support.ConfigurationExtensionPurpose) Absolute(com.github._1c_syntax.utils.Absolute) Configuration(com.github._1c_syntax.mdclasses.Configuration) ConfigurationSource(com.github._1c_syntax.mdclasses.common.ConfigurationSource) Form(com.github._1c_syntax.mdclasses.mdo.children.Form) Path(java.nio.file.Path) FormType(com.github._1c_syntax.mdclasses.mdo.support.FormType) DataLockControlMode(com.github._1c_syntax.mdclasses.mdo.support.DataLockControlMode) ApplicationRunMode(com.github._1c_syntax.mdclasses.mdo.support.ApplicationRunMode) AbstractMDOForm(com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm) Set(java.util.Set) ConfigurationExtension(com.github._1c_syntax.mdclasses.ConfigurationExtension) ModuleType(com.github._1c_syntax.mdclasses.mdo.support.ModuleType) Collectors(java.util.stream.Collectors) MDCommonForm(com.github._1c_syntax.mdclasses.mdo.MDCommonForm) File(java.io.File) Test(org.junit.jupiter.api.Test) ObjectBelonging(com.github._1c_syntax.mdclasses.mdo.support.ObjectBelonging) Paths(java.nio.file.Paths) UseMode(com.github._1c_syntax.mdclasses.mdo.support.UseMode) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Configuration(com.github._1c_syntax.mdclasses.Configuration) CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with CompatibilityMode

use of com.github._1c_syntax.mdclasses.common.CompatibilityMode in project mdclasses by 1c-syntax.

the class MDConfigurationTest method testEDT.

@Override
@Test
void testEDT() {
    var mdo = getMDObjectEDT("Configuration/Configuration.mdo");
    checkBaseField(mdo, MDConfiguration.class, "Конфигурация", "46c7c1d0-b04d-4295-9b04-ae3207c18d29");
    checkNoChildren(mdo);
    checkModules(((AbstractMDObjectBSL) mdo).getModules(), 3, "Configuration", ModuleType.SessionModule, ModuleType.ExternalConnectionModule, ModuleType.ManagedApplicationModule);
    var configuration = (MDConfiguration) mdo;
    assertThat(CompatibilityMode.compareTo(configuration.getCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(CompatibilityMode.compareTo(configuration.getConfigurationExtensionCompatibilityMode(), new CompatibilityMode(3, 10))).isZero();
    assertThat(configuration.getDataLockControlMode()).isEqualTo(DataLockControlMode.AUTOMATIC);
    assertThat(configuration.getDefaultLanguage().isRight()).isTrue();
    assertThat(configuration.getDefaultLanguage().get().getName()).isEqualTo("Русский");
    assertThat(configuration.getDefaultRunMode()).isEqualTo("ManagedApplication");
    assertThat(configuration.getModalityUseMode()).isEqualTo(UseMode.USE);
    assertThat(configuration.getObjectAutonumerationMode()).isEqualTo("NotAutoFree");
    assertThat(configuration.getScriptVariant()).isEqualTo(ScriptVariant.RUSSIAN);
    assertThat(configuration.getSynchronousExtensionAndAddInCallUseMode()).isEqualTo(UseMode.USE_WITH_WARNINGS);
    assertThat(configuration.getSynchronousPlatformExtensionAndAddInCallUseMode()).isEqualTo(UseMode.DONT_USE);
    assertThat(configuration.getConfigurationExtensionPurpose()).isEqualTo(ConfigurationExtensionPurpose.PATCH);
    assertThat(configuration.getObjectBelonging()).isEqualTo(ObjectBelonging.OWN);
    assertThat(configuration.getNamePrefix()).isEmpty();
    assertThat(configuration.getChildren()).hasSize(61).allMatch(Either::isRight);
    checkChildCount(configuration, MDOType.ACCOUNTING_REGISTER, 1);
    checkChildCount(configuration, MDOType.ACCUMULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.BUSINESS_PROCESS, 1);
    checkChildCount(configuration, MDOType.CALCULATION_REGISTER, 1);
    checkChildCount(configuration, MDOType.CATALOG, 1);
    checkChildCount(configuration, MDOType.CHART_OF_ACCOUNTS, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CALCULATION_TYPES, 1);
    checkChildCount(configuration, MDOType.CHART_OF_CHARACTERISTIC_TYPES, 1);
    checkChildCount(configuration, MDOType.COMMAND_GROUP, 1);
    checkChildCount(configuration, MDOType.COMMON_ATTRIBUTE, 1);
    checkChildCount(configuration, MDOType.COMMON_COMMAND, 1);
    checkChildCount(configuration, MDOType.COMMON_FORM, 1);
    checkChildCount(configuration, MDOType.COMMON_MODULE, 6);
    checkChildCount(configuration, MDOType.COMMON_PICTURE, 1);
    checkChildCount(configuration, MDOType.COMMON_TEMPLATE, 10);
    checkChildCount(configuration, MDOType.CONSTANT, 1);
    checkChildCount(configuration, MDOType.DATA_PROCESSOR, 1);
    checkChildCount(configuration, MDOType.DEFINED_TYPE, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_JOURNAL, 1);
    checkChildCount(configuration, MDOType.DOCUMENT_NUMERATOR, 1);
    checkChildCount(configuration, MDOType.DOCUMENT, 1);
    checkChildCount(configuration, MDOType.ENUM, 1);
    checkChildCount(configuration, MDOType.EVENT_SUBSCRIPTION, 1);
    checkChildCount(configuration, MDOType.EXCHANGE_PLAN, 1);
    checkChildCount(configuration, MDOType.FILTER_CRITERION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTION, 1);
    checkChildCount(configuration, MDOType.FUNCTIONAL_OPTIONS_PARAMETER, 1);
    checkChildCount(configuration, MDOType.HTTP_SERVICE, 1);
    checkChildCount(configuration, MDOType.INFORMATION_REGISTER, 2);
    checkChildCount(configuration, MDOType.LANGUAGE, 3);
    checkChildCount(configuration, MDOType.REPORT, 1);
    checkChildCount(configuration, MDOType.ROLE, 1);
    checkChildCount(configuration, MDOType.SCHEDULED_JOB, 1);
    checkChildCount(configuration, MDOType.SEQUENCE, 1);
    checkChildCount(configuration, MDOType.SESSION_PARAMETER, 1);
    checkChildCount(configuration, MDOType.SETTINGS_STORAGE, 1);
    checkChildCount(configuration, MDOType.STYLE_ITEM, 1);
    checkChildCount(configuration, MDOType.STYLE, 1);
    checkChildCount(configuration, MDOType.SUBSYSTEM, 2);
    checkChildCount(configuration, MDOType.TASK, 1);
    checkChildCount(configuration, MDOType.WEB_SERVICE, 1);
    checkChildCount(configuration, MDOType.WS_REFERENCE, 1);
    checkChildCount(configuration, MDOType.XDTO_PACKAGE, 1);
    checkSubsystems(configuration, 5);
    checkCommonAttributes(configuration);
}
Also used : CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Either(io.vavr.control.Either) Test(org.junit.jupiter.api.Test)

Example 5 with CompatibilityMode

use of com.github._1c_syntax.mdclasses.common.CompatibilityMode in project bsl-language-server by 1c-syntax.

the class DiagnosticsTest method testCompatibilityMode.

@Test
void testCompatibilityMode() {
    // given
    documentContext = spy(TestUtils.getDocumentContext(""));
    var serverContext = spy(context);
    var bslConfiguration = spy(serverContext.getConfiguration());
    doReturn(serverContext).when(documentContext).getServerContext();
    doReturn(bslConfiguration).when(serverContext).getConfiguration();
    configuration.getDiagnosticsOptions().setMode(Mode.ON);
    // when-then pairs
    doReturn(new CompatibilityMode(3, 10)).when(bslConfiguration).getCompatibilityMode();
    assertThat(diagnosticsConfiguration.diagnostics(documentContext)).anyMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
    doReturn(new CompatibilityMode(3, 6)).when(bslConfiguration).getCompatibilityMode();
    assertThat(diagnosticsConfiguration.diagnostics(documentContext)).anyMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
    doReturn(new CompatibilityMode(2, 16)).when(bslConfiguration).getCompatibilityMode();
    assertThat(diagnosticsConfiguration.diagnostics(documentContext)).noneMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
}
Also used : CompatibilityMode(com.github._1c_syntax.mdclasses.common.CompatibilityMode) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CompatibilityMode (com.github._1c_syntax.mdclasses.common.CompatibilityMode)13 Test (org.junit.jupiter.api.Test)12 Configuration (com.github._1c_syntax.mdclasses.Configuration)6 ModuleType (com.github._1c_syntax.mdclasses.mdo.support.ModuleType)6 File (java.io.File)6 Collectors (java.util.stream.Collectors)6 ConfigurationExtension (com.github._1c_syntax.mdclasses.ConfigurationExtension)5 ConfigurationSource (com.github._1c_syntax.mdclasses.common.ConfigurationSource)5 AbstractMDOForm (com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm)5 AbstractMDObjectBase (com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase)5 MDCommonForm (com.github._1c_syntax.mdclasses.mdo.MDCommonForm)5 Form (com.github._1c_syntax.mdclasses.mdo.children.Form)5 ApplicationRunMode (com.github._1c_syntax.mdclasses.mdo.support.ApplicationRunMode)5 ConfigurationExtensionPurpose (com.github._1c_syntax.mdclasses.mdo.support.ConfigurationExtensionPurpose)5 DataLockControlMode (com.github._1c_syntax.mdclasses.mdo.support.DataLockControlMode)5 FormType (com.github._1c_syntax.mdclasses.mdo.support.FormType)5 MDOType (com.github._1c_syntax.mdclasses.mdo.support.MDOType)5 ObjectBelonging (com.github._1c_syntax.mdclasses.mdo.support.ObjectBelonging)5 ScriptVariant (com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant)5 UseMode (com.github._1c_syntax.mdclasses.mdo.support.UseMode)5