Add color name
* add Color#name * add german color names
This commit is contained in:
committed by
Ricky Yim
parent
8160468737
commit
8197ee042d
@@ -0,0 +1,15 @@
|
||||
package com.github.javafaker;
|
||||
|
||||
import com.github.javafaker.service.FakeValuesServiceInterface;
|
||||
|
||||
public class Color {
|
||||
private final FakeValuesServiceInterface fakeValuesService;
|
||||
|
||||
public Color(FakeValuesServiceInterface fakeValuesService) {
|
||||
this.fakeValuesService = fakeValuesService;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return fakeValuesService.fetchString("color.name");
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class Faker implements Resolver {
|
||||
private final Address address;
|
||||
private final Business business;
|
||||
private final Book book;
|
||||
private final Color color;
|
||||
private final Company company;
|
||||
private final Options options;
|
||||
private final Code code;
|
||||
@@ -59,6 +60,7 @@ public class Faker implements Resolver {
|
||||
this.address = new Address(this, name, proxiedFakeValueService, randomService);
|
||||
this.book = new Book(this, proxiedFakeValueService);
|
||||
this.business = new Business(proxiedFakeValueService);
|
||||
this.color = new Color(proxiedFakeValueService);
|
||||
this.company = new Company(this, proxiedFakeValueService);
|
||||
this.options = new Options(randomService);
|
||||
this.code = new Code(randomService);
|
||||
@@ -138,6 +140,10 @@ public class Faker implements Resolver {
|
||||
return business;
|
||||
}
|
||||
|
||||
public Color color() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Company company() {
|
||||
return company;
|
||||
}
|
||||
@@ -179,4 +185,5 @@ public class Faker implements Resolver {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ de:
|
||||
- "#{first_name} #{last_name}"
|
||||
- "#{first_name} #{last_name}"
|
||||
|
||||
color:
|
||||
name: [rot, grün, blau, gelb, lila, weiß, schwarz, orange, rosa, grau, braun, violett, türkis]
|
||||
|
||||
phone_number:
|
||||
formats: ['(0###) #########', '(0####) #######', '+49-###-#######', '+49-####-########']
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.github.javafaker;
|
||||
|
||||
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ColorTest {
|
||||
|
||||
private Faker faker;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
faker = new Faker();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertThat(faker.color().name(), matchesRegularExpression("(\\w+ ?){1,2}"));
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,7 @@ public class FakerIT {
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.address());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.business());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.book());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.color());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.company());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.internet());
|
||||
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.lorem());
|
||||
|
||||
Reference in New Issue
Block a user