コード例 #1
0
  @Override
  public void doUpdateFieldsAndDeleteByKeysSpecific() {
    IMdoBean newBean = null;
    BigDecimal amount = BigDecimal.TEN;
    Revenue revenue = new Revenue();
    revenue.setId(1L);
    MdoTableAsEnum type = new MdoTableAsEnum();
    type.setId(38L);
    newBean = createNewBean(amount, revenue, type);
    try {
      // Create new bean to be updated
      IMdoBean beanToBeUpdated = this.getInstance().insert(newBean);
      assertTrue(
          "IMdoBean must be instance of " + RevenueCashing.class,
          beanToBeUpdated instanceof RevenueCashing);
      RevenueCashing castedBean = (RevenueCashing) beanToBeUpdated;
      assertNotNull("RevenueCashing amount must not be null", castedBean.getAmount());
      assertEquals(
          "RevenueCashing amount must be equals to the inserted value",
          amount,
          castedBean.getAmount());
      assertFalse("RevenueCashing must not be deleted", castedBean.isDeleted());

      // Update the created bean
      Map<String, Object> fields = new HashMap<String, Object>();
      Map<String, Object> keys = new HashMap<String, Object>();
      castedBean.setAmount(BigDecimal.ONE);
      fields.put("amount", castedBean.getAmount());
      keys.put("id", castedBean.getId());
      this.getInstance().updateFieldsByKeys(fields, keys);
      // Reload the modified bean
      RevenueCashing updatedBean = (RevenueCashing) createNewBean();
      updatedBean.setId(castedBean.getId());
      this.getInstance().load(updatedBean);
      assertEquals("Check updated fields ", castedBean.getAmount(), updatedBean.getAmount());

      // Delete the bean by keys
      // Take the fields as keys
      super.doDeleteByKeysSpecific(updatedBean, fields);
    } catch (Exception e) {
      fail(MdoTestCase.DEFAULT_FAILED_MESSAGE + " " + e.getMessage());
    }
  }
コード例 #2
0
  @Override
  public void doUpdateFieldsAndDeleteByKeysSpecific() {
    MdoTableAsEnum codeToBeUpdated = new MdoTableAsEnum();
    // Use the existing data in database
    codeToBeUpdated.setId(5L);
    BigDecimal rateToBeUpdated = basicTestRate.add(new BigDecimal(0.4f));
    try {
      // Create new bean to be updated
      IMdoBean beanToBeUpdated =
          this.getInstance().insert(createNewBean(codeToBeUpdated, rateToBeUpdated));
      assertTrue(
          "IMdoBean must be instance of " + ValueAddedTax.class,
          beanToBeUpdated instanceof ValueAddedTax);
      ValueAddedTax castedBean = (ValueAddedTax) beanToBeUpdated;
      assertEquals(
          "ValueAddedTax code must be equals to unique key", codeToBeUpdated, castedBean.getCode());
      assertEquals("ValueAddedTax rate must be equals", rateToBeUpdated, castedBean.getRate());
      assertFalse("ValueAddedTax must not be deleted", castedBean.isDeleted());

      // Update the created bean
      Map<String, Object> fields = new HashMap<String, Object>();
      Map<String, Object> keys = new HashMap<String, Object>();
      castedBean.setRate(BigDecimal.ONE);
      fields.put("rate", castedBean.getRate());
      keys.put("id", castedBean.getId());
      this.getInstance().updateFieldsByKeys(fields, keys);
      // Reload the modified bean
      ValueAddedTax updatedBean = (ValueAddedTax) createNewBean();
      updatedBean.setId(castedBean.getId());
      this.getInstance().load(updatedBean);
      assertEquals("Check updated fields ", castedBean.getRate(), updatedBean.getRate());

      // Delete the bean by keys
      // Take the fields as keys
      super.doDeleteByKeysSpecific(updatedBean, fields);
    } catch (Exception e) {
      fail(MdoTestCase.DEFAULT_FAILED_MESSAGE + " " + e.getMessage());
    }
  }