コード例 #1
0
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    ShoppingOrder newShoppingOrder = addShoppingOrder();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(ShoppingOrder.class, ShoppingOrder.class.getClassLoader());

    dynamicQuery.add(RestrictionsFactoryUtil.eq("orderId", newShoppingOrder.getOrderId()));

    List<ShoppingOrder> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    ShoppingOrder existingShoppingOrder = result.get(0);

    Assert.assertEquals(existingShoppingOrder, newShoppingOrder);
  }
コード例 #2
0
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    ShoppingOrder newShoppingOrder = addShoppingOrder();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(ShoppingOrder.class, ShoppingOrder.class.getClassLoader());

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("orderId"));

    Object newOrderId = newShoppingOrder.getOrderId();

    dynamicQuery.add(RestrictionsFactoryUtil.in("orderId", new Object[] {newOrderId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingOrderId = result.get(0);

    Assert.assertEquals(existingOrderId, newOrderId);
  }
コード例 #3
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    ShoppingOrder newShoppingOrder = _persistence.create(pk);

    newShoppingOrder.setGroupId(ServiceTestUtil.nextLong());

    newShoppingOrder.setCompanyId(ServiceTestUtil.nextLong());

    newShoppingOrder.setUserId(ServiceTestUtil.nextLong());

    newShoppingOrder.setUserName(ServiceTestUtil.randomString());

    newShoppingOrder.setCreateDate(ServiceTestUtil.nextDate());

    newShoppingOrder.setModifiedDate(ServiceTestUtil.nextDate());

    newShoppingOrder.setNumber(ServiceTestUtil.randomString());

    newShoppingOrder.setTax(ServiceTestUtil.nextDouble());

    newShoppingOrder.setShipping(ServiceTestUtil.nextDouble());

    newShoppingOrder.setAltShipping(ServiceTestUtil.randomString());

    newShoppingOrder.setRequiresShipping(ServiceTestUtil.randomBoolean());

    newShoppingOrder.setInsure(ServiceTestUtil.randomBoolean());

    newShoppingOrder.setInsurance(ServiceTestUtil.nextDouble());

    newShoppingOrder.setCouponCodes(ServiceTestUtil.randomString());

    newShoppingOrder.setCouponDiscount(ServiceTestUtil.nextDouble());

    newShoppingOrder.setBillingFirstName(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingLastName(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingEmailAddress(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingCompany(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingStreet(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingCity(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingState(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingZip(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingCountry(ServiceTestUtil.randomString());

    newShoppingOrder.setBillingPhone(ServiceTestUtil.randomString());

    newShoppingOrder.setShipToBilling(ServiceTestUtil.randomBoolean());

    newShoppingOrder.setShippingFirstName(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingLastName(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingEmailAddress(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingCompany(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingStreet(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingCity(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingState(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingZip(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingCountry(ServiceTestUtil.randomString());

    newShoppingOrder.setShippingPhone(ServiceTestUtil.randomString());

    newShoppingOrder.setCcName(ServiceTestUtil.randomString());

    newShoppingOrder.setCcType(ServiceTestUtil.randomString());

    newShoppingOrder.setCcNumber(ServiceTestUtil.randomString());

    newShoppingOrder.setCcExpMonth(ServiceTestUtil.nextInt());

    newShoppingOrder.setCcExpYear(ServiceTestUtil.nextInt());

    newShoppingOrder.setCcVerNumber(ServiceTestUtil.randomString());

    newShoppingOrder.setComments(ServiceTestUtil.randomString());

    newShoppingOrder.setPpTxnId(ServiceTestUtil.randomString());

    newShoppingOrder.setPpPaymentStatus(ServiceTestUtil.randomString());

    newShoppingOrder.setPpPaymentGross(ServiceTestUtil.nextDouble());

    newShoppingOrder.setPpReceiverEmail(ServiceTestUtil.randomString());

    newShoppingOrder.setPpPayerEmail(ServiceTestUtil.randomString());

    newShoppingOrder.setSendOrderEmail(ServiceTestUtil.randomBoolean());

    newShoppingOrder.setSendShippingEmail(ServiceTestUtil.randomBoolean());

    _persistence.update(newShoppingOrder);

    ShoppingOrder existingShoppingOrder =
        _persistence.findByPrimaryKey(newShoppingOrder.getPrimaryKey());

    Assert.assertEquals(existingShoppingOrder.getOrderId(), newShoppingOrder.getOrderId());
    Assert.assertEquals(existingShoppingOrder.getGroupId(), newShoppingOrder.getGroupId());
    Assert.assertEquals(existingShoppingOrder.getCompanyId(), newShoppingOrder.getCompanyId());
    Assert.assertEquals(existingShoppingOrder.getUserId(), newShoppingOrder.getUserId());
    Assert.assertEquals(existingShoppingOrder.getUserName(), newShoppingOrder.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingShoppingOrder.getCreateDate()),
        Time.getShortTimestamp(newShoppingOrder.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingShoppingOrder.getModifiedDate()),
        Time.getShortTimestamp(newShoppingOrder.getModifiedDate()));
    Assert.assertEquals(existingShoppingOrder.getNumber(), newShoppingOrder.getNumber());
    AssertUtils.assertEquals(existingShoppingOrder.getTax(), newShoppingOrder.getTax());
    AssertUtils.assertEquals(existingShoppingOrder.getShipping(), newShoppingOrder.getShipping());
    Assert.assertEquals(existingShoppingOrder.getAltShipping(), newShoppingOrder.getAltShipping());
    Assert.assertEquals(
        existingShoppingOrder.getRequiresShipping(), newShoppingOrder.getRequiresShipping());
    Assert.assertEquals(existingShoppingOrder.getInsure(), newShoppingOrder.getInsure());
    AssertUtils.assertEquals(existingShoppingOrder.getInsurance(), newShoppingOrder.getInsurance());
    Assert.assertEquals(existingShoppingOrder.getCouponCodes(), newShoppingOrder.getCouponCodes());
    AssertUtils.assertEquals(
        existingShoppingOrder.getCouponDiscount(), newShoppingOrder.getCouponDiscount());
    Assert.assertEquals(
        existingShoppingOrder.getBillingFirstName(), newShoppingOrder.getBillingFirstName());
    Assert.assertEquals(
        existingShoppingOrder.getBillingLastName(), newShoppingOrder.getBillingLastName());
    Assert.assertEquals(
        existingShoppingOrder.getBillingEmailAddress(), newShoppingOrder.getBillingEmailAddress());
    Assert.assertEquals(
        existingShoppingOrder.getBillingCompany(), newShoppingOrder.getBillingCompany());
    Assert.assertEquals(
        existingShoppingOrder.getBillingStreet(), newShoppingOrder.getBillingStreet());
    Assert.assertEquals(existingShoppingOrder.getBillingCity(), newShoppingOrder.getBillingCity());
    Assert.assertEquals(
        existingShoppingOrder.getBillingState(), newShoppingOrder.getBillingState());
    Assert.assertEquals(existingShoppingOrder.getBillingZip(), newShoppingOrder.getBillingZip());
    Assert.assertEquals(
        existingShoppingOrder.getBillingCountry(), newShoppingOrder.getBillingCountry());
    Assert.assertEquals(
        existingShoppingOrder.getBillingPhone(), newShoppingOrder.getBillingPhone());
    Assert.assertEquals(
        existingShoppingOrder.getShipToBilling(), newShoppingOrder.getShipToBilling());
    Assert.assertEquals(
        existingShoppingOrder.getShippingFirstName(), newShoppingOrder.getShippingFirstName());
    Assert.assertEquals(
        existingShoppingOrder.getShippingLastName(), newShoppingOrder.getShippingLastName());
    Assert.assertEquals(
        existingShoppingOrder.getShippingEmailAddress(),
        newShoppingOrder.getShippingEmailAddress());
    Assert.assertEquals(
        existingShoppingOrder.getShippingCompany(), newShoppingOrder.getShippingCompany());
    Assert.assertEquals(
        existingShoppingOrder.getShippingStreet(), newShoppingOrder.getShippingStreet());
    Assert.assertEquals(
        existingShoppingOrder.getShippingCity(), newShoppingOrder.getShippingCity());
    Assert.assertEquals(
        existingShoppingOrder.getShippingState(), newShoppingOrder.getShippingState());
    Assert.assertEquals(existingShoppingOrder.getShippingZip(), newShoppingOrder.getShippingZip());
    Assert.assertEquals(
        existingShoppingOrder.getShippingCountry(), newShoppingOrder.getShippingCountry());
    Assert.assertEquals(
        existingShoppingOrder.getShippingPhone(), newShoppingOrder.getShippingPhone());
    Assert.assertEquals(existingShoppingOrder.getCcName(), newShoppingOrder.getCcName());
    Assert.assertEquals(existingShoppingOrder.getCcType(), newShoppingOrder.getCcType());
    Assert.assertEquals(existingShoppingOrder.getCcNumber(), newShoppingOrder.getCcNumber());
    Assert.assertEquals(existingShoppingOrder.getCcExpMonth(), newShoppingOrder.getCcExpMonth());
    Assert.assertEquals(existingShoppingOrder.getCcExpYear(), newShoppingOrder.getCcExpYear());
    Assert.assertEquals(existingShoppingOrder.getCcVerNumber(), newShoppingOrder.getCcVerNumber());
    Assert.assertEquals(existingShoppingOrder.getComments(), newShoppingOrder.getComments());
    Assert.assertEquals(existingShoppingOrder.getPpTxnId(), newShoppingOrder.getPpTxnId());
    Assert.assertEquals(
        existingShoppingOrder.getPpPaymentStatus(), newShoppingOrder.getPpPaymentStatus());
    AssertUtils.assertEquals(
        existingShoppingOrder.getPpPaymentGross(), newShoppingOrder.getPpPaymentGross());
    Assert.assertEquals(
        existingShoppingOrder.getPpReceiverEmail(), newShoppingOrder.getPpReceiverEmail());
    Assert.assertEquals(
        existingShoppingOrder.getPpPayerEmail(), newShoppingOrder.getPpPayerEmail());
    Assert.assertEquals(
        existingShoppingOrder.getSendOrderEmail(), newShoppingOrder.getSendOrderEmail());
    Assert.assertEquals(
        existingShoppingOrder.getSendShippingEmail(), newShoppingOrder.getSendShippingEmail());
  }