protected IMdoBean createNewBean() { MdoTableAsEnum code = new MdoTableAsEnum(); // Use the existing data in database code.setId(1L); BigDecimal rate = basicTestRate.add(new BigDecimal(0.1f)); return createNewBean(code, rate); }
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() { MdoTableAsEnum codeToBeUpdated = new MdoTableAsEnum(); // Use the existing data in database codeToBeUpdated.setId(4L); 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 codeToBeUpdated = new MdoTableAsEnum(); // Use the existing data in database codeToBeUpdated.setId(5L); castedBean.setRate(basicTestRate.add(new BigDecimal(0.5f))); castedBean.setDeleted(true); this.getInstance().update(castedBean); // Reload the modified bean ValueAddedTax updatedBean = new ValueAddedTax(); updatedBean.setId(castedBean.getId()); this.getInstance().load(updatedBean); assertEquals( "ValueAddedTax code must be equals to unique key", castedBean.getCode().getId(), updatedBean.getCode().getId()); assertEquals( "ValueAddedTax rate must be equals", super.decimalFormat.format(castedBean.getRate()), super.decimalFormat.format(updatedBean.getRate())); assertTrue("ValueAddedTax must be deleted", updatedBean.isDeleted()); } catch (Exception e) { fail(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()); } }
@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()); } }