@@ -129,6 +129,42 @@ public void testChangingObservableToNull() {
129
129
assertFalse (property .isInnerObservablePresent ());
130
130
}
131
131
132
+ /**
133
+ * Tests whether changing the nested property's value while the nesting's observable is missing works.
134
+ */
135
+ @ Test
136
+ public void testChangingValueWhileObservableIsMissing () {
137
+ // set the nesting observable to null
138
+ setNestingObservable (nesting , null );
139
+
140
+ // set a new value (which can not be written to the nesting's observable as none is present)
141
+ T newValue = createNewValue ();
142
+ property .setValue (newValue );
143
+
144
+ // assert that the property indeed holds the new value
145
+ assertEquals (newValue , property .getValue ());
146
+ }
147
+
148
+ /**
149
+ * Tests whether the nested property's value, which was changed while the nesting's observable was missing, will not
150
+ * propagate to an observable which will be set thereafter.
151
+ */
152
+ @ Test
153
+ public void testChangedValueNotPropagationAfterObservableWasMissing () {
154
+ // set the nesting observable to null and create the new observable
155
+ setNestingObservable (nesting , null );
156
+ P newObservable = createNewObservableWithValue (createNewValue ());
157
+
158
+ // change the nested property's value (which can not be written to the nesting's observable as none is present);
159
+ // due to the contract of 'createNewValue' the nested property has currently another value than the new observable
160
+ property .setValue (createNewValue ());
161
+ assertNotEquals (newObservable .getValue (), property .getValue ());
162
+
163
+ // set the new observable and assert that the property reflects its value
164
+ setNestingObservable (nesting , newObservable );
165
+ assertEquals (newObservable .getValue (), property .getValue ());
166
+ }
167
+
132
168
/**
133
169
* Tests whether the property's value is correctly updated when the nesting's new observable gets a new value.
134
170
*/
@@ -196,7 +232,8 @@ public void testChangingOldObservablesValue() {
196
232
protected abstract NestedProperty <T > createNestedPropertyFromNesting (Nesting <P > nesting );
197
233
198
234
/**
199
- * Creates a new value. Each call must return a new instance.
235
+ * Creates a new value. Each call must return an instance which is not equal to any of those returned before and to
236
+ * that contained in the observable returned by {@link #createNewObservableWithSomeValue()}.
200
237
*
201
238
* @return a new instance of type {@code T}
202
239
*/
0 commit comments