File tree Expand file tree Collapse file tree 5 files changed +93
-1
lines changed
test/java/io/bloco/faker/components Expand file tree Collapse file tree 5 files changed +93
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ The goal was to reuse their locale data files.
17
17
}
18
18
19
19
dependencies {
20
- compile 'com.github.blocoio:faker:1.2.5 '
20
+ compile 'com.github.blocoio:faker:1.2.6 '
21
21
}
22
22
23
23
You can use ``` testCompile ``` or ``` androidTestCompile ``` , if you only want to use Faker for testing.
@@ -46,6 +46,7 @@ We have tried to keep the operations as close as possible.
46
46
- Commerce
47
47
- Company
48
48
- Date
49
+ - Food
49
50
- Internet
50
51
- Lorem
51
52
- Name
Original file line number Diff line number Diff line change 22
22
import io .bloco .faker .components .Commerce ;
23
23
import io .bloco .faker .components .Company ;
24
24
import io .bloco .faker .components .Date ;
25
+ import io .bloco .faker .components .Food ;
25
26
import io .bloco .faker .components .Internet ;
26
27
import io .bloco .faker .components .Lorem ;
27
28
import io .bloco .faker .components .Name ;
@@ -48,6 +49,7 @@ public class Faker {
48
49
public final Commerce commerce ;
49
50
public final Company company ;
50
51
public final Date date ;
52
+ public final Food food ;
51
53
public final Internet internet ;
52
54
public final Lorem lorem ;
53
55
public final Name name ;
@@ -87,6 +89,7 @@ public Faker(String locale) {
87
89
this .commerce = this .data .getComponent (Commerce .class );
88
90
this .company = this .data .getComponent (Company .class );
89
91
this .date = this .data .getComponent (Date .class );
92
+ this .food = this .data .getComponent (Food .class );
90
93
this .internet = this .data .getComponent (Internet .class );
91
94
this .lorem = this .data .getComponent (Lorem .class );
92
95
this .name = this .data .getComponent (Name .class );
Original file line number Diff line number Diff line change 13
13
import io .bloco .faker .components .Commerce ;
14
14
import io .bloco .faker .components .Company ;
15
15
import io .bloco .faker .components .Date ;
16
+ import io .bloco .faker .components .Food ;
16
17
import io .bloco .faker .components .Internet ;
17
18
import io .bloco .faker .components .Lorem ;
18
19
import io .bloco .faker .components .Name ;
@@ -46,6 +47,7 @@ public FakerData(Map<String, Object> data) {
46
47
new Commerce (this ),
47
48
new Company (this ),
48
49
new Date (this ),
50
+ new Food (this ),
49
51
new Internet (this ),
50
52
new Lorem (this ),
51
53
new Name (this ),
Original file line number Diff line number Diff line change
1
+ package io .bloco .faker .components ;
2
+
3
+ import io .bloco .faker .FakerComponent ;
4
+ import io .bloco .faker .FakerData ;
5
+
6
+ public class Food extends FakerComponent {
7
+
8
+ public Food (FakerData data ) {
9
+ super (data );
10
+ }
11
+
12
+ public String dish () {
13
+ return fetch ("food.dish" );
14
+ }
15
+
16
+ public String description () {
17
+ return fetch ("food.descriptions" );
18
+ }
19
+
20
+ public String ingredient () {
21
+ return fetch ("food.ingredients" );
22
+ }
23
+
24
+ public String spice () {
25
+ return fetch ("food.spices" );
26
+ }
27
+
28
+ public String measurement () {
29
+ return fetch ("food.measurement_sizes" ) + " " + fetch ("food.measurements" );
30
+ }
31
+
32
+ public String metricMeasurement () {
33
+ return fetch ("food.metric_measurements" );
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ package io .bloco .faker .components ;
2
+
3
+ import org .junit .Before ;
4
+ import org .junit .Test ;
5
+
6
+ import io .bloco .faker .Faker ;
7
+
8
+ import static io .bloco .faker .test_helpers .RegularExpressionMatcher .matchesPattern ;
9
+ import static org .junit .Assert .assertNotNull ;
10
+ import static org .junit .Assert .assertThat ;
11
+
12
+ public class FoodTest {
13
+
14
+ private Faker faker ;
15
+
16
+ @ Before
17
+ public void setUp () {
18
+ faker = new Faker ();
19
+ }
20
+
21
+ @ Test
22
+ public void dish () {
23
+ assertNotNull (faker .food .dish ());
24
+ }
25
+
26
+ @ Test
27
+ public void description () {
28
+ assertNotNull (faker .food .description ());
29
+ }
30
+
31
+ @ Test
32
+ public void ingredient () {
33
+ assertNotNull (faker .food .ingredient ());
34
+ }
35
+
36
+ @ Test
37
+ public void spice () {
38
+ assertNotNull (faker .food .spice ());
39
+ }
40
+
41
+ @ Test
42
+ public void measurement () {
43
+ assertNotNull (faker .food .measurement ());
44
+ assertThat (faker .food .measurement (), matchesPattern ("[\\ d\\ /]+ \\ w+" ));
45
+ }
46
+
47
+ @ Test
48
+ public void metricMeasurement () {
49
+ assertNotNull (faker .food .metricMeasurement ());
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments