Skip to content

Commit

Permalink
Merge pull request #696 from snuyanzin/mountains
Browse files Browse the repository at this point in the history
Add mountains support
  • Loading branch information
codingricky authored Jan 12, 2022
2 parents 8f20178 + 8d7036a commit a8b8ff0
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/github/javafaker/Faker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/github/javafaker/Mountain.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
77 changes: 77 additions & 0 deletions src/main/resources/en/mountain.yml
Original file line number Diff line number Diff line change
@@ -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"
]
21 changes: 21 additions & 0 deletions src/test/java/com/github/javafaker/MountainTest.java
Original file line number Diff line number Diff line change
@@ -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()));
}
}

0 comments on commit a8b8ff0

Please sign in to comment.