Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

StubFactory

...

StubFactory is used to create temporary mocks for front-end and back-end developers before real models and real data is applied.
The feature of the class is ability to generate different instances of simple or complex types.

...

StubFactory can generate:

  • primitives (boolean, short, int and so on)

  • string

  • list

  • map

  • complex object e.g. Person (name, age, birthday...)

StubFactory works recursively, so it can generate collections with other nested types e.g. List<Map<List<Integer>, String>> and so on.

...

To generate API layer without StubFactory (usual interfaces) use the following command from the project's root directory:

Code Blockinfo
cmd/templateapp generate api


To generate API layer with StubFactory usage (default method with StubFactory in interfaces) use the following command from the project's root directory:

Code Blockinfo
cmd/templateapp generate api-stub

MockDataGenerator

...

Basically, StubFactory generates random appropriate data, but it also is able to generate meaningful data using MockDataGenerator.
Meaningful data provided by MockDataGenerator is listed below:

  • name (first name + last name) / last name

  • phone number

  • email

  • address

  • date

  • datetime

  • text (like Lorem Ipsum)

Also, MockDataGenerator supports different locales.

...

Code Block
titleresponse.json
collapsetrue
{
"body": {
"fullName": "Lon Wyman",
"birthday": "Fri Apr 09 12:15:47 EEST 1993",
},
"errors": null,
"debugInfo": null
}



If you have any questions/suggestions/remarks feel free to contact Diakonov Serhii. Hope you'll find it useful =)