@Test(dependsOnMethods = "readCreditCard", enabled = true) private void updateCreditCard() { creditCardRepository = ctx.getBean(CreditCardRepository.class); // GET THE OBJECT CreditCard creditCard = creditCardRepository.findOne(id); // CREATAE A NEW COPY CreditCard updatedCreditCard = new CreditCard.Builder("5555-555-555-55555") .CreditCard(creditCard) .nameOnCreditCard("MR JOE DOLE") .build(); // SAVE THE NEW COPY creditCardRepository.save(updatedCreditCard); // GET NEW CARD AND TEST CreditCard newCreditCard = creditCardRepository.findOne(id); Assert.assertEquals(newCreditCard.getNameOnCreditCard(), "MR JOE DOLE"); }
// TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // @Test(enabled = true) public void createCreditCard() { // *** (i) Create The Entity // Get The Repository Object creditCardRepository = ctx.getBean(CreditCardRepository.class); // Create the Credit card Object using the Builder Design Pattern with ID. It will be generated // USE BUILDER PATTERN FOR CREATING ALL YOUR ENTITIES CreditCard creditCard = new CreditCard.Builder("5555-555-555-55555") .balance(new BigDecimal(200.00)) .expiryDate(new Date()) .nameOnCreditCard("John Dole") .build(); // SAVE THE CREDIT CARD OBJECT creditCardRepository.save(creditCard); // STORE THE ID FOR LATER USE id = creditCard.getId(); // ASSERT THAT THE OBJECT IS SAVED Assert.assertNotNull(creditCard); }
@Test(dependsOnMethods = "createCreditCard", enabled = true) public void readCreditCard() { creditCardRepository = ctx.getBean(CreditCardRepository.class); CreditCard creditcard = creditCardRepository.findOne(id); Assert.assertEquals(creditcard.getNameOnCreditCard(), "John Dole"); }