Skip to main content
summaryrefslogtreecommitdiffstats
blob: f1e676a7b8a2be7363dd7dec1972f5db60505473 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
/*******************************************************************************
* Copyright (c) 2009, 2010 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.
* 
* Contributors:
*     Oracle - initial API and implementation
*******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.persistence;

import java.util.ListIterator;
import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.persistence.options.Options2_0;

/**
 *  EclipseLinkOptions2_0Tests
 */
@SuppressWarnings("nls")
public class EclipseLink2_0OptionsTests extends EclipseLink2_0PersistenceUnitTestCase
{
	private Options2_0 options;
	private ListChangeEvent prePersistEvent;
	private ListChangeEvent preUpdateEvent;
	private ListChangeEvent preRemoveEvent;

	public static final String LOCK_TIMEOUT_KEY = Options2_0.PERSISTENCE_LOCK_TIMEOUT;
	public static final Integer LOCK_TIMEOUT_TEST_VALUE = 100;
	public static final Integer LOCK_TIMEOUT_TEST_VALUE_2 = 200;

	public static final String QUERY_TIMEOUT_KEY = Options2_0.PERSISTENCE_QUERY_TIMEOUT;
	public static final Integer QUERY_TIMEOUT_TEST_VALUE = 100;
	public static final Integer QUERY_TIMEOUT_TEST_VALUE_2 = 200;
	
	public static final String VALIDATION_GROUP_PRE_PERSIST_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST;
	public static final String VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE = "test_pre-persist_group";
	public static final String VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2 = "test_2_pre-persist_group";
	
	public static final String VALIDATION_GROUP_PRE_UPDATE_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE;
	public static final String VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE = "test_pre-update_group";
	public static final String VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2 = "test_2_pre-update_group";
	
	public static final String VALIDATION_GROUP_PRE_REMOVE_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE;
	public static final String VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE = "test_pre-remove_group";
	public static final String VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2 = "test_2_pre-remove_group";

	// ********** constructors **********
	public EclipseLink2_0OptionsTests(String name) {
		super(name);
	}

	// ********** behavior **********
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		this.options = (Options2_0) this.subject.getOptions();
		PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();

		this.options.addPropertyChangeListener(Options2_0.LOCK_TIMEOUT_PROPERTY, propertyChangeListener);
		this.options.addPropertyChangeListener(Options2_0.QUERY_TIMEOUT_PROPERTY, propertyChangeListener);
		this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY, propertyChangeListener);
		this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY, propertyChangeListener);
		this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY, propertyChangeListener);

		ListChangeListener validationGroupListChangeListener = this.buildValidationGroupListChangeListener();
		this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST, validationGroupListChangeListener);
		this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST, validationGroupListChangeListener);
		this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST, validationGroupListChangeListener);
		
		this.clearEvent();
	}

	/**
	 * Initializes directly the PersistenceUnit properties before testing.
	 */
	@Override
	protected void populatePu() {
		this.modelPropertiesSizeOriginal = 5; // PersistenceUnit properties
		this.propertiesTotal = this.modelPropertiesSizeOriginal + 1; // 1 misc properties
		this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
		
		// Initializes PersistenceUnit properties
		this.persistenceUnitSetProperty(LOCK_TIMEOUT_KEY, LOCK_TIMEOUT_TEST_VALUE.toString());
		this.persistenceUnitSetProperty(QUERY_TIMEOUT_KEY, QUERY_TIMEOUT_TEST_VALUE.toString());
		this.persistenceUnitSetProperty("misc.property.3", "value.3");

		this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_PERSIST_KEY, VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE);
		this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_UPDATE_KEY, VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE);
		this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_REMOVE_KEY, VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE);
	}

	@Override
	protected PersistenceUnitProperties getModel() {
		return this.options;
	}

	@Override
	protected Object getProperty(String propertyName) throws NoSuchFieldException {
		Object modelValue = null;
		if (propertyName.equals(Options2_0.LOCK_TIMEOUT_PROPERTY))
			modelValue = this.options.getLockTimeout();
		else if (propertyName.equals(Options2_0.QUERY_TIMEOUT_PROPERTY))
			modelValue = this.options.getQueryTimeout();
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY)) {
			ListIterator<String> iterator = this.options.validationGroupPrePersists();
			modelValue = this.getFirstElement(iterator);
		}
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY)) {
			ListIterator<String> iterator = this.options.validationGroupPreUpdates();
			modelValue = this.getFirstElement(iterator);
		}
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY)) {
			ListIterator<String> iterator = this.options.validationGroupPreRemoves();
			modelValue = this.getFirstElement(iterator);
		}
		else
			this.throwMissingDefinition("getProperty", propertyName);
		return modelValue;
	}
	
	@Override
	protected void setProperty(String propertyName, Object newValue) throws Exception {
		if (propertyName.equals(Options2_0.LOCK_TIMEOUT_PROPERTY))
			this.options.setLockTimeout((Integer) newValue);
		else if (propertyName.equals(Options2_0.QUERY_TIMEOUT_PROPERTY))
			this.options.setQueryTimeout((Integer) newValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			this.options.addValidationGroupPrePersist((String) newValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			this.options.addValidationGroupPreUpdate((String) newValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			this.options.addValidationGroupPreRemove((String) newValue);
		else
			this.throwMissingDefinition("setProperty", propertyName);
	}
	
	// ********** LockTimeout tests **********
	public void testSetLockTimeout() throws Exception {
		this.verifyModelInitialized(
			LOCK_TIMEOUT_KEY,
			LOCK_TIMEOUT_TEST_VALUE);
		this.verifySetProperty(
			LOCK_TIMEOUT_KEY,
			LOCK_TIMEOUT_TEST_VALUE,
			LOCK_TIMEOUT_TEST_VALUE_2);
	}

	public void testAddRemoveLockTimeout() throws Exception {
		this.verifyAddRemoveProperty(
			LOCK_TIMEOUT_KEY,
			LOCK_TIMEOUT_TEST_VALUE,
			LOCK_TIMEOUT_TEST_VALUE_2);
	}
	
	// ********** QueryTimeout tests **********
	public void testSetQueryTimeout() throws Exception {
		this.verifyModelInitialized(
			QUERY_TIMEOUT_KEY,
			QUERY_TIMEOUT_TEST_VALUE);
		this.verifySetProperty(
			QUERY_TIMEOUT_KEY,
			QUERY_TIMEOUT_TEST_VALUE,
			QUERY_TIMEOUT_TEST_VALUE_2);
	}

	public void testAddRemoveQueryTimeout() throws Exception {
		this.verifyAddRemoveProperty(
			QUERY_TIMEOUT_KEY,
			QUERY_TIMEOUT_TEST_VALUE,
			QUERY_TIMEOUT_TEST_VALUE_2);
	}

	// ********** ValidationGroupPrePersist tests **********
	public void testSetValidationGroupPrePersist() throws Exception {
		this.verifyModelInitialized(
			VALIDATION_GROUP_PRE_PERSIST_KEY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE);
		this.verifySetValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
			VALIDATION_GROUP_PRE_PERSIST_KEY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
	}

	public void testAddRemoveValidationGroupPrePersist() throws Exception {
		this.verifyAddRemoveValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
			VALIDATION_GROUP_PRE_PERSIST_KEY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
	}

	public void testAddValidationGroupPrePersistCompositeValue() throws Exception {
		this.verifyAddCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
			VALIDATION_GROUP_PRE_PERSIST_KEY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
	}

	public void testRemoveValidationGroupPrePersistCompositeValue() throws Exception {
		this.verifyRemoveCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
			VALIDATION_GROUP_PRE_PERSIST_KEY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
	}

	// ********** ValidationGroupPreUpdate tests **********
	public void testSetValidationGroupPreUpdate() throws Exception {
		this.verifyModelInitialized(
			VALIDATION_GROUP_PRE_UPDATE_KEY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE);
		this.verifySetValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
			VALIDATION_GROUP_PRE_UPDATE_KEY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
	}

	public void testAddRemoveValidationGroupPreUpdate() throws Exception {
		this.verifyAddRemoveValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
			VALIDATION_GROUP_PRE_UPDATE_KEY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
	}

	public void testAddValidationGroupPreUpdateCompositeValue() throws Exception {
		this.verifyAddCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
			VALIDATION_GROUP_PRE_UPDATE_KEY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
	}

	public void testRemoveValidationGroupPreUpdateCompositeValue() throws Exception {
		this.verifyRemoveCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
			VALIDATION_GROUP_PRE_UPDATE_KEY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
	}

	// ********** ValidationGroupPreRemove tests **********
	public void testSetValidationGroupPreRemove() throws Exception {
		this.verifyModelInitialized(
			VALIDATION_GROUP_PRE_REMOVE_KEY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE);
		this.verifySetValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
			VALIDATION_GROUP_PRE_REMOVE_KEY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
	}

	public void testAddRemoveValidationGroupPreRemove() throws Exception {
		this.verifyAddRemoveValidationGroupProperty(
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
			VALIDATION_GROUP_PRE_REMOVE_KEY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
	}

	public void testAddValidationGroupPreRemoveCompositeValue() throws Exception {
		this.verifyAddCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
			VALIDATION_GROUP_PRE_REMOVE_KEY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
	}

	public void testRemoveValidationGroupPreRemoveCompositeValue() throws Exception {
		this.verifyRemoveCompositeValue(
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
			VALIDATION_GROUP_PRE_REMOVE_KEY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
	}

	// ********** ValidationGroups list **********
	public void testValidationGroupsList() throws Exception {
		this.verifyListEvents(
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
			VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2,
			Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST);
		
		this.verifyListEvents(
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
			VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2,
			Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST);
		
		this.verifyListEvents(
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
			VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2,
			Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST);
	}

	// ********** override **********

	@Override
	protected void clearEvent() {
		super.clearEvent();
		this.prePersistEvent = null;
		this.preUpdateEvent = null;
		this.preRemoveEvent = null;
	}

	// ****** convenience methods *******

	// ********** verify ValidationGroup property **********
	protected void verifySetValidationGroupProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
		// Replace
		this.persistenceUnitSetProperty(key, testValue2, true); 
		this.propertiesTotal++;
		this.verifyPutValidationGroupProperty(propertyName, testValue1);
	}

	@SuppressWarnings("unused")
	protected void verifyAddRemoveValidationGroupProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
		assertTrue(this.validationGroupValueExists(propertyName, (String)testValue1));
		// Remove
		this.clearEvent();
		--this.propertiesTotal;
		--this.modelPropertiesSize;
		this.getPersistenceUnit().removeProperty(key, (String)testValue1);
		assertFalse(this.validationGroupValueExists(propertyName, (String)testValue1));
		assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
		
		// Add original Property
		++this.propertiesTotal;
		++this.modelPropertiesSize;
		this.persistenceUnitSetProperty(key, testValue1, true); 
		this.verifyPutValidationGroupProperty(propertyName, testValue1);
	}

	protected void verifyAddCompositeValue(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
		String stringTestValue1 = (String)testValue1;
		String stringTestValue2 = (String)testValue2;
		assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
		assertEquals(this.getValidationGroupSize(propertyName), 1);
		this.addValidationGroupValue(propertyName, stringTestValue2);
		assertEquals(this.getValidationGroupSize(propertyName), 2);

		assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
		assertTrue(this.validationGroupValueExists(propertyName, stringTestValue2));

		String propertyValue = this.getPersistenceUnit().getProperty(key).getValue();
		assertTrue(propertyValue.indexOf(stringTestValue1) != -1);
		assertTrue(propertyValue.indexOf(stringTestValue2) != -1);
	}

	protected void verifyRemoveCompositeValue(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
		String stringTestValue1 = (String)testValue1;
		String stringTestValue2 = (String)testValue2;
		assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
		assertEquals(this.getValidationGroupSize(propertyName), 1);
		this.addValidationGroupValue(propertyName, stringTestValue2);
		assertEquals(this.getValidationGroupSize(propertyName), 2);

		this.removeValidationGroupValue(propertyName, stringTestValue2);
		assertEquals(this.getValidationGroupSize(propertyName), 1);
		assertFalse(this.validationGroupValueExists(propertyName, stringTestValue2));
		String propertyValue = this.getPersistenceUnit().getProperty(key).getValue();
		assertTrue(propertyValue.indexOf(stringTestValue1) != -1);
		assertTrue(propertyValue.indexOf(stringTestValue2) == -1);
		
		this.removeValidationGroupValue(propertyName, stringTestValue2);
		assertEquals(this.getValidationGroupSize(propertyName), 1);
		
		this.removeValidationGroupValue(propertyName, stringTestValue1);
		assertEquals(this.getValidationGroupSize(propertyName), 0);
		assertFalse(this.validationGroupValueExists(propertyName, stringTestValue1));
		
		assertNull(this.getPersistenceUnit().getProperty(key));
	}

	protected void verifyListEvents(String propertyName, String testValue, String listName) throws Exception {
		// add
		this.clearEvent();
		this.addValidationGroupValue(propertyName, testValue);
		
		// verify event received
		assertNotNull("No Event Fired.", this.getEventFor(propertyName));
		// verify event for the expected property
		assertEquals("Wrong Event.", this.getEventFor(propertyName).getListName(), listName);

		// remove
		this.clearEvent();
		
		this.removeValidationGroupValue(propertyName, testValue);
		// verify event received
		assertNotNull("No Event Fired.", this.getEventFor(propertyName));
		// verify event for the expected property
		assertEquals("Wrong Event.", this.getEventFor(propertyName).getListName(), listName);
	}
	
	protected void verifyPutValidationGroupProperty(String propertyName, Object expectedValue) throws Exception {
		// verify event received
		assertNotNull("No Event Fired.", this.getEventFor(propertyName));
		// verify event value
		assertTrue(this.validationGroupValueExists(propertyName, (String) expectedValue));
		 return;
	}
	
	// ********** internal method **********

	private ListChangeListener buildValidationGroupListChangeListener() {
		return new ListChangeListener() {
			public void itemsAdded(ListAddEvent e) {
				EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
			}

			public void itemsRemoved(ListRemoveEvent e) {
				EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
			}

			public void itemsReplaced(ListReplaceEvent e) {
				EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
			}

			public void itemsMoved(ListMoveEvent e) {
				EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
			}

			public void listCleared(ListClearEvent e) {
				EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
			}

			public void listChanged(ListChangeEvent e) {
				
				EclipseLink2_0OptionsTests.this.validationGroupChanged(e);
			}
		};
	}

	private void validationGroupChanged(ListChangeEvent e) {
		String listName = e.getListName();
		
		if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST))
			this.prePersistEvent = e;
		else if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST))
			this.preUpdateEvent = e;
		else if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST))
			this.preRemoveEvent = e;
		else
			this.throwUnsupportedOperationException(e);
	}

	private void addValidationGroupValue(String propertyName, String propertyValue) throws NoSuchFieldException {
		if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			this.options.addValidationGroupPrePersist(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			this.options.addValidationGroupPreUpdate(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			this.options.addValidationGroupPreRemove(propertyValue);
		else
			this.throwMissingDefinition("addValidationGroupValue", propertyName);
	}

	private void removeValidationGroupValue(String propertyName, String propertyValue) throws NoSuchFieldException {
		if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			this.options.removeValidationGroupPrePersist(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			this.options.removeValidationGroupPreUpdate(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			this.options.removeValidationGroupPreRemove(propertyValue);
		else
			this.throwMissingDefinition("removeValidationGroupValue", propertyName);
	}

	private boolean validationGroupValueExists(String propertyName, String propertyValue) throws NoSuchFieldException {
		boolean result = false;
		if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			result = this.options.validationGroupPrePersistExists(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			result = this.options.validationGroupPreUpdateExists(propertyValue);
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			result = this.options.validationGroupPreRemoveExists(propertyValue);
		else
			this.throwMissingDefinition("verifyValidationGroupValueExists", propertyName);
		return result;
	}

	private int getValidationGroupSize(String propertyName) throws NoSuchFieldException {
		int result = 0;
		if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			result =  this.options.validationGroupPrePersistsSize();
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			result =  this.options.validationGroupPreUpdatesSize();
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			result =  this.options.validationGroupPreRemovesSize();
		else
			this.throwMissingDefinition("verifyValidationGroupSize", propertyName);
		return result;
	}
	
	private ListChangeEvent getEventFor(String propertyName) throws NoSuchFieldException {
		ListChangeEvent event = null;
		if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
			event = this.prePersistEvent;
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
			event = this.preUpdateEvent;
		else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
			event = this.preRemoveEvent;
		else
			this.throwMissingDefinition("getEventFor", propertyName);
		return event;
	}

}

Back to the top