Skip to content

Commit 68d2323

Browse files
committed
Update README and libraries.
1 parent 85da0e9 commit 68d2323

29 files changed

+214
-240
lines changed

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ We have tried to keep the operations as close as possible.
4646
- Commerce
4747
- Company
4848
- Date
49-
- Food
5049
- Internet
5150
- Lorem
5251
- Name
@@ -65,25 +64,7 @@ We have tried to keep the operations as close as possible.
6564

6665
## TODO
6766

68-
- Implement remaining components:
69-
- Beer
70-
- Bitcoin
71-
- Cat
72-
- ChuckNorris
73-
- Code
74-
- Crypto
75-
- Educator
76-
- Finance
77-
- GameOfThrones
78-
- Hacker
79-
- Hipster
80-
- IDNumber
81-
- Pokemon
82-
- Shakespeare
83-
- Space
84-
- Superhero
85-
- StarWars
86-
- Vehicle
67+
- Implement remaining components of the [Faker ruby gem](https://github.com/stympy/faker/).
8768

8869
## Proguard
8970

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ repositories {
1313
}
1414

1515
dependencies {
16-
compile 'com.github.bmoliveira:snake-yaml:v1.18-android'
17-
compile "joda-time:joda-time:2.9.1"
18-
testCompile "junit:junit:4.11"
19-
testCompile "org.hamcrest:hamcrest-junit:2.0.0.0"
20-
testCompile "org.mockito:mockito-core:2.0.+"
16+
implementation 'com.github.bmoliveira:snake-yaml:v1.18-android'
17+
implementation 'joda-time:joda-time:2.9.1'
18+
testImplementation 'junit:junit:4.12'
19+
testImplementation 'org.mockito:mockito-core:2.13.0'
20+
testImplementation 'org.hamcrest:hamcrest-core:1.3'
21+
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
2122
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

src/main/java/io/bloco/faker/Faker.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ private InputStream getDataInputStream(String locale) {
112112
.getResourceAsStream("locales/" + locale + ".yml");
113113

114114
try {
115-
assert input != null && input.available() != 0;
116-
} catch (AssertionError|IOException e) {
117-
throw new IllegalArgumentException("Unavailable locale \'" + locale + "\'");
115+
if (input != null && input.available() != 0) {
116+
return input;
117+
}
118+
} catch (IOException e) {
118119
}
119120

120-
return input;
121+
throw new IllegalArgumentException("Unavailable locale \'" + locale + "\'");
121122
}
122123
}

src/test/java/io/bloco/faker/FakerComponentTest.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public String test() {
3434
private FakerComponent fakerComponent;
3535

3636
@Before
37-
public void setUp() throws Exception {
37+
public void setUp() {
3838
fakerData = mock(FakerData.class);
3939
fakerComponent = new TestComponent(fakerData);
4040
}
4141

4242
@Test
43-
public void testFetch() throws Exception {
43+
public void testFetch() {
4444
String componentKey = "wtv";
4545

4646
List<String> options = Arrays.asList("John", "Mary");
@@ -52,7 +52,7 @@ public void testFetch() throws Exception {
5252
}
5353

5454
@Test
55-
public void testFetchComposed() throws Exception {
55+
public void testFetchComposed() {
5656
String componentKey = "wtv";
5757

5858
List<String> options = Arrays.asList("John", "Mary");
@@ -66,7 +66,7 @@ public void testFetchComposed() throws Exception {
6666
}
6767

6868
@Test
69-
public void testSampleNestedLists() throws Exception {
69+
public void testSampleNestedLists() {
7070
String componentKey = "wtv";
7171

7272
List<String> options = Arrays.asList("John", "Mary");
@@ -78,7 +78,7 @@ public void testSampleNestedLists() throws Exception {
7878
}
7979

8080
@Test
81-
public void testNumerify() throws Exception {
81+
public void testNumerify() {
8282
String digit = "#";
8383
assertThat(fakerComponent.numerify(digit), matchesPattern("\\d"));
8484

@@ -93,7 +93,7 @@ public void testNumerify() throws Exception {
9393
}
9494

9595
@Test
96-
public void testParse() throws Exception {
96+
public void testParse() {
9797
when(fakerData.getComponentByKey(anyString())).thenReturn(fakerComponent);
9898

9999
assertThat(fakerComponent.parse("#{test}"), is(equalTo("ok")));
@@ -104,23 +104,15 @@ public void testParse() throws Exception {
104104
}
105105

106106
@Test
107-
public void testCall() throws Exception {
107+
public void testCall() {
108108
when(fakerData.getComponentByKey(anyString())).thenReturn(fakerComponent);
109109
assertThat(fakerComponent.call("test"), is(equalTo("ok")));
110110
}
111111

112112
@Test(expected = IllegalArgumentException.class)
113-
public void testCallInvalid() throws Exception {
113+
public void testCallInvalid() {
114114
when(fakerData.getComponentByKey(anyString())).thenReturn(fakerComponent);
115115
fakerComponent.call("invalid");
116116
}
117117

118-
// Helpers
119-
120-
private Map<String, Object> newComponentData(String componentKey,
121-
Map<String, Object> internalData) {
122-
Map<String, Object> data = new HashMap<>();
123-
data.put(componentKey, internalData);
124-
return data;
125-
}
126118
}

src/test/java/io/bloco/faker/FakerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99

1010
public class FakerTest {
1111
@Test
12-
public void testLoadComponents() throws Exception {
12+
public void testLoadComponents() {
1313
Faker faker = new Faker();
1414
assertNotNull(faker.app);
1515
}
1616

1717
@Test
18-
public void testLocaleDefault() throws Exception {
18+
public void testLocaleDefault() {
1919
Faker faker = new Faker();
2020
assertThat(faker.getLocale(), is(equalTo(Faker.DEFAULT_LOCALE)));
2121
}
2222

2323
@Test
24-
public void testLocaleProvided() throws Exception {
24+
public void testLocaleProvided() {
2525
Faker faker = new Faker("nl");
2626
assertThat(faker.getLocale(), is(equalTo("nl")));
2727
}
@@ -32,7 +32,7 @@ public void testLocaleInvalid() {
3232
}
3333

3434
@Test
35-
public void testLocaleFallback() throws Exception {
35+
public void testLocaleFallback() {
3636
// Dutch doesn't have App.name, but English (the default) has
3737
Faker faker = new Faker("nl");
3838
assertNotNull(faker.app.name());

src/test/java/io/bloco/faker/components/AddressTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,81 @@ public class AddressTest {
1212
private Faker faker;
1313

1414
@Before
15-
public void setUp() throws Exception {
15+
public void setUp() {
1616
faker = new Faker();
1717
}
1818

1919
@Test
20-
public void testCityPrefix() throws Exception {
20+
public void testCityPrefix() {
2121
assertNotNull(faker.address.cityPrefix());
2222
}
2323

2424
@Test
25-
public void citySuffix() throws Exception {
25+
public void citySuffix() {
2626
assertNotNull(faker.address.citySuffix());
2727
}
2828

2929
@Test
30-
public void country() throws Exception {
30+
public void country() {
3131
assertNotNull(faker.address.country());
3232
}
3333

3434
@Test
35-
public void countryCode() throws Exception {
35+
public void countryCode() {
3636
assertNotNull(faker.address.countryCode());
3737
}
3838

3939
@Test
40-
public void buildingNumber() throws Exception {
40+
public void buildingNumber() {
4141
assertNotNull(faker.address.buildingNumber());
4242
}
4343
@Test
44-
public void streetSuffix() throws Exception {
44+
public void streetSuffix() {
4545
assertNotNull(faker.address.streetSuffix());
4646
}
4747

4848
@Test
49-
public void secondaryAddress() throws Exception {
49+
public void secondaryAddress() {
5050
assertNotNull(faker.address.secondaryAddress());
5151
}
5252

5353
@Test
54-
public void postcode() throws Exception {
54+
public void postcode() {
5555
assertNotNull(faker.address.postcode());
5656
}
5757

5858
@Test
59-
public void state() throws Exception {
59+
public void state() {
6060
assertNotNull(faker.address.state());
6161
}
6262

6363
@Test
64-
public void stateAbbr() throws Exception {
64+
public void stateAbbr() {
6565
assertNotNull(faker.address.stateAbbr());
6666
}
6767

6868
@Test
69-
public void timeZone() throws Exception {
69+
public void timeZone() {
7070
assertNotNull(faker.address.timeZone());
7171
}
7272

7373
@Test
74-
public void city() throws Exception {
74+
public void city() {
7575
assertNotNull(faker.address.city());
7676
}
7777

7878
@Test
79-
public void streetName() throws Exception {
79+
public void streetName() {
8080
assertNotNull(faker.address.streetName());
8181
}
8282

8383
@Test
84-
public void streetAddress() throws Exception {
84+
public void streetAddress() {
8585
assertNotNull(faker.address.streetAddress());
8686
}
8787

8888
@Test
89-
public void defaultCountry() throws Exception {
89+
public void defaultCountry() {
9090
assertNotNull(faker.address.defaultCountry());
9191
}
9292
}

src/test/java/io/bloco/faker/components/AppTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public class AppTest {
1212
private Faker faker;
1313

1414
@Before
15-
public void setUp() throws Exception {
15+
public void setUp() {
1616
faker = new Faker();
1717
}
1818

1919
@Test
20-
public void name() throws Exception {
20+
public void name() {
2121
assertNotNull(faker.app.name());
2222
}
2323

2424
@Test
25-
public void version() throws Exception {
25+
public void version() {
2626
assertNotNull(faker.app.version());
2727
}
2828

2929
@Test
30-
public void author() throws Exception {
30+
public void author() {
3131
assertNotNull(faker.app.author());
3232
}
3333
}

src/test/java/io/bloco/faker/components/AvatarTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class AvatarTest {
1414
private Faker faker;
1515

1616
@Before
17-
public void setUp() throws Exception {
17+
public void setUp() {
1818
faker = new Faker();
1919
}
2020

2121
@Test
22-
public void imageDefault() throws Exception {
22+
public void imageDefault() {
2323
String defaultUrl = faker.avatar.image();
2424
assertThat(defaultUrl, containsString("robohash.org"));
2525
assertThat(defaultUrl, containsString("image"));
@@ -30,7 +30,7 @@ public void imageDefault() throws Exception {
3030
}
3131

3232
@Test
33-
public void imageParams() throws Exception {
33+
public void imageParams() {
3434
String specificUrl = faker.avatar.image("my-slug", "80x80", "bmp", "set2", "bgset1");
3535
assertThat(specificUrl, containsString("robohash.org"));
3636
assertThat(specificUrl, containsString("my-slug"));

src/test/java/io/bloco/faker/components/BookTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ public class BookTest {
1212
private Faker faker;
1313

1414
@Before
15-
public void setUp() throws Exception {
15+
public void setUp() {
1616
faker = new Faker();
1717
}
1818

1919
@Test
20-
public void title() throws Exception {
20+
public void title() {
2121
assertNotNull(faker.book.title());
2222
}
2323

2424
@Test
25-
public void author() throws Exception {
25+
public void author() {
2626
assertNotNull(faker.book.author());
2727
}
2828

2929
@Test
30-
public void publisher() throws Exception {
30+
public void publisher() {
3131
assertNotNull(faker.book.publisher());
3232
}
3333

3434
@Test
35-
public void genre() throws Exception {
35+
public void genre() {
3636
assertNotNull(faker.book.genre());
3737
}
3838
}

src/test/java/io/bloco/faker/components/BoolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public class BoolTest {
1212
private Faker faker;
1313

1414
@Before
15-
public void setUp() throws Exception {
15+
public void setUp() {
1616
faker = new Faker();
1717
}
1818

1919
@Test
20-
public void bool() throws Exception {
20+
public void bool() {
2121
float trueRatio = Math.round(Math.random() * 10f) / 10f;
2222
int times = 1000;
2323
int trueCounter = 0;

0 commit comments

Comments
 (0)