001/* 002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.test.generator.junit.parameterized; 017 018import de.cuioss.test.generator.Generators; 019import de.cuioss.test.generator.domain.BlindTextGenerator; 020import de.cuioss.test.generator.domain.CityGenerator; 021import de.cuioss.test.generator.domain.DistinguishedNamesGenerator; 022import de.cuioss.test.generator.domain.EmailGenerator; 023import de.cuioss.test.generator.domain.FullNameGenerator; 024import de.cuioss.test.generator.domain.MailSubjectGenerator; 025import de.cuioss.test.generator.domain.Person; 026import de.cuioss.test.generator.domain.PersonGenerator; 027import de.cuioss.test.generator.domain.PhoneNumberGenerator; 028import de.cuioss.test.generator.domain.StreetGenerator; 029import de.cuioss.test.generator.domain.StreetNameGenerator; 030import de.cuioss.test.generator.domain.UUIDGenerator; 031import de.cuioss.test.generator.domain.UUIDStringGenerator; 032import de.cuioss.test.generator.domain.ZipCodeGenerator; 033import lombok.AccessLevel; 034import lombok.Getter; 035import lombok.RequiredArgsConstructor; 036 037import java.io.Serializable; 038import java.net.URL; 039import java.time.LocalDate; 040import java.time.LocalDateTime; 041import java.time.LocalTime; 042import java.time.ZoneId; 043import java.time.ZoneOffset; 044import java.time.ZonedDateTime; 045import java.time.temporal.Temporal; 046import java.util.Date; 047import java.util.Locale; 048import java.util.TimeZone; 049import java.util.UUID; 050 051/** 052 * Enum representing all available generator types from the {@link de.cuioss.test.generator.Generators} class. 053 * Used with {@link GeneratorsSource} to specify which generator method to use. 054 * 055 * @author Oliver Wolff 056 * @since 2.3 057 */ 058@RequiredArgsConstructor(access = AccessLevel.PRIVATE) 059@Getter 060public enum GeneratorType { 061 062 // String generators 063 /** Generates non-empty String values that may contain whitespace or special characters. */ 064 NON_EMPTY_STRINGS("nonEmptyStrings", Generators.class, String.class, GeneratorParameterType.PARAMETERLESS), 065 066 /** Generates non-blank String values that contain at least one non-whitespace character. */ 067 NON_BLANK_STRINGS("nonBlankStrings", Generators.class, String.class, GeneratorParameterType.PARAMETERLESS), 068 069 /** Generates String values with length between minSize and maxSize, containing various characters. */ 070 STRINGS("strings", Generators.class, String.class, GeneratorParameterType.NEEDS_BOUNDS), 071 072 /** Generates String values with length between minSize and maxSize, containing only letters. */ 073 LETTER_STRINGS("letterStrings", Generators.class, String.class, GeneratorParameterType.NEEDS_BOUNDS), 074 075 // Boolean generators 076 /** Generates random boolean primitive values (true or false). */ 077 BOOLEANS("booleans", Generators.class, Boolean.class, GeneratorParameterType.PARAMETERLESS), 078 079 /** Generates random Boolean object values (True or False). */ 080 BOOLEAN_OBJECTS("booleanObjects", Generators.class, Boolean.class, GeneratorParameterType.PARAMETERLESS), 081 082 // Byte generators 083 /** Generates random byte primitive values within the full byte range. */ 084 BYTES("bytes", Generators.class, Byte.class, GeneratorParameterType.PARAMETERLESS), 085 086 /** Generates random Byte object values within the full byte range. */ 087 BYTE_OBJECTS("byteObjects", Generators.class, Byte.class, GeneratorParameterType.PARAMETERLESS), 088 089 // Character generators 090 /** Generates random character primitive values. */ 091 CHARACTERS("characters", Generators.class, Character.class, GeneratorParameterType.PARAMETERLESS), 092 093 /** Generates random Character object values. */ 094 CHARACTER_OBJECTS("characterObjects", Generators.class, Character.class, GeneratorParameterType.PARAMETERLESS), 095 096 // Double generators 097 /** Generates double primitive values within the specified range (low to high). */ 098 DOUBLES("doubles", Generators.class, Double.class, GeneratorParameterType.NEEDS_RANGE), 099 100 /** Generates random Double object values across the full double range. */ 101 DOUBLE_OBJECTS("doubleObjects", Generators.class, Double.class, GeneratorParameterType.PARAMETERLESS), 102 103 // Float generators 104 /** Generates float primitive values within the specified range (low to high). */ 105 FLOATS("floats", Generators.class, Float.class, GeneratorParameterType.NEEDS_RANGE), 106 107 /** Generates random Float object values across the full float range. */ 108 FLOAT_OBJECTS("floatObjects", Generators.class, Float.class, GeneratorParameterType.PARAMETERLESS), 109 110 // Integer generators 111 /** Generates integer primitive values within the specified range (low to high). */ 112 INTEGERS("integers", Generators.class, Integer.class, GeneratorParameterType.NEEDS_RANGE), 113 114 /** Generates random Integer object values across the full integer range. */ 115 INTEGER_OBJECTS("integerObjects", Generators.class, Integer.class, GeneratorParameterType.PARAMETERLESS), 116 117 // Number generator 118 /** Generates random Number objects of various numeric types. */ 119 NUMBERS("numbers", Generators.class, Number.class, GeneratorParameterType.PARAMETERLESS), 120 121 // Short generators 122 /** Generates random short primitive values within the full short range. */ 123 SHORTS("shorts", Generators.class, Short.class, GeneratorParameterType.PARAMETERLESS), 124 125 /** Generates random Short object values within the full short range. */ 126 SHORT_OBJECTS("shortObjects", Generators.class, Short.class, GeneratorParameterType.PARAMETERLESS), 127 128 // Long generators 129 /** Generates long primitive values within the specified range (low to high). */ 130 LONGS("longs", Generators.class, Long.class, GeneratorParameterType.NEEDS_RANGE), 131 132 /** Generates random Long object values across the full long range. */ 133 LONG_OBJECTS("longObjects", Generators.class, Long.class, GeneratorParameterType.PARAMETERLESS), 134 135 // Date and time generators 136 /** Generates random java.util.Date objects with varying dates and times. */ 137 DATES("dates", Generators.class, Date.class, GeneratorParameterType.PARAMETERLESS), 138 139 /** Generates random LocalDate objects representing dates without time components. */ 140 LOCAL_DATES("localDates", Generators.class, LocalDate.class, GeneratorParameterType.PARAMETERLESS), 141 142 /** Generates random LocalTime objects representing times without date components. */ 143 LOCAL_TIMES("localTimes", Generators.class, LocalTime.class, GeneratorParameterType.PARAMETERLESS), 144 145 /** Generates random LocalDateTime objects representing date-time combinations without time zones. */ 146 LOCAL_DATE_TIMES("localDateTimes", Generators.class, LocalDateTime.class, GeneratorParameterType.PARAMETERLESS), 147 148 /** Generates random ZonedDateTime objects representing date-time combinations with time zones. */ 149 ZONED_DATE_TIMES("zonedDateTimes", Generators.class, ZonedDateTime.class, GeneratorParameterType.PARAMETERLESS), 150 151 /** Generates random TimeZone objects representing various time zones. */ 152 TIME_ZONES("timeZones", Generators.class, TimeZone.class, GeneratorParameterType.PARAMETERLESS), 153 154 /** Generates random ZoneId objects representing time zone identifiers. */ 155 ZONE_IDS("zoneIds", Generators.class, ZoneId.class, GeneratorParameterType.PARAMETERLESS), 156 157 /** Generates random ZoneOffset objects representing time zone offsets from UTC. */ 158 ZONE_OFFSETS("zoneOffsets", Generators.class, ZoneOffset.class, GeneratorParameterType.PARAMETERLESS), 159 160 /** Generates random Temporal objects of various temporal types (dates, times, etc.). */ 161 TEMPORALS("temporals", Generators.class, Temporal.class, GeneratorParameterType.PARAMETERLESS), 162 163 // Other generators 164 /** Generates random Class objects representing various Java types. */ 165 CLASS_TYPES("classTypes", Generators.class, Class.class, GeneratorParameterType.PARAMETERLESS), 166 167 /** Generates random Locale objects representing different language and country combinations. */ 168 LOCALES("locales", Generators.class, Locale.class, GeneratorParameterType.PARAMETERLESS), 169 170 /** Generates random Serializable objects of various types. */ 171 SERIALIZABLES("serializables", Generators.class, Serializable.class, GeneratorParameterType.PARAMETERLESS), 172 173 /** Generates random RuntimeException instances with various exception types. */ 174 RUNTIME_EXCEPTIONS("runtimeExceptions", Generators.class, RuntimeException.class, GeneratorParameterType.PARAMETERLESS), 175 176 /** Generates random Throwable instances with various exception and error types. */ 177 THROWABLES("throwables", Generators.class, Throwable.class, GeneratorParameterType.PARAMETERLESS), 178 179 /** Generates random URL objects with various protocols, hosts, and paths. */ 180 URLS("urls", Generators.class, URL.class, GeneratorParameterType.PARAMETERLESS), 181 182 /** Generates values from a fixed set of predefined values. */ 183 FIXED_VALUES("fixedValues", Generators.class, Object.class, GeneratorParameterType.PARAMETERLESS), 184 185 // Domain-specific generators 186 /** Generates random placeholder text (lorem ipsum style) for testing text-heavy components. */ 187 DOMAIN_BLIND_TEXT(null, BlindTextGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 188 189 /** Generates random city names for address-related testing. */ 190 DOMAIN_CITY(null, CityGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 191 192 /** Generates random distinguished names (DNs) for LDAP/directory testing. */ 193 DOMAIN_DISTINGUISHED_NAMES(null, DistinguishedNamesGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 194 195 /** Generates random email addresses in the format firstname.lastname@domain.tld. */ 196 DOMAIN_EMAIL(null, EmailGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 197 198 /** Generates random full names (first and last name combinations). */ 199 DOMAIN_FULL_NAME(null, FullNameGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 200 201 /** Generates random email subject lines for testing email functionality. */ 202 DOMAIN_MAIL_SUBJECT(null, MailSubjectGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 203 204 /** Generates random Person objects with first name, last name, and other personal details. */ 205 DOMAIN_PERSON(null, PersonGenerator.class, Person.class, GeneratorParameterType.PARAMETERLESS), 206 207 /** Generates random phone numbers in various formats. */ 208 DOMAIN_PHONE_NUMBER(null, PhoneNumberGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 209 210 /** Generates random street addresses including street name and house number. */ 211 DOMAIN_STREET(null, StreetGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 212 213 /** Generates random street names without house numbers. */ 214 DOMAIN_STREET_NAME(null, StreetNameGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 215 216 /** Generates random UUID objects for unique identifier testing. */ 217 DOMAIN_UUID(null, UUIDGenerator.class, UUID.class, GeneratorParameterType.PARAMETERLESS), 218 219 /** Generates random UUID strings in standard UUID format. */ 220 DOMAIN_UUID_STRING(null, UUIDStringGenerator.class, String.class, GeneratorParameterType.PARAMETERLESS), 221 222 /** Generates random zip/postal codes as integers. */ 223 DOMAIN_ZIP_CODE(null, ZipCodeGenerator.class, Integer.class, GeneratorParameterType.PARAMETERLESS); 224 225 private final String methodName; 226 private final Class<?> factoryClass; 227 private final Class<?> returnType; 228 private final GeneratorParameterType parameterType; 229 230 231}