Search in sources :

Example 1 with Policy

use of org.eclipse.persistence.testing.models.insurance.Policy in project eclipselink by eclipse-ee4j.

the class PolicyHolderClient method run.

@Override
public void run() {
    try {
        ExpressionBuilder builder = new ExpressionBuilder();
        Expression exp = builder.get("policyHolder").get("ssn").equal(1111);
        for (int i = 0; i < 1; i++) {
            Policy policy = (Policy) this.clientSession.readObject(org.eclipse.persistence.testing.models.insurance.Policy.class, exp);
            if ((policy == null) || (policy.getPolicyHolder() == null) || policy.getPolicyHolder().getLastName().equals("")) {
                throw new TestWarningException("Client/Server dead lock test fails as null is returned");
            }
        }
    } catch (Exception exception) {
        this.server.errorOccured = true;
        exception.printStackTrace(System.out);
    }
}
Also used : Policy(org.eclipse.persistence.testing.models.insurance.Policy)

Example 2 with Policy

use of org.eclipse.persistence.testing.models.insurance.Policy in project eclipselink by eclipse-ee4j.

the class InsuranceObjectRelationalTestModel method getNullUpdatesTestSuite.

/**
 * For bug 2730536 try setting various object-relational fields to null.
 * Test difficulties: setting values to null effectively triggers deletes on
 * the database.  This triggers database constraints and also errors as all this
 * is done outside a unit of work.
 * It was not possible to set an existing Ref to null, without also deleting
 * what the ref pointed to.
 */
protected static TestSuite getNullUpdatesTestSuite() {
    TestSuite testSuite = new TestSuite();
    testSuite.setName("NullUpdatesTestSuite");
    testSuite.setDescription("Tests setting various object-relational fields to null.");
    // Do not use Population manager, as it does not return clones and we are
    // modifying the objects before the test.
    PolicyHolder policyHolder;
    Policy policy;
    Claim claim;
    WriteObjectTest test;
    // Test 1: Setting arrays, object arrays and Structs to null.
    policyHolder = PolicyHolder.example1();
    // Test setting an Array to null.
    policyHolder.setChildrenNames(null);
    // Test setting a Struct to null.
    policyHolder.setAddress(null);
    policyHolder.setOccupation(null);
    // Test seting an ObjectArray to null.
    policyHolder.setPhones(null);
    test = new WriteObjectTest(policyHolder);
    test.setShouldBindAllParameters(true);
    test.setMakesTrivialUpdate(false);
    test.setDescription("Tests setting null on Array, Structure, and ObjectArray mappings.");
    testSuite.addTest(test);
    // Test 2: Setting arrays and object arrays to empty vectors.
    policyHolder = PolicyHolder.example1();
    // Test setting an Array to null.
    policyHolder.setChildrenNames(new Vector());
    // Test seting an ObjectArray to null.
    policyHolder.setPhones(new Vector());
    test = new WriteObjectTest(policyHolder);
    test.setShouldBindAllParameters(true);
    test.setMakesTrivialUpdate(false);
    test.setDescription("Tests setting empty vectors on Array and NestedTable mappings.");
    testSuite.addTest(test);
    // Test 3: Setting nested tables and references to null.
    // This policy does not exist on database and has null values for Ref and NestedTables.
    policy = HousePolicy.example3();
    test = new WriteObjectTest(policy);
    test.setShouldBindAllParameters(true);
    test.setDescription("Tests setting null on Ref and NestedTable mappings.");
    testSuite.addTest(test);
    // Test 4: Setting a nested table to null, with non-trivial update.
    policyHolder = PolicyHolder.example1();
    policy = (Policy) policyHolder.getPolicies().firstElement();
    // Test setting a nested table to null.
    policy.setClaims(null);
    test = new WriteObjectTest(policy);
    test.setShouldBindAllParameters(true);
    test.setMakesTrivialUpdate(false);
    test.setDescription("Tests setting null on a Ref mapping.");
    testSuite.addTest(test);
    return testSuite;
}
Also used : Policy(org.eclipse.persistence.testing.models.insurance.Policy) HousePolicy(org.eclipse.persistence.testing.models.insurance.HousePolicy) PolicyHolder(org.eclipse.persistence.testing.models.insurance.PolicyHolder) TestSuite(org.eclipse.persistence.testing.framework.TestSuite) WriteObjectTest(org.eclipse.persistence.testing.framework.WriteObjectTest) Vector(java.util.Vector) Claim(org.eclipse.persistence.testing.models.insurance.Claim)

Example 3 with Policy

use of org.eclipse.persistence.testing.models.insurance.Policy in project eclipselink by eclipse-ee4j.

the class DeleteOrderUnitOfWorkTest method test.

@Override
protected void test() {
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression expression = builder.get("id").equal(303);
    UnitOfWork uow = getSession().acquireUnitOfWork();
    Claim claim = (Claim) uow.readObject(org.eclipse.persistence.testing.models.insurance.Claim.class, expression);
    Policy policy = claim.getPolicy();
    PolicyHolder holder = policy.getPolicyHolder();
    Address address = holder.getAddress();
    uow.deleteObject(claim);
    uow.deleteObject(address);
    uow.deleteObject(policy);
    uow.deleteObject(holder);
    uow.commit();
}
Also used : Policy(org.eclipse.persistence.testing.models.insurance.Policy) PolicyHolder(org.eclipse.persistence.testing.models.insurance.PolicyHolder) Address(org.eclipse.persistence.testing.models.insurance.Address) Claim(org.eclipse.persistence.testing.models.insurance.Claim)

Aggregations

Policy (org.eclipse.persistence.testing.models.insurance.Policy)3 Claim (org.eclipse.persistence.testing.models.insurance.Claim)2 PolicyHolder (org.eclipse.persistence.testing.models.insurance.PolicyHolder)2 Vector (java.util.Vector)1 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)1 WriteObjectTest (org.eclipse.persistence.testing.framework.WriteObjectTest)1 Address (org.eclipse.persistence.testing.models.insurance.Address)1 HousePolicy (org.eclipse.persistence.testing.models.insurance.HousePolicy)1