1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   // Generated from: ../../../../../../metaschema/unit-tests.yaml
6   // Do not edit - changes will be lost when regenerated.
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.datatype.adapter.StringAdapter;
17  import dev.metaschema.core.model.IBoundObject;
18  import dev.metaschema.core.model.IMetaschemaData;
19  import dev.metaschema.core.model.JsonGroupAsBehavior;
20  import dev.metaschema.core.util.ObjectUtils;
21  import dev.metaschema.databind.model.annotations.BoundAssembly;
22  import dev.metaschema.databind.model.annotations.BoundFlag;
23  import dev.metaschema.databind.model.annotations.GroupAs;
24  import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
25  import edu.umd.cs.findbugs.annotations.NonNull;
26  import edu.umd.cs.findbugs.annotations.Nullable;
27  
28  /**
29   * A test scenario that validates a metaschema and its content.
30   */
31  @MetaschemaAssembly(
32      formalName = "Test Scenario",
33      description = "A test scenario that validates a metaschema and its content.",
34      name = "test-scenario",
35      moduleClass = MetaschemaTestSuiteModule.class)
36  public class TestScenario implements IBoundObject {
37    private final IMetaschemaData __metaschemaData;
38  
39    /**
40     * The name of this test scenario.
41     */
42    @BoundFlag(
43        formalName = "Name",
44        description = "The name of this test scenario.",
45        name = "name",
46        required = true,
47        typeAdapter = StringAdapter.class)
48    private String _name;
49  
50    /**
51     * Defines schema generation parameters and expected results.
52     */
53    @BoundAssembly(
54        formalName = "Generate Schema",
55        description = "Defines schema generation parameters and expected results.",
56        useName = "generate-schema")
57    private GenerateSchema _generateSchema;
58  
59    /**
60     * A content validation test case.
61     */
62    @BoundAssembly(
63        formalName = "Validation Case",
64        description = "A content validation test case.",
65        useName = "validation-case",
66        maxOccurs = -1,
67        groupAs = @GroupAs(name = "validation-cases", inJson = JsonGroupAsBehavior.LIST))
68    private List<ValidationCase> _validationCases;
69  
70    /**
71     * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestScenario}
72     * instance with no metadata.
73     */
74    public TestScenario() {
75      this(null);
76    }
77  
78    /**
79     * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestScenario}
80     * instance with the specified metadata.
81     *
82     * @param data
83     *          the metaschema data, or {@code null} if none
84     */
85    public TestScenario(IMetaschemaData data) {
86      this.__metaschemaData = data;
87    }
88  
89    @Override
90    public IMetaschemaData getMetaschemaData() {
91      return __metaschemaData;
92    }
93  
94    /**
95     * Get the name.
96     *
97     * <p>
98     * The name of this test scenario.
99     *
100    * @return the name value
101    */
102   @NonNull
103   public String getName() {
104     return _name;
105   }
106 
107   /**
108    * Set the name.
109    *
110    * <p>
111    * The name of this test scenario.
112    *
113    * @param value
114    *          the name value to set
115    */
116   public void setName(@NonNull String value) {
117     _name = value;
118   }
119 
120   /**
121    * Get the generate Schema.
122    *
123    * <p>
124    * Defines schema generation parameters and expected results.
125    *
126    * @return the generate-schema value, or {@code null} if not set
127    */
128   @Nullable
129   public GenerateSchema getGenerateSchema() {
130     return _generateSchema;
131   }
132 
133   /**
134    * Set the generate Schema.
135    *
136    * <p>
137    * Defines schema generation parameters and expected results.
138    *
139    * @param value
140    *          the generate-schema value to set, or {@code null} to clear
141    */
142   public void setGenerateSchema(@Nullable GenerateSchema value) {
143     _generateSchema = value;
144   }
145 
146   /**
147    * Get the validation Case.
148    *
149    * <p>
150    * A content validation test case.
151    *
152    * @return the validation-case value
153    */
154   @NonNull
155   public List<ValidationCase> getValidationCases() {
156     if (_validationCases == null) {
157       _validationCases = new LinkedList<>();
158     }
159     return ObjectUtils.notNull(_validationCases);
160   }
161 
162   /**
163    * Set the validation Case.
164    *
165    * <p>
166    * A content validation test case.
167    *
168    * @param value
169    *          the validation-case value to set
170    */
171   public void setValidationCases(@NonNull List<ValidationCase> value) {
172     _validationCases = value;
173   }
174 
175   /**
176    * Add a new {@link ValidationCase} item to the underlying collection.
177    *
178    * @param item
179    *          the item to add
180    * @return {@code true}
181    */
182   public boolean addValidationCase(ValidationCase item) {
183     ValidationCase value = ObjectUtils.requireNonNull(item, "item cannot be null");
184     if (_validationCases == null) {
185       _validationCases = new LinkedList<>();
186     }
187     return _validationCases.add(value);
188   }
189 
190   /**
191    * Remove the first matching {@link ValidationCase} item from the underlying
192    * collection.
193    *
194    * @param item
195    *          the item to remove
196    * @return {@code true} if the item was removed or {@code false} otherwise
197    */
198   public boolean removeValidationCase(ValidationCase item) {
199     ValidationCase value = ObjectUtils.requireNonNull(item, "item cannot be null");
200     return _validationCases != null && _validationCases.remove(value);
201   }
202 
203   @Override
204   public String toString() {
205     return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
206   }
207 }