Search in sources :

Example 1 with FieldOffice

use of org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice in project eclipselink by eclipse-ee4j.

the class SetUnReferencedObjectTest method setup.

@Override
public void setup() {
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    beginTransaction();
    UnitOfWork uow = getSession().acquireUnitOfWork();
    this.fieldOfficeClone = new FieldOffice();
    this.fieldOfficeClone.setLocation(FieldLocation.example2());
    uow.registerObject(this.fieldOfficeClone);
    uow.commit();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) FieldOffice(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice)

Example 2 with FieldOffice

use of org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice in project eclipselink by eclipse-ee4j.

the class TransparentIndirectionAddOverflowBehaviourTest method verify.

/*
     * Checks to see that the names of the updated version and the origional are the same
     */
@Override
public void verify() {
    FieldOffice cachedOffice2 = (FieldOffice) getSession().readObject(this.clone2);
    SalesPerson cachedTransfer = (SalesPerson) getSession().readObject(this.transfer);
    Resource cachedResource = (Resource) getSession().readObject(this.resource);
    if (cachedOffice2.getSalespeople().contains(cachedTransfer)) {
        throw new TestErrorException("Failed to replicate Set behavior for double add when tracking changes");
    }
    if (!cachedOffice2.getResources().contains(cachedResource)) {
        throw new TestErrorException("Failed to replicate List behavior for double add when tracking changes");
    }
}
Also used : FieldOffice(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice) SalesPerson(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson) Resource(org.eclipse.persistence.testing.models.relationshipmaintenance.Resource) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException)

Example 3 with FieldOffice

use of org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice in project eclipselink by eclipse-ee4j.

the class TransparentIndirectionAddRemoveTest method testAddRemove.

public void testAddRemove() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    FieldOffice office = (FieldOffice) uow.readObject(FieldOffice.class, new ExpressionBuilder().get("location").get("city").equal("Toronto"));
    SalesPerson person = new SalesPerson();
    person.setName("Bob");
    person.setFieldOffice(office);
    office.getSalespeople().add(person);
    uow.commit();
    if (((IndirectContainer) office.getSalespeople()).isInstantiated()) {
        throwError("Sales people indirect collection should not be instantiated on add.");
    }
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in clone.");
    }
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in cache.");
    }
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    uow = getSession().acquireUnitOfWork();
    office = (FieldOffice) uow.readObject(office);
    person = (SalesPerson) uow.readObject(person);
    office.getSalespeople().remove(person);
    uow.commit();
    if (((IndirectContainer) office.getSalespeople()).isInstantiated()) {
        throwError("Sales people indirect collection should not be instantiated on remove.");
    }
    if (office.getSalespeople().contains(person)) {
        throwError("Person not removed in clone.");
    }
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (office.getSalespeople().contains(person)) {
        throwError("Person not removed in cache.");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) FieldOffice(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice) SalesPerson(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 4 with FieldOffice

use of org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice in project eclipselink by eclipse-ee4j.

the class TransparentIndirectionAddRemoveTest method testSetUnset.

public void testSetUnset() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    FieldOffice office = (FieldOffice) uow.readObject(FieldOffice.class, new ExpressionBuilder().get("location").get("city").equal("Toronto"));
    SalesPerson person = new SalesPerson();
    person.setName("Bob");
    person = (SalesPerson) uow.registerObject(person);
    person.setFieldOffice(office);
    uow.commit();
    if (((IndirectContainer) office.getSalespeople()).isInstantiated()) {
        throwError("Sales people indirect collection should not be instantiated on add.");
    }
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in clone.");
    }
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in cache.");
    }
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    uow = getSession().acquireUnitOfWork();
    office = (FieldOffice) uow.readObject(office);
    person = (SalesPerson) uow.readObject(person);
    person.setFieldOffice(null);
    uow.commit();
    if (((IndirectContainer) office.getSalespeople()).isInstantiated()) {
        throwError("Sales people indirect collection should not be instantiated on remove.");
    }
    if (office.getSalespeople().contains(person)) {
        throwError("Person not removed in clone.");
    }
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (office.getSalespeople().contains(person)) {
        throwError("Person not removed in cache.");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) FieldOffice(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice) SalesPerson(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson) IndirectContainer(org.eclipse.persistence.indirection.IndirectContainer) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 5 with FieldOffice

use of org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice in project eclipselink by eclipse-ee4j.

the class TransparentIndirectionResumeAddTest method test.

@Override
public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    FieldOffice office = new FieldOffice();
    SalesPerson person = new SalesPerson();
    person.setName("Bob");
    person.setFieldOffice(office);
    office.getSalespeople().add(person);
    uow.registerNewObject(office);
    uow.commitAndResume();
    person = new SalesPerson();
    person.setName("Joe");
    person.setFieldOffice(office);
    office.getSalespeople().add(person);
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in clone.");
    }
    uow.commit();
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in cache.");
    }
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    office = (FieldOffice) getSession().readObject(office);
    person = (SalesPerson) getSession().readObject(person);
    if (!office.getSalespeople().contains(person)) {
        throwError("Person not added in cache.");
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) FieldOffice(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice) SalesPerson(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson)

Aggregations

FieldOffice (org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice)7 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)5 SalesPerson (org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson)5 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)2 IndirectContainer (org.eclipse.persistence.indirection.IndirectContainer)2 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)2 Resource (org.eclipse.persistence.testing.models.relationshipmaintenance.Resource)2