1
2
3
4
5
6
7
8 package dev.metaschema.model.testing.testsuite;
9
10 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
11 import org.apache.commons.lang3.builder.ToStringStyle;
12
13 import java.util.LinkedList;
14 import java.util.List;
15
16 import dev.metaschema.core.model.IBoundObject;
17 import dev.metaschema.core.model.IMetaschemaData;
18 import dev.metaschema.core.model.JsonGroupAsBehavior;
19 import dev.metaschema.core.util.ObjectUtils;
20 import dev.metaschema.databind.model.annotations.BoundAssembly;
21 import dev.metaschema.databind.model.annotations.GroupAs;
22 import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
23 import edu.umd.cs.findbugs.annotations.NonNull;
24
25
26
27
28 @MetaschemaAssembly(
29 formalName = "Test Suite",
30 description = "The root element containing a collection of test collections.",
31 name = "test-suite",
32 moduleClass = MetaschemaTestSuiteModule.class,
33 rootName = "test-suite")
34 public class TestSuite implements IBoundObject {
35 private final IMetaschemaData __metaschemaData;
36
37
38
39
40 @BoundAssembly(
41 formalName = "Test Collection",
42 description = "A collection of test scenarios located at a specific path.",
43 useName = "test-collection",
44 minOccurs = 1,
45 maxOccurs = -1,
46 groupAs = @GroupAs(name = "test-collections", inJson = JsonGroupAsBehavior.LIST))
47 private List<TestCollection> _testCollections;
48
49
50
51
52
53 public TestSuite() {
54 this(null);
55 }
56
57
58
59
60
61
62
63
64 public TestSuite(IMetaschemaData data) {
65 this.__metaschemaData = data;
66 }
67
68 @Override
69 public IMetaschemaData getMetaschemaData() {
70 return __metaschemaData;
71 }
72
73
74
75
76
77
78
79
80
81 @NonNull
82 public List<TestCollection> getTestCollections() {
83 if (_testCollections == null) {
84 _testCollections = new LinkedList<>();
85 }
86 return ObjectUtils.notNull(_testCollections);
87 }
88
89
90
91
92
93
94
95
96
97
98 public void setTestCollections(@NonNull List<TestCollection> value) {
99 _testCollections = value;
100 }
101
102
103
104
105
106
107
108
109 public boolean addTestCollection(TestCollection item) {
110 TestCollection value = ObjectUtils.requireNonNull(item, "item cannot be null");
111 if (_testCollections == null) {
112 _testCollections = new LinkedList<>();
113 }
114 return _testCollections.add(value);
115 }
116
117
118
119
120
121
122
123
124
125 public boolean removeTestCollection(TestCollection item) {
126 TestCollection value = ObjectUtils.requireNonNull(item, "item cannot be null");
127 return _testCollections != null && _testCollections.remove(value);
128 }
129
130 @Override
131 public String toString() {
132 return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
133 }
134 }