You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2016/04/24 22:48:58 UTC

[1/2] wicket git commit: Add tests for IModel#orElse() and #orElseGet()

Repository: wicket
Updated Branches:
  refs/heads/master 506ada457 -> e0d962bd5


Add tests for IModel#orElse() and #orElseGet()


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e83d6b69
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e83d6b69
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e83d6b69

Branch: refs/heads/master
Commit: e83d6b69d9a2b338107ae4fc935c2ab95e976597
Parents: 506ada4
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun Apr 24 22:47:24 2016 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sun Apr 24 22:47:24 2016 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/model/IModelTest.java     | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e83d6b69/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
index 402bca6..1394253 100644
--- a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
@@ -20,8 +20,6 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.nullValue;
 
-import java.io.Serializable;
-
 import org.apache.wicket.lambda.WicketBiFunction;
 import org.apache.wicket.lambda.WicketFunction;
 import org.apache.wicket.model.lambda.Address;
@@ -146,4 +144,24 @@ public class IModelTest extends Assert
 
 		assertThat(applyModel.getObject().getNumber(), is(person.getAddress().getNumber() * 2));
 	}
+
+	@Test
+	public void orElse()
+	{
+		person.setName(null);
+		String defaultName = "Default name";
+		IModel<String> defaultNameModel = IModel.of(person).map(Person::getName).orElse(defaultName);
+
+		assertThat(defaultNameModel.getObject(), is(equalTo(defaultName)));
+	}
+
+	@Test
+	public void orElseGet()
+	{
+		person.setName(null);
+		String defaultName = "Default name";
+		IModel<String> defaultNameModel = IModel.of(person).map(Person::getName).orElseGet(() -> defaultName);
+
+		assertThat(defaultNameModel.getObject(), is(equalTo(defaultName)));
+	}
 }


[2/2] wicket git commit: Give a better name for the variable used as a second parameter for #mapWith() tests

Posted by mg...@apache.org.
Give a better name for the variable used as a second parameter for #mapWith() tests


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e0d962bd
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e0d962bd
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e0d962bd

Branch: refs/heads/master
Commit: e0d962bd5d32c63403dc775b80a4022fce511679
Parents: e83d6b6
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun Apr 24 22:48:16 2016 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sun Apr 24 22:48:16 2016 +0200

----------------------------------------------------------------------
 .../test/java/org/apache/wicket/model/IModelTest.java   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e0d962bd/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
index 1394253..996a758 100644
--- a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
@@ -87,8 +87,8 @@ public class IModelTest extends Assert
 	{
 		IModel<String> janeModel = IModel.of("Jane");
 		WicketBiFunction<Person, String, String> function =
-				(WicketBiFunction<Person, String, String>) (person1, nth) ->
-						person1.getName() + " is in relationship with " + nth;
+				(WicketBiFunction<Person, String, String>) (person1, other) ->
+						person1.getName() + " is in relationship with " + other;
 		IModel<String> relationShipModel = IModel.of(person).mapWith(function, janeModel);
 		assertThat(relationShipModel.getObject(), is(equalTo("John is in relationship with Jane")));
 	}
@@ -98,8 +98,8 @@ public class IModelTest extends Assert
 	{
 		IModel<String> janeModel = IModel.of(null);
 		WicketBiFunction<Person, String, String> function =
-				(WicketBiFunction<Person, String, String>) (person1, nth) ->
-						person1.getName() + " is in relationship with " + nth;
+				(WicketBiFunction<Person, String, String>) (person1, other) ->
+						person1.getName() + " is in relationship with " + other;
 		IModel<String> relationShipModel = IModel.of(person).mapWith(function, janeModel);
 		assertThat(relationShipModel.getObject(), is(nullValue()));
 	}
@@ -109,8 +109,8 @@ public class IModelTest extends Assert
 	{
 		IModel<String> janeModel = null;
 		WicketBiFunction<Person, String, String> function =
-				(WicketBiFunction<Person, String, String>) (person1, nth) ->
-						person1.getName() + " is in relationship with " + nth;
+				(WicketBiFunction<Person, String, String>) (person1, other) ->
+						person1.getName() + " is in relationship with " + other;
 		IModel<String> relationShipModel = IModel.of(person).mapWith(function, janeModel);
 		assertThat(relationShipModel.getObject(), is(nullValue()));
 	}