use of org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson 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");
}
}
use of org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson 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.");
}
}
use of org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson 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.");
}
}
use of org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson 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.");
}
}
use of org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson in project eclipselink by eclipse-ee4j.
the class SetReferencedObjectTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Iterator iterator = uow.readAllObjects(SalesPerson.class).iterator();
this.sales = (SalesPerson) iterator.next();
this.secondSales = (SalesPerson) iterator.next();
while ((this.secondSales.getFieldOffice() == this.sales.getFieldOffice()) && iterator.hasNext()) {
this.secondSales = (SalesPerson) iterator.next();
}
this.fieldOfficeClone = this.sales.getFieldOffice();
this.sales.setFieldOffice(this.secondSales.getFieldOffice());
}
Aggregations