001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005// Generated from: ../../../../../../metaschema/unit-tests.yaml 006// Do not edit - changes will be lost when regenerated. 007 008package dev.metaschema.model.testing.testsuite; 009 010import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 011import org.apache.commons.lang3.builder.ToStringStyle; 012 013import java.util.LinkedList; 014import java.util.List; 015 016import dev.metaschema.core.datatype.adapter.StringAdapter; 017import dev.metaschema.core.model.IBoundObject; 018import dev.metaschema.core.model.IMetaschemaData; 019import dev.metaschema.core.model.JsonGroupAsBehavior; 020import dev.metaschema.core.util.ObjectUtils; 021import dev.metaschema.databind.model.annotations.BoundAssembly; 022import dev.metaschema.databind.model.annotations.BoundFlag; 023import dev.metaschema.databind.model.annotations.GroupAs; 024import dev.metaschema.databind.model.annotations.MetaschemaAssembly; 025import edu.umd.cs.findbugs.annotations.NonNull; 026import edu.umd.cs.findbugs.annotations.Nullable; 027 028/** 029 * A test scenario that validates a metaschema and its content. 030 */ 031@MetaschemaAssembly( 032 formalName = "Test Scenario", 033 description = "A test scenario that validates a metaschema and its content.", 034 name = "test-scenario", 035 moduleClass = MetaschemaTestSuiteModule.class) 036public class TestScenario implements IBoundObject { 037 private final IMetaschemaData __metaschemaData; 038 039 /** 040 * The name of this test scenario. 041 */ 042 @BoundFlag( 043 formalName = "Name", 044 description = "The name of this test scenario.", 045 name = "name", 046 required = true, 047 typeAdapter = StringAdapter.class) 048 private String _name; 049 050 /** 051 * Defines schema generation parameters and expected results. 052 */ 053 @BoundAssembly( 054 formalName = "Generate Schema", 055 description = "Defines schema generation parameters and expected results.", 056 useName = "generate-schema") 057 private GenerateSchema _generateSchema; 058 059 /** 060 * A content validation test case. 061 */ 062 @BoundAssembly( 063 formalName = "Validation Case", 064 description = "A content validation test case.", 065 useName = "validation-case", 066 maxOccurs = -1, 067 groupAs = @GroupAs(name = "validation-cases", inJson = JsonGroupAsBehavior.LIST)) 068 private List<ValidationCase> _validationCases; 069 070 /** 071 * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestScenario} 072 * instance with no metadata. 073 */ 074 public TestScenario() { 075 this(null); 076 } 077 078 /** 079 * Constructs a new {@code dev.metaschema.model.testing.testsuite.TestScenario} 080 * instance with the specified metadata. 081 * 082 * @param data 083 * the metaschema data, or {@code null} if none 084 */ 085 public TestScenario(IMetaschemaData data) { 086 this.__metaschemaData = data; 087 } 088 089 @Override 090 public IMetaschemaData getMetaschemaData() { 091 return __metaschemaData; 092 } 093 094 /** 095 * Get the name. 096 * 097 * <p> 098 * The name of this test scenario. 099 * 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}