From 8d7036a66fcad54bf652d1bae91fa4ab668c1334 Mon Sep 17 00:00:00 2001 From: Sergey Nuyanzin Date: Tue, 4 Jan 2022 08:55:59 +0100 Subject: [PATCH] Add mountains support --- src/main/java/com/github/javafaker/Faker.java | 4 + .../java/com/github/javafaker/Mountain.java | 17 ++++ .../javafaker/service/files/EnFile.java | 1 + src/main/resources/en/mountain.yml | 77 +++++++++++++++++++ .../com/github/javafaker/MountainTest.java | 21 +++++ 5 files changed, 120 insertions(+) create mode 100644 src/main/java/com/github/javafaker/Mountain.java create mode 100644 src/main/resources/en/mountain.yml create mode 100644 src/test/java/com/github/javafaker/MountainTest.java diff --git a/src/main/java/com/github/javafaker/Faker.java b/src/main/java/com/github/javafaker/Faker.java index 63ac4a4d..751fb779 100644 --- a/src/main/java/com/github/javafaker/Faker.java +++ b/src/main/java/com/github/javafaker/Faker.java @@ -106,6 +106,7 @@ public class Faker { private final Barcode barcode; private final Sip sip; private final EnglandFootBall englandfootball; + private final Mountain mountain; public Faker() { this(Locale.ENGLISH); @@ -221,6 +222,7 @@ public Faker(FakeValuesService fakeValuesService, RandomService random) { this.barcode = new Barcode(this); this.sip = new Sip(this); this.englandfootball = new EnglandFootBall(this); + this.mountain = new Mountain(this); } /** @@ -687,6 +689,8 @@ public StarCraft starCraft() { public EnglandFootBall englandfootball() { return englandfootball; } + public Mountain mountain() { return mountain; } + public String resolve(String key) { return this.fakeValuesService.resolve(key, this, this); } diff --git a/src/main/java/com/github/javafaker/Mountain.java b/src/main/java/com/github/javafaker/Mountain.java new file mode 100644 index 00000000..ce34897b --- /dev/null +++ b/src/main/java/com/github/javafaker/Mountain.java @@ -0,0 +1,17 @@ +package com.github.javafaker; + +public class Mountain { + private final Faker faker; + + protected Mountain(Faker faker) { + this.faker = faker; + } + + public String name() { + return faker.fakeValuesService().resolve("mountain.name", this, faker); + } + + public String range() { + return faker.fakeValuesService().resolve("mountain.range", this, faker); + } +} diff --git a/src/main/java/com/github/javafaker/service/files/EnFile.java b/src/main/java/com/github/javafaker/service/files/EnFile.java index 10f0c0ca..4a77ac01 100644 --- a/src/main/java/com/github/javafaker/service/files/EnFile.java +++ b/src/main/java/com/github/javafaker/service/files/EnFile.java @@ -120,6 +120,7 @@ public String getPath() { "military.yml", "most_interesting_man_in_the_world.yml", "movie.yml", + "mountain.yml", "music.yml", "myst.yml", "name.yml", diff --git a/src/main/resources/en/mountain.yml b/src/main/resources/en/mountain.yml new file mode 100644 index 00000000..4a0cf8ad --- /dev/null +++ b/src/main/resources/en/mountain.yml @@ -0,0 +1,77 @@ +en: + faker: + mountain: + range: [ + "Himalayas", + "Karakoram", + "Hindu Kush", + "Pamirs", + "Hengduan Mountains", + "Tian Shan", + "Kunlun", + "Transhimalaya", + "Andes", + "Hindu Raj", + "Alaska Range", + "Saint Elias Mountains", + "Caucasus Mountains" + ] + name: [ + "Everest", + "Cerro Aconcagua", + "Denali", + "Kilimanjaro", + "Elbrus", + "Vinson Massif", + "Puncak Jaya", + "K2", + "Kangchenjunga", + "Lhotse", + "Makalu", + "Mount Logan", + "Pico de Orizaba", + "Mount Saint Elias", + "Popocatépetl", + "Mount Foraker", + "Mount Lucania", + "Iztaccíhuatl", + "King Peak", + "Mount Bona", + "Cristobal Colon", + "Citlaltepetl", + "Mount Blanc", + "Damavand", + "Klyuchevskaya", + "Nanga Parbat", + "Mauna Kea", + "Jengish Chokusu (Pik Pobeda)", + "Chimborazo", + "Bogda Shan", + "Namcha Barwa", + "Kinabalu", + "Mount Rainier", + "Ras Dashen", + "Tajumulco", + "Pico Bolivar", + "Mount Fairweather", + "Margherita", + "Kangchenjunga", + "Tirich Mir", + "Koryaksky", + "Gunung Agung", + "Popocatepetl", + "Mount Whitney", + "Haleakala", + "Shiveluch", + "Nanda Devi", + "Mount Waddington", + "Mount Marcus Baker", + "Manaslu", + "Ojos del Salado", + "Monte San Valentin", + "Mount Fuji", + "Mount Kenya", + "Mount Ararat", + "Dhaulagiri I", + "Etna" + ] diff --git a/src/test/java/com/github/javafaker/MountainTest.java b/src/test/java/com/github/javafaker/MountainTest.java new file mode 100644 index 00000000..0eac0223 --- /dev/null +++ b/src/test/java/com/github/javafaker/MountainTest.java @@ -0,0 +1,21 @@ +package com.github.javafaker; + +import org.junit.Test; + +import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + +public class MountainTest extends AbstractFakerTest { + @Test + public void testMountainName() { + String mountainName = faker.mountain().name(); + assertThat(mountainName, not(isEmptyOrNullString())); + } + + @Test + public void testMountainLeague() { + String mountainLeague = faker.mountain().range(); + assertThat(mountainLeague, not(isEmptyOrNullString())); + } +}