Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theshadowco committed Mar 19, 2024
1 parent e52e3f0 commit e54a056
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,40 @@ void testFullMdclasses(ArgumentsAccessor argumentsAccessor) {
.isEmpty();
}

@ParameterizedTest
@CsvSource(
{
"false, mdclasses_ext",
}
)
void testFullExt(ArgumentsAccessor argumentsAccessor) {
var mdc = MDTestUtils.readConfiguration(argumentsAccessor, false);
assertThat(mdc).isInstanceOf(ConfigurationExtension.class);
var cf = (ConfigurationExtension) mdc;
assertThat(cf.getSupportVariant()).isEqualTo(SupportVariant.NONE);
assertThat(cf.getModules()).isEmpty();
assertThat(cf.getAllModules())
.hasSize(7 + cf.getCommonModules().size())
.allMatch(module -> module.getSupportVariant().equals(SupportVariant.NONE));

// проверка состава дочерних
checkChildrenExt(cf);

assertThat(cf.getPlainChildren())
.hasSize(147)
.allMatch(md -> md.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getAllModules().stream().filter(Module::isProtected)).isEmpty();

assertThat(cf.getChildren().stream().filter(md -> md instanceof Form form && !form.getData().isEmpty()))
.hasSize(cf.getCommonForms().size());
assertThat(cf.getPlainChildren().stream().filter(md -> md instanceof Form form && !form.getData().isEmpty()))
.hasSize(cf.getCommonForms().size() + 12);
assertThat(cf.getPlainChildren().stream().filter(md -> md instanceof Form form && form.getData().isEmpty()))
.isEmpty();
}


private static void checkChildrenSSL(Configuration cf) {
assertThat(cf.getSubsystems())
.hasSize(3)
Expand Down Expand Up @@ -626,4 +660,212 @@ private static void checkChildrenMdclasses(Configuration cf) {
cf.getExternalDataSources().size());
}

private static void checkChildrenExt(ConfigurationExtension cf) {
assertThat(cf.getSubsystems())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonModules())
.hasSize(9)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getSessionParameters())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getRoles())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonAttributes())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getExchangePlans())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getFilterCriteria())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getEventSubscriptions())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getScheduledJobs())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getBots()).isEmpty();

assertThat(cf.getFunctionalOptions())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getFunctionalOptionsParameters())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getDefinedTypes())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getSettingsStorages())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonForms())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonCommands())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommandGroups())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonTemplates())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCommonPictures())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getInterfaces()).isEmpty();

assertThat(cf.getXDTOPackages())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getWebServices())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getHttpServices())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getWsReferences())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getIntegrationServices()).isEmpty();

assertThat(cf.getStyleItems())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getStyles())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getLanguages())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getConstants())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCatalogs())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getDocuments())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getDocumentNumerators())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getSequences())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getDocumentJournals())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getEnums())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getReports())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getDataProcessors())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getChartsOfCharacteristicTypes())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getChartsOfAccounts())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getChartsOfCalculationTypes())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getInformationRegisters())
.hasSize(4)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getAccumulationRegisters())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getAccountingRegisters())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getCalculationRegisters())
.hasSize(2)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getBusinessProcesses())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getTasks())
.hasSize(1)
.allMatch(mdo -> mdo.getSupportVariant().equals(SupportVariant.NONE));

assertThat(cf.getExternalDataSources()).isEmpty();

assertThat(cf.getChildren()).hasSize(
cf.getSubsystems().size() + cf.getCommonModules().size() +
cf.getSessionParameters().size() + cf.getRoles().size() +
cf.getCommonAttributes().size() + cf.getExchangePlans().size() +
cf.getFilterCriteria().size() + cf.getEventSubscriptions().size() +
cf.getScheduledJobs().size() + cf.getBots().size() +
cf.getFunctionalOptions().size() + cf.getFunctionalOptionsParameters().size() +
cf.getDefinedTypes().size() + cf.getSettingsStorages().size() +
cf.getCommonForms().size() + cf.getCommonCommands().size() +
cf.getCommandGroups().size() + cf.getCommonTemplates().size() +
cf.getCommonPictures().size() + cf.getInterfaces().size() +
cf.getXDTOPackages().size() + cf.getWebServices().size() +
cf.getHttpServices().size() + cf.getWsReferences().size() +
cf.getIntegrationServices().size() + cf.getStyleItems().size() +
cf.getStyles().size() + cf.getLanguages().size() +
cf.getConstants().size() + cf.getCatalogs().size() +
cf.getDocuments().size() + cf.getDocumentNumerators().size() +
cf.getSequences().size() + cf.getDocumentJournals().size() +
cf.getEnums().size() + cf.getReports().size() +
cf.getDataProcessors().size() + cf.getChartsOfCharacteristicTypes().size() +
cf.getChartsOfAccounts().size() + cf.getChartsOfCalculationTypes().size() +
cf.getInformationRegisters().size() + cf.getAccumulationRegisters().size() +
cf.getAccountingRegisters().size() + cf.getCalculationRegisters().size() +
cf.getBusinessProcesses().size() + cf.getTasks().size() +
cf.getExternalDataSources().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,40 @@
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo;

import com.github._1c_syntax.bsl.test_utils.MDTestUtils;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
import org.junit.jupiter.params.provider.CsvSource;

class IntegrationServiceTest {
@ParameterizedTest
@CsvSource(
{
"true, mdclasses_3_18, IntegrationServices.СервисИнтеграции1, _edt",
"false, mdclasses_3_18, IntegrationServices.СервисИнтеграции1"
}
)
void test(ArgumentsAccessor argumentsAccessor) {
var mdo = MDTestUtils.getMDWithSimpleTest(argumentsAccessor);
}

import com.github._1c_syntax.bsl.support.SupportVariant;
import com.github._1c_syntax.bsl.test_utils.MDTestUtils;
import com.github._1c_syntax.bsl.types.MdoReference;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
import org.junit.jupiter.params.provider.CsvSource;

import static org.assertj.core.api.Assertions.assertThat;

class IntegrationServiceTest {
@ParameterizedTest
@CsvSource(
{
"true, mdclasses_3_18, IntegrationServices.СервисИнтеграции1, _edt",
"false, mdclasses_3_18, IntegrationServices.СервисИнтеграции1"
}
)
void test(ArgumentsAccessor argumentsAccessor) {
var mdo = MDTestUtils.getMDWithSimpleTest(argumentsAccessor);
assertThat(mdo).isInstanceOf(IntegrationService.class);
var is = (IntegrationService) mdo;
assertThat(is.getUuid()).isEqualTo("94ed2401-fd3c-4e92-b34d-1cdad2d8ee42");
assertThat(is.getName()).isEqualTo("СервисИнтеграции1");
assertThat(is.getMdoReference()).isEqualTo(MdoReference.create("IntegrationServices.СервисИнтеграции1"));
assertThat(is.getComment()).isEmpty();
assertThat(is.getSynonym().isEmpty()).isTrue();
assertThat(is.getSupportVariant()).isEqualTo(SupportVariant.NONE);
assertThat(is.getModules())
.hasSize(1)
.isEqualTo(is.getAllModules());
assertThat(is.getIntegrationServiceChannels())
.hasSize(2)
.isEqualTo(is.getChildren())
.isEqualTo(is.getPlainChildren());
}
}

0 comments on commit e54a056

Please sign in to comment.