Search in sources :

Example 1 with Address

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

the class StoredProcedureVARRAYParametersTest method verify.

@Override
public void verify() {
    if ((results2.size() != 1) && (results3.size() != 1)) {
        throw new TestErrorException("Collections returned did not contain expected number of results");
    }
    // check that a Struct was returned for address
    Object addressOut = ((DatabaseRecord) results2.get(0)).get("address");
    if ((addressOut == null) || (!(addressOut instanceof Struct))) {
        throw new TestErrorException("Address returned by SProc_Read_PHolders was null or not a Struct :" + addressOut);
    }
    // This is an Address instance instead of struct since it picks up the address class from the value passed in.
    Address addressInOut = ((Address) ((DatabaseRecord) results3.get(0)).get("address"));
    if ((addressInOut == null) || !originalAddress.getStreet().equals(addressInOut.getStreet())) {
        throw new TestErrorException("Address in did not equal the address returned out by SProc_Delete_PHolders " + addressInOut);
    }
    Vector childrenRead = ((Vector) ((DatabaseRecord) results2.get(0)).get("childrenNames"));
    if ((childrenNames.size() != childrenRead.size()) && (!childrenNames.get(0).equals(childrenRead.get(0)))) {
        throw new TestErrorException("First Child's Name did not match what was returned out by SProc_Read_PHolders");
    }
    childrenRead = ((Vector) ((DatabaseRecord) results3.get(0)).get("childrenNames"));
    if ((childrenNames.size() != childrenRead.size()) && (!childrenNames.get(0).equals(childrenRead.get(0)))) {
        throw new TestErrorException("First Child's Name did not match what was returned out by SProc_Delete_PHolders");
    }
    Vector phonesRead = ((Vector) ((DatabaseRecord) results2.get(0)).get("phones"));
    if ((phoneNumbers.size() != phonesRead.size()) && (!phoneNumbers.get(0).equals(childrenRead.get(0)))) {
        throw new TestErrorException("First phone did not match what was returned out by SProc_Read_PHolders");
    }
    phonesRead = ((Vector) ((DatabaseRecord) results3.get(0)).get("phones"));
    if ((phoneNumbers.size() != phonesRead.size()) && (!phoneNumbers.get(0).equals(phonesRead.get(0)))) {
        throw new TestErrorException("First phone did not match what was returned out by SProc_Delete_PHolders");
    }
}
Also used : DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) Address(org.eclipse.persistence.testing.models.insurance.Address) TestErrorException(org.eclipse.persistence.testing.framework.TestErrorException) Vector(java.util.Vector) Struct(java.sql.Struct)

Example 2 with Address

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

the class StoredProcedureObjectRelationalParameters method verify.

@Override
public void verify() {
    if ((results2.size() != 1) && (results3.size() != 1)) {
        throw new TestErrorException("Collections returned did not contain expected number of results");
    }
    Address addressRead = ((Address) ((DatabaseRecord) results2.get(0)).get("address"));
    if (!originalAddress.getStreet().equals(addressRead.getStreet())) {
        throw new TestErrorException("Address in did not equal the address returned out by SProc_Read_PHolders");
    }
    Address addressRemoved = ((Address) ((DatabaseRecord) results3.get(0)).get("address"));
    if (!originalAddress.getStreet().equals(addressRemoved.getStreet())) {
        throw new TestErrorException("Address in did not equal the address returned out by SProc_Delete_PHolders");
    }
}
Also used : Address(org.eclipse.persistence.testing.models.insurance.Address) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord)

Example 3 with Address

use of org.eclipse.persistence.testing.models.insurance.Address 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)

Example 4 with Address

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

the class ComplexJoinedAttributeQueryTest method test.

@Override
public void test() {
    ReadAllQuery query = new ReadAllQuery(Address.class);
    Expression zipCodeExpression = new ExpressionBuilder().get("zipCode").equal("28150");
    Expression ssnExpression = new ExpressionBuilder().get("policyHolder").get("ssn").equal(1111);
    Expression expression = zipCodeExpression.or(ssnExpression);
    Expression policyExpression = new ExpressionBuilder().get("policyHolder").anyOf("policies").get("policyNumber").equal(200);
    Expression phoneExpression = new ExpressionBuilder().get("policyHolder").anyOf("phones").get("areaCode").equal(123);
    expression = expression.and(policyExpression).and(phoneExpression);
    query.setSelectionCriteria(expression);
    query.addJoinedAttribute(new ExpressionBuilder().get("policyHolder"));
    query.addJoinedAttribute(new ExpressionBuilder().get("policyHolder").anyOf("policies"));
    query.addJoinedAttribute(new ExpressionBuilder().get("policyHolder").anyOf("phones"));
    Collection<Address> result = (Collection<Address>) getSession().executeQuery(query);
    if (result != null && result.size() == 1) {
        queryResult = (Address) result.toArray()[0];
    }
}
Also used : Address(org.eclipse.persistence.testing.models.insurance.Address) Expression(org.eclipse.persistence.expressions.Expression) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) Collection(java.util.Collection) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

Address (org.eclipse.persistence.testing.models.insurance.Address)4 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)2 Struct (java.sql.Struct)1 Collection (java.util.Collection)1 Vector (java.util.Vector)1 Expression (org.eclipse.persistence.expressions.Expression)1 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)1 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)1 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)1 Claim (org.eclipse.persistence.testing.models.insurance.Claim)1 Policy (org.eclipse.persistence.testing.models.insurance.Policy)1 PolicyHolder (org.eclipse.persistence.testing.models.insurance.PolicyHolder)1