-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from Tahanima/feature/add-measurement-faker
Added Measurement Faker
- Loading branch information
Showing
7 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,6 +242,7 @@ Providers | |
* Marketing | ||
* Matz | ||
* MBTI | ||
* Measurement | ||
* Medical | ||
* Military | ||
* Minecraft | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package net.datafaker; | ||
|
||
public class Measurement { | ||
|
||
private final Faker faker; | ||
|
||
protected Measurement(Faker faker) { | ||
this.faker = faker; | ||
} | ||
|
||
/** | ||
* This method generates a random height measurement. | ||
* | ||
* @return a string of height measurement. | ||
*/ | ||
public String height() { | ||
return faker.fakeValuesService().resolve("measurement.height", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random length measurement. | ||
* | ||
* @return a string of length measurement. | ||
*/ | ||
public String length() { | ||
return faker.fakeValuesService().resolve("measurement.length", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random volume measurement. | ||
* | ||
* @return a string of volume measurement. | ||
*/ | ||
public String volume() { | ||
return faker.fakeValuesService().resolve("measurement.volume", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random weight measurement. | ||
* | ||
* @return a string of weight measurement. | ||
*/ | ||
public String weight() { | ||
return faker.fakeValuesService().resolve("measurement.weight", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random metric height measurement. | ||
* | ||
* @return a string of metric height measurement. | ||
*/ | ||
public String metricHeight() { | ||
return faker.fakeValuesService().resolve("measurement.metric_height", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random metric length measurement. | ||
* | ||
* @return a string of metric length measurement. | ||
*/ | ||
public String metricLength() { | ||
return faker.fakeValuesService().resolve("measurement.metric_length", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random metric volume measurement. | ||
* | ||
* @return a string of metric volume measurement. | ||
*/ | ||
public String metricVolume() { | ||
return faker.fakeValuesService().resolve("measurement.metric_volume", this, faker); | ||
} | ||
|
||
/** | ||
* This method generates a random metric weight measurement. | ||
* | ||
* @return a string of metric weight measurement. | ||
*/ | ||
public String metricWeight() { | ||
return faker.fakeValuesService().resolve("measurement.metric_weight", this, faker); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.datafaker; | ||
|
||
import org.junit.jupiter.api.RepeatedTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class MeasurementTest extends AbstractFakerTest { | ||
|
||
public static final String WORDS = "^[a-z ]+$"; | ||
|
||
@RepeatedTest(10) | ||
void testHeight() { | ||
assertThat(faker.measurement().height()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testLength() { | ||
assertThat(faker.measurement().length()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testVolume() { | ||
assertThat(faker.measurement().volume()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testWeight() { | ||
assertThat(faker.measurement().weight()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testMetricHeight() { | ||
assertThat(faker.measurement().metricHeight()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testMetricLength() { | ||
assertThat(faker.measurement().metricLength()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testMetricVolume() { | ||
assertThat(faker.measurement().metricVolume()).matches(WORDS); | ||
} | ||
|
||
@RepeatedTest(10) | ||
void testMetricWeight() { | ||
assertThat(faker.measurement().metricWeight()).matches(WORDS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters