protected IMdoBean createNewBean() { BigDecimal amount = BigDecimal.TEN; Revenue revenue = new Revenue(); revenue.setId(1L); MdoTableAsEnum type = new MdoTableAsEnum(); type.setId(36L); return createNewBean(amount, revenue, type); }
protected List<IMdoBean> createListBeans() { List<IMdoBean> list = new ArrayList<IMdoBean>(); BigDecimal amount = BigDecimal.TEN; Revenue revenue = new Revenue(); revenue.setId(1L); MdoTableAsEnum type = new MdoTableAsEnum(); type.setId(37L); list.add(createNewBean(amount, revenue, type)); return list; }
@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()); } }
@Override public void doUpdate() { 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 amount = BigDecimal.valueOf(5.123456789); castedBean.setAmount(amount); castedBean.setDeleted(true); this.getInstance().update(castedBean); // Reload the modified bean RevenueCashing updatedBean = new RevenueCashing(); updatedBean.setId(castedBean.getId()); this.getInstance().load(updatedBean); assertEquals( "RevenueCashing amount must be equals to the updated value", super.decimalFormat.format(amount), super.decimalFormat.format(updatedBean.getAmount())); assertTrue("RevenueCashing must be deleted", castedBean.isDeleted()); this.getInstance().delete(updatedBean); } catch (Exception e) { fail(MdoTestCase.DEFAULT_FAILED_MESSAGE + ": " + e.getMessage()); } }