@@ -128,6 +128,10 @@ export class TestSampleData {
128128 return this . random . pickOne ( options ) ;
129129 }
130130
131+ pickOneString < T extends string > ( options : Array < T > ) : T {
132+ return this . random . pickOne ( options ) ;
133+ }
134+
131135 pickSome < T > ( options : Array < T > ) : T [ ] {
132136 return this . random . pickSome ( options ) ;
133137 }
@@ -216,6 +220,10 @@ export class TestSampleData {
216220 return Array . from ( { length : length || this . arrayLength ( ) } ) . map ( ( ) => this . sampleString ( ) ) ;
217221 }
218222
223+ sampleArrayArray < T > ( length ?: number ) : Array < Array < T > > {
224+ return [ ] ;
225+ }
226+
219227 sampleArraynumber ( length ?: number ) : Array < number > {
220228 return Array . from ( { length : length || this . arrayLength ( ) } ) . map ( ( ) => this . samplenumber ( ) ) ;
221229 }
@@ -256,6 +264,14 @@ export class TestSampleData {
256264 // eslint-disable-next-line @typescript-eslint/no-explicit-any
257265 sample ( modelName : string ) : any {
258266 switch ( modelName ) {
267+ case "AnyPartyDto" :
268+ return this . sampleAnyPartyDto ( ) ;
269+ case "Array<AnyPartyDto>" :
270+ return this . sampleArrayAnyPartyDto ( ) ;
271+ case "CreationErrorDto" :
272+ return this . sampleCreationErrorDto ( ) ;
273+ case "Array<CreationErrorDto>" :
274+ return this . sampleArrayCreationErrorDto ( ) ;
259275 case "DuplicateIdentifierErrorDto" :
260276 return this . sampleDuplicateIdentifierErrorDto ( ) ;
261277 case "Array<DuplicateIdentifierErrorDto>" :
@@ -280,11 +296,84 @@ export class TestSampleData {
280296 return this . samplePersonDto ( ) ;
281297 case "Array<PersonDto>" :
282298 return this . sampleArrayPersonDto ( ) ;
299+ case "UpdateErrorDto" :
300+ return this . sampleUpdateErrorDto ( ) ;
301+ case "Array<UpdateErrorDto>" :
302+ return this . sampleArrayUpdateErrorDto ( ) ;
283303 default :
284304 throw new Error ( "Unknown type " + modelName ) ;
285305 }
286306 }
287307
308+ sampleAnyPartyDto (
309+ template ?: Factory < OrganizationDto & PersonDto >
310+ ) : AnyPartyDto {
311+ const containerClass = "AnyPartyDto" ;
312+ if ( ! template && typeof this . sampleModelProperties [ containerClass ] === "function" ) {
313+ return this . sampleModelProperties [ containerClass ] ( this ) ;
314+ }
315+ const type = this . pickOneString ( [ "organization" , "person" ] )
316+ switch ( type ) {
317+ case "organization" :
318+ return {
319+ ...this . sampleOrganizationDto ( template ) ,
320+ type
321+ } ;
322+ case "person" :
323+ return {
324+ ...this . samplePersonDto ( template ) ,
325+ type
326+ } ;
327+ }
328+ }
329+
330+ sampleArrayAnyPartyDto (
331+ template : Factory < OrganizationDto & PersonDto > = { } ,
332+ length ?: number
333+ ) : Array < AnyPartyDto > {
334+ return this . randomArray (
335+ ( ) => this . sampleAnyPartyDto ( template ) ,
336+ length ?? this . arrayLength ( )
337+ ) ;
338+ }
339+
340+ sampleCreationErrorDto (
341+ template ?: Factory < IllegalEmailAddressErrorDto & DuplicateIdentifierErrorDto & GeneralErrorDto >
342+ ) : CreationErrorDto {
343+ const containerClass = "CreationErrorDto" ;
344+ if ( ! template && typeof this . sampleModelProperties [ containerClass ] === "function" ) {
345+ return this . sampleModelProperties [ containerClass ] ( this ) ;
346+ }
347+ const code = this . pickOneString ( [ "IllegalEmailAddressError" , "DuplicateIdentifierError" , "GeneralError" ] )
348+ switch ( code ) {
349+ case "IllegalEmailAddressError" :
350+ return {
351+ ...this . sampleIllegalEmailAddressErrorDto ( template ) ,
352+ code
353+ } ;
354+ case "DuplicateIdentifierError" :
355+ return {
356+ ...this . sampleDuplicateIdentifierErrorDto ( template ) ,
357+ code
358+ } ;
359+ case "GeneralError" :
360+ return {
361+ ...this . sampleGeneralErrorDto ( template ) ,
362+ code
363+ } ;
364+ }
365+ }
366+
367+ sampleArrayCreationErrorDto (
368+ template : Factory < IllegalEmailAddressErrorDto & DuplicateIdentifierErrorDto & GeneralErrorDto > = { } ,
369+ length ?: number
370+ ) : Array < CreationErrorDto > {
371+ return this . randomArray (
372+ ( ) => this . sampleCreationErrorDto ( template ) ,
373+ length ?? this . arrayLength ( )
374+ ) ;
375+ }
376+
288377 sampleDuplicateIdentifierErrorDto ( template ?: Factory < DuplicateIdentifierErrorDto > ) : DuplicateIdentifierErrorDto {
289378 const containerClass = "DuplicateIdentifierErrorDto" ;
290379 if ( ! template && typeof this . sampleModelProperties [ containerClass ] === "function" ) {
@@ -528,4 +617,46 @@ export class TestSampleData {
528617 length ?? this . arrayLength ( )
529618 ) ;
530619 }
620+
621+ sampleUpdateErrorDto (
622+ template ?: Factory < IllegalEmailAddressErrorDto & DuplicateIdentifierErrorDto & GeneralErrorDto & NotFoundErrorDto >
623+ ) : UpdateErrorDto {
624+ const containerClass = "UpdateErrorDto" ;
625+ if ( ! template && typeof this . sampleModelProperties [ containerClass ] === "function" ) {
626+ return this . sampleModelProperties [ containerClass ] ( this ) ;
627+ }
628+ const code = this . pickOneString ( [ "IllegalEmailAddressError" , "DuplicateIdentifierError" , "GeneralError" , "NotFoundError" ] )
629+ switch ( code ) {
630+ case "IllegalEmailAddressError" :
631+ return {
632+ ...this . sampleIllegalEmailAddressErrorDto ( template ) ,
633+ code
634+ } ;
635+ case "DuplicateIdentifierError" :
636+ return {
637+ ...this . sampleDuplicateIdentifierErrorDto ( template ) ,
638+ code
639+ } ;
640+ case "GeneralError" :
641+ return {
642+ ...this . sampleGeneralErrorDto ( template ) ,
643+ code
644+ } ;
645+ case "NotFoundError" :
646+ return {
647+ ...this . sampleNotFoundErrorDto ( template ) ,
648+ code
649+ } ;
650+ }
651+ }
652+
653+ sampleArrayUpdateErrorDto (
654+ template : Factory < IllegalEmailAddressErrorDto & DuplicateIdentifierErrorDto & GeneralErrorDto & NotFoundErrorDto > = { } ,
655+ length ?: number
656+ ) : Array < UpdateErrorDto > {
657+ return this . randomArray (
658+ ( ) => this . sampleUpdateErrorDto ( template ) ,
659+ length ?? this . arrayLength ( )
660+ ) ;
661+ }
531662}
0 commit comments