Skip to content

Commit

Permalink
Merge d7bd3dd into 33f96e1
Browse files Browse the repository at this point in the history
  • Loading branch information
egoetschalckx committed Aug 26, 2019
2 parents 33f96e1 + d7bd3dd commit abfbb86
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -102,6 +102,7 @@ Fakers
* LordOfTheRings
* Lorem
* Matz
* Military
* Music
* Name
* Nation
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/github/javafaker/Faker.java
Expand Up @@ -93,6 +93,7 @@ public class Faker {
private final Relationships relationships;
private final Nation nation;
private final Dune dune;
private final Military military;

public Faker() {
this(Locale.ENGLISH);
Expand Down Expand Up @@ -187,6 +188,7 @@ public Faker(Locale locale, Random random) {
this.relationships = new Relationships(this);
this.nation = new Nation(this);
this.dune = new Dune(this);
this.military = new Military(this);
}

/**
Expand Down Expand Up @@ -608,7 +610,11 @@ public Nation nation() {
public Dune dune() {
return dune;
}


public Military military() {
return military;
}

public String resolve(String key) {
return this.fakeValuesService.resolve(key, this, this);
}
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/github/javafaker/Military.java
@@ -0,0 +1,31 @@
package com.github.javafaker;

public class Military {

private final Faker faker;

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

public String armyRank() {
return faker.fakeValuesService().fetchString("military.army_rank");
}

public String marinesRank() {
return faker.fakeValuesService().fetchString("military.marines_rank");
}

public String navyRank() {
return faker.fakeValuesService().fetchString("military.navy_rank");
}

public String airForceRank() {
return faker.fakeValuesService().fetchString("military.air_force_rank");
}

public String dodPaygrade() {
return faker.fakeValuesService().fetchString("military.dod_paygrade");
}

}
36 changes: 36 additions & 0 deletions src/test/java/com/github/javafaker/MilitaryTest.java
@@ -0,0 +1,36 @@
package com.github.javafaker;

import com.github.javafaker.repeating.Repeat;
import org.junit.Test;

import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;

public class MilitaryTest extends AbstractFakerTest {

@Test
public void armyRank() {
assertThat(faker.military().armyRank(), matchesRegularExpression("[A-Za-z ]+"));
}

@Test
public void marinesRank() {
assertThat(faker.military().marinesRank(), matchesRegularExpression("[A-Za-z ]+"));
}

@Test
public void navyRank() {
assertThat(faker.military().navyRank(), matchesRegularExpression("[A-Za-z ]+"));
}

@Test
public void airForceRank() {
assertThat(faker.military().airForceRank(), matchesRegularExpression("[A-Za-z ]+"));
}

@Test
public void dodPaygrade() {
assertThat(faker.military().dodPaygrade(), matchesRegularExpression("((E|O)\\-([0-9]|10)$)|Special"));
}

}
Expand Up @@ -159,6 +159,7 @@ public void testAllFakerMethodsThatReturnStrings() throws Exception {
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.relationships());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.nation());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.dune());
testAllMethodsThatReturnStringsActuallyReturnStrings(faker.military());
}

private void testAllMethodsThatReturnStringsActuallyReturnStrings(Object object) throws Exception {
Expand Down

0 comments on commit abfbb86

Please sign in to comment.