Skip to content

Commit 56fbdd7

Browse files
committed
add tests
1 parent 694d226 commit 56fbdd7

File tree

4 files changed

+302
-0
lines changed

4 files changed

+302
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
class QuerySourceTest {
29+
30+
@Test
31+
void testEmptyConstant() {
32+
assertThat(QuerySource.EMPTY).isNotNull();
33+
assertThat(QuerySource.EMPTY.line()).isZero();
34+
assertThat(QuerySource.EMPTY.column()).isZero();
35+
assertThat(QuerySource.EMPTY.textQuery()).isEmpty();
36+
}
37+
38+
@Test
39+
void testRecordCreation() {
40+
var querySource = new QuerySource(10, 5, "SELECT * FROM Table");
41+
42+
assertThat(querySource.line()).isEqualTo(10);
43+
assertThat(querySource.column()).isEqualTo(5);
44+
assertThat(querySource.textQuery()).isEqualTo("SELECT * FROM Table");
45+
}
46+
47+
@Test
48+
void testRecordWithEmptyQuery() {
49+
var querySource = new QuerySource(0, 0, "");
50+
51+
assertThat(querySource).isNotNull();
52+
assertThat(querySource.textQuery()).isEmpty();
53+
}
54+
55+
@Test
56+
void testRecordEquality() {
57+
var querySource1 = new QuerySource(1, 2, "query");
58+
var querySource2 = new QuerySource(1, 2, "query");
59+
60+
assertThat(querySource1).isEqualTo(querySource2);
61+
}
62+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
23+
24+
import com.github._1c_syntax.bsl.mdo.support.RoleRight;
25+
import com.github._1c_syntax.bsl.types.MdoReference;
26+
import org.junit.jupiter.api.Test;
27+
28+
import java.util.Collections;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
32+
class RoleDataTest {
33+
34+
@Test
35+
void testEmptyConstant() {
36+
assertThat(RoleData.EMPTY).isNotNull();
37+
assertThat(RoleData.EMPTY.objectRights()).isEmpty();
38+
}
39+
40+
@Test
41+
void testBuilderWithEmptyList() {
42+
var roleData = RoleData.builder().build();
43+
44+
assertThat(roleData).isNotNull();
45+
assertThat(roleData.objectRights()).isEmpty();
46+
}
47+
48+
@Test
49+
void testObjectRight() {
50+
var objectRight = new RoleData.ObjectRight(MdoReference.create("Catalogs.TestObject"), Collections.emptyList());
51+
52+
assertThat(objectRight).isNotNull();
53+
assertThat(objectRight.name().getMdoRef()).isEqualTo("Catalog.TestObject");
54+
assertThat(objectRight.rights()).isEmpty();
55+
}
56+
57+
@Test
58+
void testRight() {
59+
var right = new RoleData.Right(RoleRight.READ, true);
60+
61+
assertThat(right).isNotNull();
62+
assertThat(right.name()).isEqualTo(RoleRight.READ);
63+
assertThat(right.value()).isTrue();
64+
}
65+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
class XdtoPackageDataTest {
29+
30+
@Test
31+
void testEmptyConstant() {
32+
assertThat(XdtoPackageData.EMPTY).isNotNull();
33+
assertThat(XdtoPackageData.EMPTY.targetNamespace()).isEmpty();
34+
assertThat(XdtoPackageData.EMPTY.imports()).isEmpty();
35+
assertThat(XdtoPackageData.EMPTY.valueTypes()).isEmpty();
36+
assertThat(XdtoPackageData.EMPTY.objectTypes()).isEmpty();
37+
assertThat(XdtoPackageData.EMPTY.properties()).isEmpty();
38+
}
39+
40+
@Test
41+
void testValueType() {
42+
var valueType = new XdtoPackageData.ValueType(
43+
"TestType",
44+
"BaseType",
45+
"Atomic",
46+
java.util.List.of("Value1", "Value2")
47+
);
48+
49+
assertThat(valueType).isNotNull();
50+
assertThat(valueType.name()).isEqualTo("TestType");
51+
assertThat(valueType.base()).isEqualTo("BaseType");
52+
assertThat(valueType.variety()).isEqualTo("Atomic");
53+
assertThat(valueType.enumerations()).hasSize(2);
54+
}
55+
56+
@Test
57+
void testObjectType() {
58+
var objectType = new XdtoPackageData.ObjectType(
59+
"TestObject",
60+
"BaseObject",
61+
java.util.List.of()
62+
);
63+
64+
assertThat(objectType).isNotNull();
65+
assertThat(objectType.name()).isEqualTo("TestObject");
66+
assertThat(objectType.base()).isEqualTo("BaseObject");
67+
assertThat(objectType.properties()).isEmpty();
68+
}
69+
70+
@Test
71+
void testProperty() {
72+
var property = new XdtoPackageData.Property(
73+
"TestProperty",
74+
"string",
75+
0,
76+
1,
77+
false,
78+
"Element",
79+
java.util.List.of()
80+
);
81+
82+
assertThat(property).isNotNull();
83+
assertThat(property.name()).isEqualTo("TestProperty");
84+
assertThat(property.type()).isEqualTo("string");
85+
assertThat(property.lowerBound()).isZero();
86+
assertThat(property.upperBound()).isOne();
87+
assertThat(property.nillable()).isFalse();
88+
assertThat(property.form()).isEqualTo("Element");
89+
assertThat(property.typeDef()).isEmpty();
90+
}
91+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.support;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
class HandlerTest {
29+
30+
@Test
31+
void testEmptyConstant() {
32+
assertThat(Handler.EMPTY).isNotNull();
33+
assertThat(Handler.EMPTY.isEmpty()).isTrue();
34+
assertThat(Handler.EMPTY.getMethodPath()).isEmpty();
35+
assertThat(Handler.EMPTY.getModuleName()).isEmpty();
36+
assertThat(Handler.EMPTY.getMethodName()).isEmpty();
37+
}
38+
39+
@Test
40+
void testNullPath() {
41+
var handler = new Handler(null);
42+
43+
assertThat(handler.isEmpty()).isTrue();
44+
assertThat(handler.getMethodPath()).isEmpty();
45+
assertThat(handler.getModuleName()).isEmpty();
46+
assertThat(handler.getMethodName()).isEmpty();
47+
}
48+
49+
@Test
50+
void testEmptyPath() {
51+
var handler = new Handler("");
52+
53+
assertThat(handler.isEmpty()).isTrue();
54+
assertThat(handler.getMethodPath()).isEmpty();
55+
}
56+
57+
@Test
58+
void testValidHandler() {
59+
var handler = new Handler("Configuration.CommonModule.MethodName");
60+
61+
assertThat(handler.isEmpty()).isFalse();
62+
assertThat(handler.getMethodPath()).isEqualTo("Configuration.CommonModule.MethodName");
63+
assertThat(handler.getModuleName()).isEqualTo("CommonModule");
64+
assertThat(handler.getMethodName()).isEqualTo("MethodName");
65+
}
66+
67+
@Test
68+
void testHandlerWithModuleOnly() {
69+
var handler = new Handler("Configuration.CommonModule");
70+
71+
assertThat(handler.isEmpty()).isFalse();
72+
assertThat(handler.getModuleName()).isEqualTo("CommonModule");
73+
assertThat(handler.getMethodName()).isEmpty();
74+
}
75+
76+
@Test
77+
void testHandlerWithShortPath() {
78+
var handler = new Handler("Module");
79+
80+
assertThat(handler.isEmpty()).isFalse();
81+
assertThat(handler.getModuleName()).isEmpty();
82+
assertThat(handler.getMethodName()).isEmpty();
83+
}
84+
}

0 commit comments

Comments
 (0)