Skip to content

Commit 64785e9

Browse files
authored
Merge pull request #156 from Tahanima/feature/add-camera-faker
Added camera faker
2 parents 68b3a1c + 3c15daa commit 64785e9

File tree

7 files changed

+67
-0
lines changed

7 files changed

+67
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Providers
175175
* Business
176176
* CNPJ [Brazilian National Registry of Legal Entities](https://en.wikipedia.org/wiki/CNPJ)
177177
* CPF [Brazilian individual taxpayer registry identification](https://en.wikipedia.org/wiki/CPF_number)
178+
* Camera
178179
* Cat
179180
* ChuckNorris
180181
* Code
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.datafaker;
2+
3+
public class Camera {
4+
5+
private final Faker faker;
6+
7+
protected Camera(Faker faker) {
8+
this.faker = faker;
9+
}
10+
11+
/**
12+
* This method generates a random camera brand.
13+
*
14+
* @return a string of camera brand.
15+
*/
16+
public String brand() {
17+
return faker.fakeValuesService().resolve("camera.brand", this, faker);
18+
}
19+
20+
/**
21+
* This method generates a random camera model.
22+
*
23+
* @return a string of camera model.
24+
*/
25+
public String model() {
26+
return faker.fakeValuesService().resolve("camera.model", this, faker);
27+
}
28+
29+
/**
30+
* This method generates a random camera brand with a model.
31+
*
32+
* @return a string of camera brand with a model.
33+
*/
34+
public String brandWithModel() {
35+
return faker.fakeValuesService().resolve("camera.brand_with_model", this, faker);
36+
}
37+
}

src/main/java/net/datafaker/Faker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ public Business business() {
386386
return getProvider(Business.class, () -> new Business(this));
387387
}
388388

389+
public Camera camera() {
390+
return getProvider(Camera.class, () -> new Camera(this));
391+
}
392+
389393
public Cat cat() {
390394
return getProvider(Cat.class, () -> new Cat(this));
391395
}

src/main/java/net/datafaker/service/files/EnFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public String getPath() {
5454
"brooklyn_nine_nine.yml",
5555
"buffy.yml",
5656
"business.yml",
57+
"camera.yml",
5758
// "cannabis.yml",
5859
"chuck_norris.yml",
5960
"code.yml",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package net.datafaker;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
class CameraTest extends AbstractFakerTest {
8+
9+
@Test
10+
void testBrand() {
11+
assertThat(faker.camera().brand()).matches("^[a-zA-Z0-9 -]+$");
12+
}
13+
14+
@Test
15+
void testModel() {
16+
assertThat(faker.camera().model()).matches("^[a-zA-Z0-9 -]+$");
17+
}
18+
19+
@Test
20+
void testBrandWithModel() {
21+
assertThat(faker.camera().brandWithModel()).matches("^[a-zA-Z0-9 -]+$");
22+
}
23+
}

src/test/java/net/datafaker/integration/FakerIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
9898
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.breakingBad());
9999
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.buffy());
100100
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.business());
101+
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.camera());
101102
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.cat());
102103
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.chuckNorris());
103104
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.coin());

0 commit comments

Comments
 (0)