Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-06-22 18:54:01 +0000
committerBrian Vosburgh2017-05-18 22:37:20 +0000
commit170f9c6c0c84726d35065c0587045b9744e4c81c (patch)
tree62367c50c7d09dc11886cd6fb699dfe27697e2ae /common/tests
parent92e73fe18ef5f2625ec37f381173d139c835e83f (diff)
downloadwebtools.dali-170f9c6c0c84726d35065c0587045b9744e4c81c.tar.gz
webtools.dali-170f9c6c0c84726d35065c0587045b9744e4c81c.tar.xz
webtools.dali-170f9c6c0c84726d35065c0587045b9744e4c81c.zip
add PropertyPluggablePropertyValueModelAdapter
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java2
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java2
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyValueModelToolsTests.java65
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/EqualsTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/IsIdenticalTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateTests.java14
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateWrapperTests.java8
7 files changed, 70 insertions, 33 deletions
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java
index af4dc8ab43..73a410eec3 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java
@@ -24,7 +24,7 @@ public class DoubleModifiablePropertyValueModelTests
@Override
protected PropertyValueModel<String> buildDoubleModel(ModifiablePropertyValueModel<ModifiablePropertyValueModel<String>> modelModel) {
- return PropertyValueModelTools.wrapModifiable(modelModel);
+ return PropertyValueModelTools.doubleWrapModifiable(modelModel);
}
protected ModifiablePropertyValueModel<String> getDoubleModel() {
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java
index d6a5fe85e9..ce392ccc24 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java
@@ -55,7 +55,7 @@ public class DoublePropertyValueModelTests
}
protected PropertyValueModel<String> buildDoubleModel(ModifiablePropertyValueModel<ModifiablePropertyValueModel<String>> modelModel) {
- return PropertyValueModelTools.wrap(modelModel);
+ return PropertyValueModelTools.doubleWrap(modelModel);
}
@Override
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyValueModelToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyValueModelToolsTests.java
index 1943731ab0..c5ff11b419 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyValueModelToolsTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyValueModelToolsTests.java
@@ -35,44 +35,81 @@ public class PropertyValueModelToolsTests
super(name);
}
+ public void testValueEquals() {
+ String string = "foo";
+ ModifiablePropertyValueModel<String> stringModel = new SimplePropertyValueModel<>("");
+ PropertyValueModel<Boolean> booleanModel = PropertyValueModelTools.valueEquals(stringModel, string);
+ LocalListener listener = new LocalListener();
+ booleanModel.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
+
+ listener.event = null;
+ assertEquals(Boolean.FALSE, booleanModel.getValue());
+ assertEquals("", stringModel.getValue());
+ assertNull(listener.event);
+
+ listener.event = null;
+ stringModel.setValue("foo");
+ assertEquals(Boolean.TRUE, booleanModel.getValue());
+ assertEquals("foo", stringModel.getValue());
+ assertEquals(Boolean.TRUE, listener.event.getNewValue());
+
+ listener.event = null;
+ stringModel.setValue("bar");
+ assertEquals(Boolean.FALSE, booleanModel.getValue());
+ assertEquals("bar", stringModel.getValue());
+ assertEquals(Boolean.FALSE, listener.event.getNewValue());
+
+ listener.event = null;
+ stringModel.setValue(null);
+ assertNull(booleanModel.getValue());
+ assertNull(stringModel.getValue());
+ assertNull(listener.event.getNewValue());
+
+ listener.event = null;
+ booleanModel.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertNull(booleanModel.getValue());
+ assertNull(stringModel.getValue());
+ assertNull(listener.event);
+ }
+
public void testModifiablePropertyValueModel() {
ModifiablePropertyValueModel<String> doubleStringModel = new SimplePropertyValueModel<>("foofoo");
PluggableModifiablePropertyValueModel.Adapter.Factory<String> factory = new HalfStringModelAdapter.Factory(doubleStringModel);
ModifiablePropertyValueModel<String> halfStringModel = PropertyValueModelTools.modifiablePropertyValueModel(factory);
- HalfStringListener halfStringListener = new HalfStringListener();
- halfStringModel.addPropertyChangeListener(PropertyValueModel.VALUE, halfStringListener);
+ LocalListener listener = new LocalListener();
+ halfStringModel.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- halfStringListener.event = null;
+ listener.event = null;
assertEquals("foofoo", doubleStringModel.getValue());
assertEquals("foo", halfStringModel.getValue());
- assertNull(halfStringListener.event);
+ assertNull(listener.event);
- halfStringListener.event = null;
+ listener.event = null;
halfStringModel.setValue("bar");
assertEquals("bar", halfStringModel.getValue());
assertEquals("barbar", doubleStringModel.getValue());
- assertEquals("bar", halfStringListener.event.getNewValue());
+ assertEquals("bar", listener.event.getNewValue());
- halfStringListener.event = null;
+ listener.event = null;
halfStringModel.setValue("bar");
assertEquals("bar", halfStringModel.getValue());
assertEquals("barbar", doubleStringModel.getValue());
- assertNull(halfStringListener.event);
+ assertNull(listener.event);
- halfStringListener.event = null;
+ listener.event = null;
doubleStringModel.setValue("xxxxxx");
assertEquals("xxx", halfStringModel.getValue());
assertEquals("xxxxxx", doubleStringModel.getValue());
- assertEquals("xxx", halfStringListener.event.getNewValue());
+ assertEquals("xxx", listener.event.getNewValue());
- halfStringListener.event = null;
- halfStringModel.removePropertyChangeListener(PropertyValueModel.VALUE, halfStringListener);
+ listener.event = null;
+ halfStringModel.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
assertNull(halfStringModel.getValue());
assertEquals("xxxxxx", doubleStringModel.getValue());
- assertNull(halfStringListener.event);
+ assertNull(listener.event);
}
- public static class HalfStringListener
+ public static class LocalListener
implements PropertyChangeListener
{
public PropertyChangeEvent event;
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/EqualsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/EqualsTests.java
index 9da51ccd28..5be5112ddd 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/EqualsTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/EqualsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Oracle. All rights reserved.
+ * Copyright (c) 2013, 2016 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,7 +19,7 @@ import org.eclipse.jpt.common.utility.tests.internal.TestTools;
public class EqualsTests
extends TestCase
{
- private Predicate<Integer> equalPredicate;
+ private Predicate<Object> equalPredicate;
public EqualsTests(String name) {
@@ -48,7 +48,7 @@ public class EqualsTests
}
public void testEquals() {
- Predicate<Integer> equalPredicate2 = PredicateTools.isEqual(new Integer(42));
+ Predicate<Object> equalPredicate2 = PredicateTools.isEqual(new Integer(42));
assertEquals(this.equalPredicate, equalPredicate2);
assertEquals(this.equalPredicate.hashCode(), equalPredicate2.hashCode());
assertFalse(this.equalPredicate.equals(IsNotNull.instance()));
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/IsIdenticalTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/IsIdenticalTests.java
index b081668834..d825f45194 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/IsIdenticalTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/IsIdenticalTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Oracle. All rights reserved.
+ * Copyright (c) 2013, 2016 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,7 +19,7 @@ public class IsIdenticalTests
extends TestCase
{
private Integer integer = Integer.valueOf(42);
- private Predicate<Integer> identityPredicate;
+ private Predicate<Object> identityPredicate;
public IsIdenticalTests(String name) {
@@ -48,7 +48,7 @@ public class IsIdenticalTests
}
public void testEquals() {
- Predicate<Integer> identityPredicate2 = PredicateTools.isIdentical(new Integer(42));
+ Predicate<Object> identityPredicate2 = PredicateTools.isIdentical(new Integer(42));
assertEquals(this.identityPredicate, identityPredicate2);
assertEquals(this.identityPredicate.hashCode(), identityPredicate2.hashCode());
assertFalse(this.identityPredicate.equals(IsNotNull.instance()));
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateTests.java
index c7d8a7872f..565a7c3bc1 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2016 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -26,7 +26,7 @@ public class PredicateTests
}
public void testPredicateAdapter() {
- Predicate<String> filter = new PredicateAdapter<String>();
+ Predicate<String> filter = new PredicateAdapter<>();
assertFalse(filter.evaluate(""));
assertFalse(filter.evaluate(null));
assertFalse(filter.evaluate("foo"));
@@ -34,7 +34,7 @@ public class PredicateTests
}
public void testPredicateAdapter_toString() {
- Predicate<String> filter = new PredicateAdapter<String>();
+ Predicate<String> filter = new PredicateAdapter<>();
assertNotNull(filter.toString());
}
@@ -73,7 +73,7 @@ public class PredicateTests
}
public void testNotNullPredicate() {
- Predicate<String> filter = PredicateTools.isNotNull();
+ Predicate<Object> filter = PredicateTools.isNotNull();
assertTrue(filter.evaluate(""));
assertFalse(filter.evaluate(null));
assertTrue(filter.evaluate("foo"));
@@ -81,12 +81,12 @@ public class PredicateTests
}
public void testNotNullPredicate_toString() {
- Predicate<String> filter = PredicateTools.isNotNull();
+ Predicate<Object> filter = PredicateTools.isNotNull();
assertNotNull(filter.toString());
}
public void testNullPredicate() {
- Predicate<String> filter = PredicateTools.isNull();
+ Predicate<Object> filter = PredicateTools.isNull();
assertFalse(filter.evaluate(""));
assertTrue(filter.evaluate(null));
assertFalse(filter.evaluate("foo"));
@@ -94,7 +94,7 @@ public class PredicateTests
}
public void testNullPredicate_toString() {
- Predicate<String> filter = PredicateTools.isNull();
+ Predicate<Object> filter = PredicateTools.isNull();
assertNotNull(filter.toString());
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateWrapperTests.java
index 517ea3a25c..81ad67011d 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateWrapperTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/predicate/PredicateWrapperTests.java
@@ -20,8 +20,8 @@ import org.eclipse.jpt.common.utility.tests.internal.TestTools;
public class PredicateWrapperTests
extends TestCase
{
- private Predicate<Integer> wrappedPredicate;
- private PredicateWrapper<Integer> predicateWrapper;
+ private Predicate<Object> wrappedPredicate;
+ private PredicateWrapper<Object> predicateWrapper;
public PredicateWrapperTests(String name) {
@@ -32,7 +32,7 @@ public class PredicateWrapperTests
protected void setUp() throws Exception {
super.setUp();
this.wrappedPredicate = PredicateTools.isEqual(Integer.valueOf(42));
- this.predicateWrapper = (PredicateWrapper<Integer>) PredicateTools.wrap(this.wrappedPredicate);
+ this.predicateWrapper = (PredicateWrapper<Object>) PredicateTools.wrap(this.wrappedPredicate);
}
@Override
@@ -59,7 +59,7 @@ public class PredicateWrapperTests
}
public void testEquals() {
- PredicateWrapper<Integer> predicateWrapper2 = (PredicateWrapper<Integer>) PredicateTools.wrap(this.wrappedPredicate);
+ PredicateWrapper<Object> predicateWrapper2 = (PredicateWrapper<Object>) PredicateTools.wrap(this.wrappedPredicate);
assertEquals(this.predicateWrapper, predicateWrapper2);
assertEquals(this.predicateWrapper.hashCode(), predicateWrapper2.hashCode());
assertFalse(this.predicateWrapper.equals(IsNotNull.instance()));

Back to the top