@Test(groups = "integration")
  public void createCreditCardTest() throws PayPalRESTException {
    logger.info("**** Create CreditCard ****");
    logger.info("Generated Access Token = " + TokenHolder.accessToken);

    CreditCard creditCard = new CreditCard();
    creditCard.setExpireMonth(EXPMONTH);
    creditCard.setExpireYear(EXPYEAR);
    creditCard.setNumber(NUMBER);
    creditCard.setType(TYPE);
    this.creditCard = creditCard.create(TokenHolder.accessToken);
    logger.info("Request = " + CreditCard.getLastRequest());
    logger.info("Response = " + CreditCard.getLastResponse());
    logger.info("Credit Card created with ID = " + this.creditCard.getId());
    Assert.assertEquals(true, "ok".equalsIgnoreCase(this.creditCard.getState()));
    logger.info("Created Credit Card status = " + this.creditCard.getState());
    createdCreditCardId = this.creditCard.getId();
  }
 public static CreditCard createDummyCreditCard() {
   CreditCard creditCard = new CreditCard();
   creditCard.setBillingAddress(BILLINGADDRESS);
   creditCard.setExpireMonth(EXPMONTH);
   creditCard.setExpireYear(EXPYEAR);
   creditCard.setFirstName(FIRSTNAME);
   creditCard.setLastName(LASTNAME);
   creditCard.setNumber(NUMBER);
   creditCard.setType(TYPE);
   creditCard.setCvv2(CVV2);
   creditCard.setBillingAddress(BILLINGADDRESS);
   creditCard.setId(ID);
   creditCard.setExternalCustomerId(EXTERNAL_CUSTOMER_ID);
   creditCard.setState(STATE);
   creditCard.setValidUntil(VALIDUNTIL);
   List<Links> links = new ArrayList<Links>();
   links.add(LinksTestCase.createLinks());
   creditCard.setLinks(links);
   return creditCard;
 }
Exemplo n.º 3
0
  public static Customer createCreditCard(EntityManagerFactory factory, Customer cust) {
    CreditCard card = new CreditCard();
    card.setExpirationDate(new java.util.Date());
    card.setNumber("4444-4444-4444-4444");
    card.setNameOnCard("William Burke");
    card.setCreditOrganization("Capital One");
    card.setCustomer(cust);

    EntityManager manager = factory.createEntityManager();
    try {
      manager.getTransaction().begin();
      manager.persist(card);
      manager.getTransaction().commit();

      // Show that card.getCustomer() returns null

      manager.clear();

      CreditCard cardCopy = manager.find(CreditCard.class, card.getId());
      System.out.println("should be null: " + cardCopy.getCustomer());

      manager.getTransaction().begin();
      System.out.println("now set the owning side of the relationship");
      Customer custCopy = manager.find(Customer.class, cust.getId());
      custCopy.setCreditCard(cardCopy);
      manager.getTransaction().commit();

      manager.clear();

      cardCopy = manager.find(CreditCard.class, card.getId());
      System.out.println("should be set now: " + cardCopy.getCustomer().getFirstName());
    } finally {
      manager.close();
    }
    return cust;
  }