diff --git a/pom.xml b/pom.xml index eb425a2..fe6d5b7 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,12 @@ org.easytesting fest-assert-core - 2.0M8 + 2.0M9-SNAPSHOT + + + org.easytesting + fest-reflect + 1.4.1-SNAPSHOT org.easytesting diff --git a/src/main/java/org/fest/assertions/examples/data/Movie.java b/src/main/java/org/fest/assertions/examples/data/Movie.java index 0c16015..e5b46cb 100644 --- a/src/main/java/org/fest/assertions/examples/data/Movie.java +++ b/src/main/java/org/fest/assertions/examples/data/Movie.java @@ -4,8 +4,8 @@ import java.util.Date; public class Movie { - private final String title; - private final Date releaseDate; + private String title; + private Date releaseDate; public Movie(String title, Date releaseDate) { super(); @@ -16,6 +16,14 @@ public class Movie { public String getTitle() { return title; } + + public void setTitle(String title) { + this.title = title; + } + + public void setReleaseDate(Date releaseDate) { + this.releaseDate = releaseDate; + } public Date getReleaseDate() { return releaseDate; diff --git a/src/test/java/org/fest/reflect/examples/BasicExamples.java b/src/test/java/org/fest/reflect/examples/BasicExamples.java new file mode 100644 index 0000000..9bcd5f2 --- /dev/null +++ b/src/test/java/org/fest/reflect/examples/BasicExamples.java @@ -0,0 +1,27 @@ +package org.fest.reflect.examples; + +import static org.fest.assertions.api.Assertions.assertThat; +import static org.fest.reflect.core.Reflection.constructor; +import static org.fest.reflect.core.Reflection.method; + +import java.util.Date; + +import org.junit.Test; + +import org.fest.assertions.examples.data.Movie; + +public class BasicExamples { + + @Test + public void constructor_and_method_call_example() throws Exception { + Date date = new Date(); + Movie movie = constructor().withParameterTypes(String.class, Date.class).in(Movie.class) + .newInstance("Pulp Fiction", date); + assertThat(movie).isNotNull(); + assertThat(movie.getTitle()).isEqualTo("Pulp Fiction"); + assertThat(movie.getReleaseDate()).isEqualTo(date); + + method("setTitle").withParameterTypes(String.class).in(movie).invoke("Kill Bill"); + assertThat(movie.getTitle()).isEqualTo("Kill Bill"); + } +}