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.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   * The root element containing a collection of test collections.
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     * A collection of test scenarios located at a specific path.
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     * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestSuite}
51     * instance with no metadata.
52     */
53    public TestSuite() {
54      this(null);
55    }
56  
57    /**
58     * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestSuite}
59     * instance with the specified metadata.
60     *
61     * @param data
62     *          the metaschema data, or {@code null} if none
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     * Get the test Collection.
75     *
76     * <p>
77     * A collection of test scenarios located at a specific path.
78     *
79     * @return the test-collection value
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     * Set the test Collection.
91     *
92     * <p>
93     * A collection of test scenarios located at a specific path.
94     *
95     * @param value
96     *          the test-collection value to set
97     */
98    public void setTestCollections(@NonNull List<TestCollection> value) {
99      _testCollections = value;
100   }
101 
102   /**
103    * Add a new {@link TestCollection} item to the underlying collection.
104    *
105    * @param item
106    *          the item to add
107    * @return {@code true}
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    * Remove the first matching {@link TestCollection} item from the underlying
119    * collection.
120    *
121    * @param item
122    *          the item to remove
123    * @return {@code true} if the item was removed or {@code false} otherwise
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 }