Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-07-12 22:11:12 +0000
committerBrian Vosburgh2017-05-18 22:37:46 +0000
commitc06255a0b27d949afea7c27a528e2fb913908eca (patch)
tree87ee2e9199cac892d43b17f8e119a9a0667e8807 /common/tests
parent246f11c9c3a8e9a2a55dd00f0069ed004f6da700 (diff)
downloadwebtools.dali-c06255a0b27d949afea7c27a528e2fb913908eca.tar.gz
webtools.dali-c06255a0b27d949afea7c27a528e2fb913908eca.tar.xz
webtools.dali-c06255a0b27d949afea7c27a528e2fb913908eca.zip
delete Transformation PVMs
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/bindings/ComboBoxModelBindingUITest.java21
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java118
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java20
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationModifiablePropertyValueModelTests.java154
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java188
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java53
7 files changed, 272 insertions, 288 deletions
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/bindings/ComboBoxModelBindingUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/bindings/ComboBoxModelBindingUITest.java
index fb1990bd2d..ca11d5a0fa 100644
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/bindings/ComboBoxModelBindingUITest.java
+++ b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/bindings/ComboBoxModelBindingUITest.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.
@@ -19,10 +19,9 @@ import org.eclipse.jpt.common.utility.internal.ArrayTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
@@ -71,13 +70,13 @@ public class ComboBoxModelBindingUITest
super(null);
this.nameListModel = this.buildNameListModel();
this.testModel = new TestModel(DEFAULT_NAME);
- this.testModelModel = new SimplePropertyValueModel<TestModel>(this.testModel);
+ this.testModelModel = new SimplePropertyValueModel<>(this.testModel);
this.nameModel = new NameModel(this.testModelModel);
this.allCapsNameModel = this.buildAllCapsNameModel(this.testModelModel);
- this.nameListSelectionModel = new SimplePropertyValueModel<String>();
- this.nameListIndexTextModel = new SimplePropertyValueModel<String>();
- this.nameListNameModel = new SimplePropertyValueModel<String>();
+ this.nameListSelectionModel = new SimplePropertyValueModel<>();
+ this.nameListIndexTextModel = new SimplePropertyValueModel<>();
+ this.nameListNameModel = new SimplePropertyValueModel<>();
}
private static final Transformer<String, Integer> STRING_INTEGER_TRANSFORMER = new StringIntegerTransformer();
static class StringIntegerTransformer
@@ -94,7 +93,7 @@ public class ComboBoxModelBindingUITest
}
private SimpleListValueModel<String> buildNameListModel() {
- SimpleListValueModel<String> x = new SimpleListValueModel<String>();
+ SimpleListValueModel<String> x = new SimpleListValueModel<>();
x.add("Daphne");
x.add("Fred");
x.add("Scooby-Doo");
@@ -120,16 +119,16 @@ public class ComboBoxModelBindingUITest
}
private PropertyValueModel<String> buildAllCapsNameModel(PropertyValueModel<TestModel> vm) {
- return new TransformationPropertyValueModel<String, String>(new NameModel(vm), UPPER_CASE_TRANSFORMER);
+ return PropertyValueModelTools.transform(new NameModel(vm), UPPER_CASE_TRANSFORMER);
}
public static final Transformer<String, String> UPPER_CASE_TRANSFORMER = new UpperCaseTransformer();
/* CU private */ static class UpperCaseTransformer
- extends AbstractTransformer<String, String>
+ extends TransformerAdapter<String, String>
{
@Override
- protected String transform_(String string) {
+ public String transform(String string) {
return string.toUpperCase();
}
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java
index e87cc82924..18860d8783 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 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.
@@ -9,11 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal.model.value;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
@@ -22,13 +21,16 @@ import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
-public class CachingTransformationPropertyValueModelTests extends TestCase {
- private ModifiablePropertyValueModel<Person> objectHolder;
+public class CachingTransformationPropertyValueModelTests
+ extends TestCase
+{
+ private ModifiablePropertyValueModel<Person> personModel;
PropertyChangeEvent event;
- private PropertyValueModel<Person> transformationObjectHolder;
+ private PropertyValueModel<Person> testModel;
PropertyChangeEvent transformationEvent;
public CachingTransformationPropertyValueModelTests(String name) {
@@ -38,8 +40,8 @@ public class CachingTransformationPropertyValueModelTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.objectHolder = new SimplePropertyValueModel<Person>(new Person("Karen", "Peggy", null));
- this.transformationObjectHolder = new TransformationPropertyValueModel<Person, Person>(this.objectHolder, PARENT_TRANSFORMER);
+ this.personModel = new SimplePropertyValueModel<>(new Person("Karen", "Peggy", null));
+ this.testModel = PropertyValueModelTools.transform(this.personModel, PARENT_TRANSFORMER);
}
@Override
@@ -50,93 +52,93 @@ public class CachingTransformationPropertyValueModelTests extends TestCase {
public void testValue() {
ChangeListener listener = this.buildTransformationChangeListener();
- this.transformationObjectHolder.addChangeListener(listener);
+ this.testModel.addChangeListener(listener);
- Person person = this.objectHolder.getValue();
+ Person person = this.personModel.getValue();
assertEquals("Karen", person.getName());
- Person parent = this.transformationObjectHolder.getValue();
+ Person parent = this.testModel.getValue();
assertEquals(person.getParent().getName(), parent.getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent, this.transformationObjectHolder.getValue());
+ assertNotSame(person.getParent(), this.testModel.getValue());
+ assertEquals(parent, this.testModel.getValue());
Person person1 = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(person1);
- Person parent2 = this.transformationObjectHolder.getValue();
+ this.personModel.setValue(person1);
+ Person parent2 = this.testModel.getValue();
assertEquals(person1.getParent().getName(), parent2.getName());
- assertNotSame(person1.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent2, this.transformationObjectHolder.getValue());
+ assertNotSame(person1.getParent(), this.testModel.getValue());
+ assertEquals(parent2, this.testModel.getValue());
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
+ this.personModel.setValue(null);
+ assertNull(this.personModel.getValue());
+ assertNull(this.testModel.getValue());
Person person3 = new Person("Karen", "Peggy", null);
- this.objectHolder.setValue(person3);
+ this.personModel.setValue(person3);
assertEquals("Karen", person3.getName());
- Person parent3 = this.transformationObjectHolder.getValue();
+ Person parent3 = this.testModel.getValue();
assertEquals(person3.getParent().getName(), parent3.getName());
- assertNotSame(person3.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent3, this.transformationObjectHolder.getValue());
+ assertNotSame(person3.getParent(), this.testModel.getValue());
+ assertEquals(parent3, this.testModel.getValue());
}
public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
ChangeListener listener = this.buildTransformationChangeListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.addChangeListener(listener);
+ assertTrue(((AbstractModel) this.personModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removeChangeListener(listener);
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.personModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
}
public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildChangeListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationChangeListener());
+ this.personModel.addChangeListener(this.buildChangeListener());
+ this.testModel.addChangeListener(this.buildTransformationChangeListener());
this.verifyPropertyChanges();
}
public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
+ this.personModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
this.verifyPropertyChanges();
}
private void verifyPropertyChanges() {
this.event = null;
this.transformationEvent = null;
- Person karen = this.objectHolder.getValue();
- Person peggyParent = this.transformationObjectHolder.getValue();
+ Person karen = this.personModel.getValue();
+ Person peggyParent = this.testModel.getValue();
Person peggy = new Person("Peggy", "Marian", null);
- this.objectHolder.setValue(peggy);
- Person marianParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, karen, peggy);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, peggyParent, marianParent);
+ this.personModel.setValue(peggy);
+ Person marianParent = this.testModel.getValue();
+ this.verifyEvent(this.event, this.personModel, karen, peggy);
+ this.verifyEvent(this.transformationEvent, this.testModel, peggyParent, marianParent);
this.event = null;
this.transformationEvent = null;
Person matt = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(matt);
- Person mitchParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, peggy, matt);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, marianParent, mitchParent);
+ this.personModel.setValue(matt);
+ Person mitchParent = this.testModel.getValue();
+ this.verifyEvent(this.event, this.personModel, peggy, matt);
+ this.verifyEvent(this.transformationEvent, this.testModel, marianParent, mitchParent);
this.event = null;
this.transformationEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, matt, null);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, mitchParent, null);
+ this.personModel.setValue(null);
+ this.verifyEvent(this.event, this.personModel, matt, null);
+ this.verifyEvent(this.transformationEvent, this.testModel, mitchParent, null);
this.event = null;
this.transformationEvent = null;
- this.objectHolder.setValue(matt);
- mitchParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, null, matt);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, mitchParent);
+ this.personModel.setValue(matt);
+ mitchParent = this.testModel.getValue();
+ this.verifyEvent(this.event, this.personModel, null, matt);
+ this.verifyEvent(this.transformationEvent, this.testModel, null, mitchParent);
}
private PropertyChangeListener buildListener() {
@@ -183,10 +185,10 @@ public class CachingTransformationPropertyValueModelTests extends TestCase {
private static final Transformer<Person, Person> PARENT_TRANSFORMER = new ParentTransformer();
static class ParentTransformer
- extends AbstractTransformer<Person, Person>
+ extends TransformerAdapter<Person, Person>
{
@Override
- public Person transform_(Person person) {
+ public Person transform(Person person) {
return person.getParent();
}
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java
index 535a700f52..1390771067 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -9,15 +9,17 @@
******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal.model.value;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
-public class StaticValueModelTests extends TestCase {
- private PropertyValueModel<String> objectHolder;
- private static final PropertyValueModel<String> OBJECT_HOLDER = new StaticPropertyValueModel<String>("foo");
+public class StaticValueModelTests
+ extends TestCase
+{
+ private PropertyValueModel<String> testModel;
+ private static final PropertyValueModel<String> OBJECT_HOLDER = PropertyValueModelTools.staticPropertyValueModel("foo");
public StaticValueModelTests(String name) {
@@ -27,7 +29,7 @@ public class StaticValueModelTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.objectHolder = OBJECT_HOLDER;
+ this.testModel = OBJECT_HOLDER;
}
@Override
@@ -37,11 +39,11 @@ public class StaticValueModelTests extends TestCase {
}
public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
+ assertEquals("foo", this.testModel.getValue());
}
public void testToString() {
- assertTrue(this.objectHolder.toString().indexOf("foo") >= 0);
+ assertTrue(this.testModel.toString().indexOf("foo") >= 0);
}
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationModifiablePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationModifiablePropertyValueModelTests.java
index de112694d2..c23cf44a2d 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationModifiablePropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationModifiablePropertyValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 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.
@@ -9,10 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal.model.value;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
@@ -21,15 +20,16 @@ import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationModifiablePropertyValueModelTests
extends TestCase
{
- private ModifiablePropertyValueModel<Person> objectHolder;
- PropertyChangeEvent event;
+ private ModifiablePropertyValueModel<Person> personModel;
+ PropertyChangeEvent personEvent;
- private ModifiablePropertyValueModel<Person> transformationObjectHolder;
+ private ModifiablePropertyValueModel<Person> testModel;
PropertyChangeEvent transformationEvent;
public TransformationModifiablePropertyValueModelTests(String name) {
@@ -39,8 +39,8 @@ public class TransformationModifiablePropertyValueModelTests
@Override
protected void setUp() throws Exception {
super.setUp();
- this.objectHolder = new SimplePropertyValueModel<Person>(new Person("Karen", "Peggy", null));
- this.transformationObjectHolder = new TransformationModifiablePropertyValueModel<Person, Person>(this.objectHolder, PARENT_TRANSFORMER, CHILD_TRANSFORMER);
+ this.personModel = new SimplePropertyValueModel<>(new Person("Karen", "Peggy", null));
+ this.testModel = PropertyValueModelTools.transform_(this.personModel, PARENT_TRANSFORMER, CHILD_TRANSFORMER);
}
@Override
@@ -51,131 +51,106 @@ public class TransformationModifiablePropertyValueModelTests
public void testValue() {
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
+ this.testModel.addChangeListener(listener);
- Person person = this.objectHolder.getValue();
+ Person person = this.personModel.getValue();
assertEquals("Karen", person.getName());
- Person parent = this.transformationObjectHolder.getValue();
+ Person parent = this.testModel.getValue();
assertEquals(person.getParent().getName(), parent.getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent, this.transformationObjectHolder.getValue());
+ assertNotSame(person.getParent(), this.testModel.getValue());
+ assertEquals(parent, this.testModel.getValue());
Person person1 = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(person1);
- Person parent2 = this.transformationObjectHolder.getValue();
+ this.personModel.setValue(person1);
+ Person parent2 = this.testModel.getValue();
assertEquals(person1.getParent().getName(), parent2.getName());
- assertNotSame(person1.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent2, this.transformationObjectHolder.getValue());
+ assertNotSame(person1.getParent(), this.testModel.getValue());
+ assertEquals(parent2, this.testModel.getValue());
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
+ this.personModel.setValue(null);
+ assertNull(this.personModel.getValue());
+ assertNull(this.testModel.getValue());
Person person3 = new Person("Karen", "Peggy", null);
- this.objectHolder.setValue(person3);
+ this.personModel.setValue(person3);
assertEquals("Karen", person3.getName());
- Person parent3 = this.transformationObjectHolder.getValue();
+ Person parent3 = this.testModel.getValue();
assertEquals(person3.getParent().getName(), parent3.getName());
- assertNotSame(person3.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent3, this.transformationObjectHolder.getValue());
+ assertNotSame(person3.getParent(), this.testModel.getValue());
+ assertEquals(parent3, this.testModel.getValue());
}
public void testSetValue() {
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
+ this.testModel.addChangeListener(listener);
Person person = new Person("Chris", "Noel", null);
- this.transformationObjectHolder.setValue(person.getParent());
- assertEquals(person, this.objectHolder.getValue());
- assertEquals(person.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
+ this.testModel.setValue(person.getParent());
+ assertEquals(person, this.personModel.getValue());
+ assertEquals(person.getParent().getName(), this.testModel.getValue().getName());
+ assertNotSame(person.getParent(), this.testModel.getValue());
Person person2 = new Person("Jon", "Elizabeth", null);
- this.transformationObjectHolder.setValue(person2.getParent());
- assertEquals(person2, this.objectHolder.getValue());
- assertEquals(person2.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person2.getParent(), this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue(person.getParent());
- assertEquals(person, this.objectHolder.getValue());
- assertEquals(person.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
+ this.testModel.setValue(person2.getParent());
+ assertEquals(person2, this.personModel.getValue());
+ assertEquals(person2.getParent().getName(), this.testModel.getValue().getName());
+ assertNotSame(person2.getParent(), this.testModel.getValue());
+
+ this.testModel.setValue(null);
+ assertNull(this.personModel.getValue());
+ assertNull(this.testModel.getValue());
+
+ this.testModel.setValue(person.getParent());
+ assertEquals(person, this.personModel.getValue());
+ assertEquals(person.getParent().getName(), this.testModel.getValue().getName());
+ assertNotSame(person.getParent(), this.testModel.getValue());
}
public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.addChangeListener(listener);
+ assertTrue(((AbstractModel) this.personModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removeChangeListener(listener);
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.personModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.personModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
}
public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationListener());
+ this.personModel.addChangeListener(this.buildListener());
+ this.testModel.addChangeListener(this.buildTransformationListener());
this.verifyPropertyChanges();
}
public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
+ this.personModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
this.verifyPropertyChanges();
}
private void verifyPropertyChanges() {
- this.event = null;
+ this.personEvent = null;
this.transformationEvent = null;
- Person oldPerson = this.objectHolder.getValue();
- Person oldParent = this.transformationObjectHolder.getValue();
+ Person oldPerson = this.personModel.getValue();
+ Person oldParent = this.testModel.getValue();
Person newPerson = new Person("Karen" , "Peggy", null);
- this.objectHolder.setValue(newPerson);
- Person newParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, oldPerson, newPerson);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, oldParent, newParent);
-
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("Foo");
-// this.verifyEvent(this.event, this.objectHolder, "baz", "Foo");
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAZ", "FOO");
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("FOO");
-// this.verifyEvent(this.event, this.objectHolder, "Foo", "FOO");
-// assertNull(this.transformationEvent);
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue(null);
-// this.verifyEvent(this.event, this.objectHolder, "FOO", null);
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", null);
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("bar");
-// this.verifyEvent(this.event, this.objectHolder, null, "bar");
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, "BAR");
+ this.personModel.setValue(newPerson);
+ Person newParent = this.testModel.getValue();
+ this.verifyEvent(this.personEvent, this.personModel, oldPerson, newPerson);
+ this.verifyEvent(this.transformationEvent, this.testModel, oldParent, newParent);
}
private ChangeListener buildListener() {
return new ChangeAdapter() {
@Override
public void propertyChanged(PropertyChangeEvent e) {
- TransformationModifiablePropertyValueModelTests.this.event = e;
+ TransformationModifiablePropertyValueModelTests.this.personEvent = e;
}
};
}
@@ -190,6 +165,7 @@ public class TransformationModifiablePropertyValueModelTests
}
private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
+ assertNotNull(e);
assertEquals(source, e.getSource());
assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
assertEquals(oldValue, e.getOldValue());
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
index f7a837d0a3..4d7248c792 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -9,10 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal.model.value;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
@@ -21,16 +20,17 @@ import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationPropertyValueModelTests
extends TestCase
{
- private ModifiablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
+ private ModifiablePropertyValueModel<String> stringModel;
+ PropertyChangeEvent stringEvent;
- private ModifiablePropertyValueModel<String> transformationObjectHolder;
- PropertyChangeEvent transformationEvent;
+ private ModifiablePropertyValueModel<String> testModel;
+ PropertyChangeEvent testEvent;
public TransformationPropertyValueModelTests(String name) {
super(name);
@@ -39,8 +39,8 @@ public class TransformationPropertyValueModelTests
@Override
protected void setUp() throws Exception {
super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.transformationObjectHolder = new TransformationModifiablePropertyValueModel<String, String>(this.objectHolder, UPPER_CASE_TRANSFORMER, LOWER_CASE_TRANSFORMER);
+ this.stringModel = new SimplePropertyValueModel<>("foo");
+ this.testModel = PropertyValueModelTools.transform_(this.stringModel, UPPER_CASE_TRANSFORMER, LOWER_CASE_TRANSFORMER);
}
private static final Transformer<String, String> UPPER_CASE_TRANSFORMER = new UpperCaseTransformer();
@@ -70,125 +70,125 @@ public class TransformationPropertyValueModelTests
}
public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
+ assertEquals("foo", this.stringModel.getValue());
+ assertNull(this.testModel.getValue());
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("FOO", this.transformationObjectHolder.getValue());
+ this.testModel.addChangeListener(listener);
+ assertEquals("FOO", this.testModel.getValue());
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
+ this.stringModel.setValue("bar");
+ assertEquals("bar", this.stringModel.getValue());
+ assertEquals("BAR", this.testModel.getValue());
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
+ this.stringModel.setValue("baz");
+ assertEquals("baz", this.stringModel.getValue());
+ assertEquals("BAZ", this.testModel.getValue());
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
+ this.stringModel.setValue(null);
+ assertNull(this.stringModel.getValue());
+ assertNull(this.testModel.getValue());
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("FOO", this.transformationObjectHolder.getValue());
+ this.stringModel.setValue("foo");
+ assertEquals("foo", this.stringModel.getValue());
+ assertEquals("FOO", this.testModel.getValue());
}
public void testSetValue() {
- this.transformationObjectHolder.setValue("BAR");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
+ this.testModel.setValue("BAR");
+ assertEquals("bar", this.stringModel.getValue());
+ assertNull(this.testModel.getValue()); // no listeners
// NB: odd behavior(!)
- this.transformationObjectHolder.setValue("Foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("Foo", this.transformationObjectHolder.getValue());
+ this.testModel.setValue("Foo");
+ assertEquals("foo", this.stringModel.getValue());
+ assertNull(this.testModel.getValue()); // still no listeners
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("FOO", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.removeChangeListener(listener);
+ this.testModel.addChangeListener(listener);
+ assertEquals("FOO", this.testModel.getValue());
+ this.testModel.removeChangeListener(listener);
- this.transformationObjectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
+ this.testModel.setValue(null);
+ assertNull(this.stringModel.getValue());
+ assertNull(this.testModel.getValue());
// NB: odd behavior(!)
- this.transformationObjectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("baz", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.removeChangeListener(listener);
+ this.testModel.setValue("baz");
+ assertEquals("baz", this.stringModel.getValue());
+ assertNull(this.testModel.getValue()); // no listeners
+ this.testModel.addChangeListener(listener);
+ assertEquals("BAZ", this.testModel.getValue());
+ this.testModel.removeChangeListener(listener);
}
public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.addChangeListener(listener);
+ assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removeChangeListener(listener);
+ assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
+
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
+ this.testModel.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
+ assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
}
public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationListener());
+ this.stringModel.addChangeListener(this.buildListener());
+ this.testModel.addChangeListener(this.buildTransformationListener());
this.verifyPropertyChanges();
}
public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
+ this.stringModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
+ this.testModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
this.verifyPropertyChanges();
}
private void verifyPropertyChanges() {
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, "foo", "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", "BAR");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(this.event, this.objectHolder, "bar", "baz");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAR", "BAZ");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("Foo");
- this.verifyEvent(this.event, this.objectHolder, "baz", "Foo");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAZ", "FOO");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("FOO");
- this.verifyEvent(this.event, this.objectHolder, "Foo", "FOO");
- assertNull(this.transformationEvent);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, "FOO", null);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", null);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, null, "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, "BAR");
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue("bar");
+ this.verifyEvent(this.stringEvent, this.stringModel, "foo", "bar");
+ this.verifyEvent(this.testEvent, this.testModel, "FOO", "BAR");
+
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue("baz");
+ this.verifyEvent(this.stringEvent, this.stringModel, "bar", "baz");
+ this.verifyEvent(this.testEvent, this.testModel, "BAR", "BAZ");
+
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue("Foo");
+ this.verifyEvent(this.stringEvent, this.stringModel, "baz", "Foo");
+ this.verifyEvent(this.testEvent, this.testModel, "BAZ", "FOO");
+
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue("FOO");
+ this.verifyEvent(this.stringEvent, this.stringModel, "Foo", "FOO");
+ assertNull(this.testEvent);
+
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue(null);
+ this.verifyEvent(this.stringEvent, this.stringModel, "FOO", null);
+ this.verifyEvent(this.testEvent, this.testModel, "FOO", null);
+
+ this.stringEvent = null;
+ this.testEvent = null;
+ this.stringModel.setValue("bar");
+ this.verifyEvent(this.stringEvent, this.stringModel, null, "bar");
+ this.verifyEvent(this.testEvent, this.testModel, null, "BAR");
}
private ChangeListener buildListener() {
return new ChangeAdapter() {
@Override
public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.event = e;
+ TransformationPropertyValueModelTests.this.stringEvent = e;
}
};
}
@@ -197,7 +197,7 @@ public class TransformationPropertyValueModelTests
return new ChangeAdapter() {
@Override
public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.transformationEvent = e;
+ TransformationPropertyValueModelTests.this.testEvent = e;
}
};
}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
index b527dabc90..0aef2cbd3a 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -47,7 +47,7 @@ public class PreferencePropertyValueModelTests extends PreferencesTestCase {
super.setUp();
this.testNode.put(KEY_NAME, STRING_VALUE);
- this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
+ this.nodeHolder = new SimplePropertyValueModel<>(this.testNode);
this.preferenceAdapter = PreferencePropertyValueModel.forString(this.nodeHolder, KEY_NAME, null);
this.listener = this.buildValueChangeListener();
this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
@@ -387,7 +387,7 @@ public class PreferencePropertyValueModelTests extends PreferencesTestCase {
extends PreferencePropertyValueModel<P>
{
public static PreferencePropertyValueModel<String> forString(PropertyValueModel<? extends Preferences> preferencesModel, String key, String defaultValue) {
- return new AlwaysUpdatePreferencePropertyValueModel<String>(
+ return new AlwaysUpdatePreferencePropertyValueModel<>(
preferencesModel,
key,
defaultValue,
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
index 97d635aef9..2724f9c2e3 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -20,7 +20,6 @@ import javax.swing.JTree;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.collection.HashBag;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
@@ -30,10 +29,10 @@ import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapt
import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.NullListValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools;
import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.TransformationListValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.swing.TreeModelAdapter;
import org.eclipse.jpt.common.utility.io.IndentingPrintWriter;
@@ -47,6 +46,7 @@ import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.TreeNodeValueModel;
import org.eclipse.jpt.common.utility.tests.internal.model.Displayable;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TreeModelAdapterTests extends TestCase {
@@ -189,8 +189,8 @@ public class TreeModelAdapterTests extends TestCase {
}
public void testTreeStructureChanged() {
- ModifiablePropertyValueModel<TreeNodeValueModel<Object>> nodeHolder = new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
- TreeModel treeModel = this.buildTreeModel(nodeHolder);
+ ModifiablePropertyValueModel<TreeNodeValueModel<Object>> nodeModel = new SimplePropertyValueModel<>(this.buildSortedRootNode());
+ TreeModel treeModel = this.buildTreeModel(nodeModel);
this.eventFired = false;
treeModel.addTreeModelListener(new TestTreeModelListener() {
@Override
@@ -206,7 +206,7 @@ public class TreeModelAdapterTests extends TestCase {
TreeModelAdapterTests.this.eventFired = true;
}
});
- nodeHolder.setValue(this.buildUnsortedRootNode());
+ nodeModel.setValue(this.buildUnsortedRootNode());
assertTrue(this.eventFired);
}
@@ -303,7 +303,7 @@ public class TreeModelAdapterTests extends TestCase {
super();
this.parent = parent;
this.name = name;
- this.children = new HashBag<TestModel>();
+ this.children = new HashBag<>();
}
public TestModel getParent() {
@@ -358,8 +358,9 @@ public class TreeModelAdapterTests extends TestCase {
public String dumpString() {
StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
+ try (IndentingPrintWriter ipw = new IndentingPrintWriter(sw)) {
+ this.dumpOn(ipw);
+ }
return sw.toString();
}
public void dumpOn(IndentingPrintWriter writer) {
@@ -371,9 +372,10 @@ public class TreeModelAdapterTests extends TestCase {
writer.undent();
}
public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
+ try (IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream))) {
+ this.dumpOn(writer);
+ writer.flush();
+ }
}
public void dump() {
this.dumpOn(System.out);
@@ -516,8 +518,9 @@ public class TreeModelAdapterTests extends TestCase {
public String dumpString() {
StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
+ try (IndentingPrintWriter ipw = new IndentingPrintWriter(sw)) {
+ this.dumpOn(ipw);
+ }
return sw.toString();
}
@@ -532,9 +535,10 @@ public class TreeModelAdapterTests extends TestCase {
}
public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
+ try (IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream))) {
+ this.dumpOn(writer);
+ writer.flush();
+ }
}
public void dump() {
@@ -607,11 +611,11 @@ public class TreeModelAdapterTests extends TestCase {
/** the list should be sorted */
@Override
protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- return new SortedListValueModelWrapper<TreeNodeValueModel<Object>>(this.buildDisplayStringAdapter(testModel));
+ return new SortedListValueModelWrapper<>(this.buildDisplayStringAdapter(testModel));
}
/** the display string (name) of each node can change */
protected ListValueModel<TreeNodeValueModel<Object>> buildDisplayStringAdapter(TestModel testModel) {
- return new ItemPropertyListValueModelAdapter<TreeNodeValueModel<Object>>(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
+ return new ItemPropertyListValueModelAdapter<>(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
}
/** children are also sorted nodes */
@Override
@@ -676,7 +680,7 @@ public class TreeModelAdapterTests extends TestCase {
protected ListValueModel<TreeNodeValueModel<Object>> buildSpecialChildrenModel() {
TreeNodeValueModel<Object>[] children = new NameTestNode[1];
children[0] = new NameTestNode(this);
- return new SimpleListValueModel<TreeNodeValueModel<Object>>(Arrays.asList(children));
+ return new SimpleListValueModel<>(Arrays.asList(children));
}
/** children are also special nodes */
@Override
@@ -700,7 +704,7 @@ public class TreeModelAdapterTests extends TestCase {
this.nameListener = this.buildNameListener();
this.specialNode = specialNode;
this.nameAdapter = this.buildNameAdapter();
- this.childrenModel = new NullListValueModel<TreeNodeValueModel<Object>>();
+ this.childrenModel = new NullListValueModel<>();
}
protected PropertyChangeListener buildNameListener() {
return new PropertyChangeListener() {
@@ -762,11 +766,12 @@ public class TreeModelAdapterTests extends TestCase {
}
private TreeModel buildTreeModel(TestNode root) {
- return this.buildTreeModel(new StaticPropertyValueModel<TreeNodeValueModel<Object>>(root));
+ return this.buildTreeModel(PropertyValueModelTools.staticPropertyValueModel(root));
}
- private TreeModel buildTreeModel(PropertyValueModel<TreeNodeValueModel<Object>> rootHolder) {
- return new TreeModelAdapter<Object>(rootHolder) {
+ private TreeModel buildTreeModel(PropertyValueModel<TreeNodeValueModel<Object>> rootModel) {
+ return new TreeModelAdapter<Object>(rootModel) {
+ private static final long serialVersionUID = 1L;
@Override
protected ListChangeListener buildChildrenListener() {
return this.buildChildrenListener_();

Back to the top