blob: b5c1e22e89772ba7d27b10ca2e7ff388bb4eb64f [file] [log] [blame]
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.testing.tests.unitofwork.changeflag;
import org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy;
import org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy;
import org.eclipse.persistence.testing.framework.TestModel;
import org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice;
import org.eclipse.persistence.testing.models.relationshipmaintenance.RelationshipsSystem;
/**
* This model tests reading/writing/deleting through using the employee demo.
* This model is set up to test the use of change tracking policy. It uses
* the employee demo test framework to ensure everything works as it did before when
* the new change policy is used. It also makes use of several of the tests from the UnitOfWork
* model to ensure that the actual updates function correctly.
* @author Tom Ware
*/
public class TransparentIndirectionChangeFlagBasicTestModel extends TestModel {
protected ObjectChangePolicy fieldOfficeChangePolicy;
public TransparentIndirectionChangeFlagBasicTestModel() {
setDescription("This model tests reading/writing/deleting using the IndirectList with change tracking.");
}
@Override
public void addRequiredSystems() {
addRequiredSystem(new RelationshipsSystem());
}
@Override
public void addTests() {
addTest(new TransparentIndirectionTest());
addTest(new TransparentIndirectionAddOverflowBehaviourTest());
addTest(new TransparentIndirectionAddRemoveTest());
addTest(new TransparentIndirectionResumeAddTest());
}
@Override
public void setup() {
// Save change policies for the all employee demo class in order to restore them at reset time.
fieldOfficeChangePolicy = getSession().getDescriptor(FieldOffice.class).getObjectChangePolicy();
getSession().getDescriptor(FieldOffice.class).setObjectChangePolicy(new AttributeChangeTrackingPolicy());
}
@Override
public void reset() {
// restore old change policies.
getSession().getDescriptor(FieldOffice.class).setObjectChangePolicy(fieldOfficeChangePolicy);
}
}