BAEL-5760: Creating a separate mocks-2 module (#12882)

This commit is contained in:
Eugene Kovko
2022-10-17 00:10:50 +02:00
committed by GitHub
parent 7b44b2759f
commit 6da922c20a
25 changed files with 52 additions and 14 deletions
@@ -1,22 +0,0 @@
package com.baeldung.datafaker;
import java.util.List;
import net.datafaker.Faker;
public class Collection {
public static final int MIN = 1;
public static final int MAX = 100;
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println(getFictionalCharacters());
}
static List<String> getFictionalCharacters() {
return faker.collection(
() -> faker.starWars().character(),
() -> faker.starTrek().character())
.len(MIN, MAX)
.generate();
}
}
@@ -1,25 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class Csv {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("First expression:\n" + getFirstExpression());
System.out.println("Second expression:\n" + getSecondExpression());
}
static String getSecondExpression() {
final String secondExpressionString
= "#{csv ',','\"','true','4','name_column','#{Name.first_name}','last_name_column','#{Name.last_name}'}";
return faker.expression(secondExpressionString);
}
static String getFirstExpression() {
final String firstExpressionString
= "#{csv '4','name_column','#{Name.first_name}','last_name_column','#{Name.last_name}'}";
return faker.expression(firstExpressionString);
}
}
@@ -1,21 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class Examplify {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("Expression: " + getExpression());
System.out.println("Number expression: " + getNumberExpression());
}
static String getNumberExpression() {
return faker.expression("#{examplify '123-123-123'}");
}
static String getExpression() {
return faker.expression("#{examplify 'Cat in the Hat'}");
}
}
@@ -1,19 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class Json {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println(getExpression());
}
static String getExpression() {
return faker.expression(
"#{json 'person'," +
"'#{json ''first_name'',''#{Name.first_name}'',''last_name'',''#{Name.last_name}''}'," +
"'address'," +
"'#{json ''country'',''#{Address.country}'',''city'',''#{Address.city}''}'}");
}
}
@@ -1,20 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class MethodInvocation {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("Name from a method: " + getNameFromMethod());
System.out.println("Name from an expression: " + getNameFromExpression());
}
static String getNameFromExpression() {
return faker.expression("#{Name.first_Name}");
}
static String getNameFromMethod() {
return faker.name().firstName();
}
}
@@ -1,25 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
import java.time.Duration;
public class MethodInvocationWithParams {
public static final int MIN = 1;
public static final int MAX = 10;
public static final String UNIT = "SECONDS";
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("Duration from the method :" + getDurationFromMethod());
System.out.println("Duration from the expression: " + getDurationFromExpression());
}
static String getDurationFromExpression() {
return faker.expression("#{date.duration '1', '10', 'SECONDS'}");
}
static Duration getDurationFromMethod() {
return faker.date().duration(MIN, MAX, UNIT);
}
}
@@ -1,25 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
import java.io.Serializable;
import java.util.List;
public class MixedCollection {
public static final int MIN = 1;
public static final int MAX = 20;
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println(getMixedCollection());
}
static List<? extends Serializable> getMixedCollection() {
return faker.collection(
() -> faker.date().birthday(),
() -> faker.name().fullName()
)
.len(MIN, MAX)
.generate();
}
}
@@ -1,25 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class Option {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("First expression: " + getFirstExpression());
System.out.println("Second expression: " + getSecondExpression());
System.out.println("Third expression: " + getThirdExpression());
}
static String getThirdExpression() {
return faker.expression("#{regexify '(Hi|Hello|Hey)'}");
}
static String getSecondExpression() {
return faker.expression("#{options.option '1','2','3','4','*'}");
}
static String getFirstExpression() {
return faker.expression("#{options.option 'Hi','Hello','Hey'}");
}
}
@@ -1,20 +0,0 @@
package com.baeldung.datafaker;
import com.github.javafaker.Faker;
public class Regexify {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("Expression: " + getExpression());
System.out.println("Regexify with a method: " + getMethodExpression());
}
static String getMethodExpression() {
return faker.regexify("[A-D]{4,10}");
}
static String getExpression() {
return faker.expression("#{regexify '(hello|bye|hey)'}");
}
}
@@ -1,21 +0,0 @@
package com.baeldung.datafaker;
import net.datafaker.Faker;
public class Templatify {
private static final Faker faker = new Faker();
public static void main(String[] args) {
System.out.println("Expression: " + getExpression());
System.out.println("Expression with a placeholder: " + getExpressionWithPlaceholder());
}
static String getExpressionWithPlaceholder() {
return faker.expression("#{templatify '#ight', '#', 'f', 'l', 'm', 'n'}");
}
static String getExpression() {
return faker.expression("#{templatify 'test','t','j','r'}");
}
}