Skip to content

Added camera faker #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Providers
* Business
* CNPJ [Brazilian National Registry of Legal Entities](https://en.wikipedia.org/wiki/CNPJ)
* CPF [Brazilian individual taxpayer registry identification](https://en.wikipedia.org/wiki/CPF_number)
* Camera
* Cat
* ChuckNorris
* Code
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/net/datafaker/Camera.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package net.datafaker;

public class Camera {

private final Faker faker;

protected Camera(Faker faker) {
this.faker = faker;
}

/**
* This method generates a random camera brand.
*
* @return a string of camera brand.
*/
public String brand() {
return faker.fakeValuesService().resolve("camera.brand", this, faker);
}

/**
* This method generates a random camera model.
*
* @return a string of camera model.
*/
public String model() {
return faker.fakeValuesService().resolve("camera.model", this, faker);
}

/**
* This method generates a random camera brand with a model.
*
* @return a string of camera brand with a model.
*/
public String brandWithModel() {
return faker.fakeValuesService().resolve("camera.brand_with_model", this, faker);
}
}
4 changes: 4 additions & 0 deletions src/main/java/net/datafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ public Business business() {
return getProvider(Business.class, () -> new Business(this));
}

public Camera camera() {
return getProvider(Camera.class, () -> new Camera(this));
}

public Cat cat() {
return getProvider(Cat.class, () -> new Cat(this));
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/datafaker/service/files/EnFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public String getPath() {
"brooklyn_nine_nine.yml",
"buffy.yml",
"business.yml",
"camera.yml",
// "cannabis.yml",
"chuck_norris.yml",
"code.yml",
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions src/test/java/net/datafaker/CameraTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.datafaker;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class CameraTest extends AbstractFakerTest {

@Test
void testBrand() {
assertThat(faker.camera().brand()).matches("^[a-zA-Z0-9 -]+$");
}

@Test
void testModel() {
assertThat(faker.camera().model()).matches("^[a-zA-Z0-9 -]+$");
}

@Test
void testBrandWithModel() {
assertThat(faker.camera().brandWithModel()).matches("^[a-zA-Z0-9 -]+$");
}
}
1 change: 1 addition & 0 deletions src/test/java/net/datafaker/integration/FakerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void testAllFakerMethodsThatReturnStrings(Locale locale, Random random) throws E
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.breakingBad());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.buffy());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.business());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.camera());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.cat());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.chuckNorris());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.coin());
Expand Down