Merge branch 'manudevelopia-master'

This commit is contained in:
Ricky
2020-07-06 17:57:29 +10:00
6 changed files with 66 additions and 0 deletions
@@ -0,0 +1,22 @@
package com.github.javafaker;
public class Barcode {
private Faker faker;
public Barcode(Faker faker) {
this.faker = faker;
}
public String type() {
return faker.resolve("barcode.types");
}
public String data(){
return faker.resolve("barcode.datas");
}
public String typeAndData(){
return faker.resolve("barcode.typeAndData");
}
}
@@ -101,6 +101,7 @@ public class Faker {
private final BojackHorseman bojackHorseman;
private final Disease disease;
private final Basketball basketball;
private final Barcode barcode;
public Faker() {
this(Locale.ENGLISH);
@@ -211,6 +212,7 @@ public class Faker {
this.bojackHorseman = new BojackHorseman(this);
this.disease = new Disease(this);
this.basketball = new Basketball(this);
this.barcode = new Barcode(this);
}
/**
@@ -663,6 +665,8 @@ public class Faker {
public Basketball basketball() { return basketball; }
public Barcode barcode() { return barcode; }
public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
@@ -35,6 +35,7 @@ public class EnFile {
"artist.yml",
"aviation.yml",
"back_to_the_future.yml",
"barcode.yml",
"bank.yml",
"basketball.yml",
"beer.yml",
+10
View File
@@ -0,0 +1,10 @@
en:
faker:
barcode:
types: ['UPC', 'UPC-A', 'UPC-E', 'Code128', 'Code39','Code93', 'EAN', 'EAN-13', 'EAN-8', 'JAN-13', 'ISBN', 'ISSN',
'ITF', 'Codabar', 'Ames Code', 'NW-7', 'Monarch', 'Code 2 of 7', 'Rationalized', 'ANSI/AIM BC3-1995', 'USD-4',
'GS1 Databar', 'MSI Plessey', 'UCC']
datas: ['12345678', '09876543', '05755069', '15008444', '69503172', '05082366', '29951287', '37457367',
'87164772', '17217165', '56462327', '35186895', '16957481', '68124245', '28664694', '12372549',
'02527355']
typeAndData: "#{barcode.types} #{barcode.datas}"
@@ -0,0 +1,28 @@
package com.github.javafaker;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;
public class BarcodeTest extends AbstractFakerTest {
@Test
public void type() {
assertThat(faker.barcode().type(),
matchesRegularExpression("(Code(128|39|93))|(E|J)AN(-\\d{1,2})*|Codabar|UCC|UPC(-(A|E))*|IS(B|S)N|ITF|" +
"Ames\\sCode|NW-7|Monarch|Code\\s2\\sof\\s7|Rationalized|ANSI\\/AIM BC3-1995|USD-4|" +
"GS1 Databar|MSI Plessey"));
}
@Test
public void data(){
assertThat(faker.barcode().data(), matchesRegularExpression("\\d+"));
}
@Test
public void typeAndData(){
assertThat(faker.barcode().typeAndData(), matchesRegularExpression("(\\w|\\W)+\\s\\d+$"));
}
}
@@ -167,6 +167,7 @@ public class FakerIT {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.bojackHorseman());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.disease());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.basketball());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.barcode());
}
private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {