diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 74e642288..1560c5bd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ First and foremost thanks to anyone who contributes, very much appreciated. ## Guidelines -- Need to maintain compatibility with Java 1.6 (and Android). Therefore any attempt to migrate to 1.6 JDKs and above will not be merged back in. +- The minimum supported Java version is **1.8**. Please keep source/target compatibility at Java 1.8 and avoid APIs introduced in later JDKs. This baseline was raised from 1.6 so the project can stay on maintained dependency versions (for example `snakeyaml` 2.x, which requires Java 8+). Android is still supported on API levels that provide Java 8 language features (via desugaring), so no Android-specific artifact/classifier is required anymore. - If you add new faker classes like `Address`, `Country`, and `Number` they should be accompanied by a unit test. Where relevant please add more assertions to the `com.github.javafaker.integration.FakerIT` class. - If you add a new faker class, update the `README.md`. @@ -13,3 +13,4 @@ First and foremost thanks to anyone who contributes, very much appreciated. ## Building - Should be as easy as running `mvn clean install` on the root directory +- Requires a JDK 8 or newer to build diff --git a/README.md b/README.md index d1385324e..1d211c9fd 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ Java Faker This library is a port of Ruby's [faker](https://github.com/stympy/faker) gem (as well as Perl's Data::Faker library) that generates fake data. It's useful when you're developing a new project and need some pretty data for showcase. +Requirements +----- +* Java 1.8 or newer. +* Android is supported on API levels that enable Java 8 language features (via [desugaring](https://developer.android.com/studio/write/java8-support)). + Usage ----- In pom.xml, add the following xml stanza between ` ... ` diff --git a/pom.xml b/pom.xml index f936524bc..d9aa49f23 100644 --- a/pom.xml +++ b/pom.xml @@ -53,8 +53,7 @@ org.yaml snakeyaml - 1.26 - android + 2.4 com.github.mifmif @@ -112,8 +111,8 @@ maven-compiler-plugin 3.7.0 - 1.6 - 1.6 + 1.8 + 1.8 diff --git a/src/test/java/com/github/javafaker/service/FakeValuesTest.java b/src/test/java/com/github/javafaker/service/FakeValuesTest.java index 1710efe6e..7f8948f3e 100644 --- a/src/test/java/com/github/javafaker/service/FakeValuesTest.java +++ b/src/test/java/com/github/javafaker/service/FakeValuesTest.java @@ -3,7 +3,9 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; import java.util.Locale; +import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.*; @@ -58,4 +60,30 @@ public void getAValueFromALocaleThatCantBeLoaded() { assertThat(fakeValues.get(PATH), is(nullValue())); } + @Test + public void getReturnsAMapForALoadedPath() { + assertThat(fakeValues.get(PATH), is(instanceOf(Map.class))); + } + + @Test + public void yamlSequencesAreLoadedAsLists() { + Map address = (Map) fakeValues.get(PATH); + Object cityPrefix = address.get("city_prefix"); + assertThat(cityPrefix, is(instanceOf(List.class))); + assertThat((List) cityPrefix, hasItem("North")); + } + + @Test + public void nestedYamlMappingsAreLoadedAsMaps() { + Map address = (Map) fakeValues.get(PATH); + Object countryByCode = address.get("country_by_code"); + assertThat(countryByCode, is(instanceOf(Map.class))); + assertThat((Map) countryByCode, hasEntry("AF", "Afghanistan")); + } + + @Test + public void getIsCachedAcrossInvocations() { + assertThat(fakeValues.get(PATH), is(sameInstance(fakeValues.get(PATH)))); + } + }