Beispiel #1
0
  @Test
  public void customerService() {
    Customer cust = addCustomer(UUID.randomUUID().toString());
    CustomerService service = addService(cust.getCust_id());
    assertNotNull(service);
    assertEquals(System.currentTimeMillis() / 1000 + 3600, service.getExpire_time());
    assertEquals(service.getStatus(), Status.AVAILABLE);

    CustomerService s1 = custRepo.getServiceById(service.getId());
    assertNotNull(s1);
    assertEquals(s1.getStatus(), Status.AVAILABLE);
    assertEquals(s1.getService_type(), ServiceType.WEIXIN);

    CustomerService s2 = custRepo.getService(cust.getCust_id(), ServiceType.WEIXIN);
    assertNotNull(s2);
    assertEquals(s2.getStatus(), Status.AVAILABLE);
    assertEquals(s2.getService_type(), ServiceType.WEIXIN);

    CustomerService s3 = custRepo.getService(cust.getCust_id(), ServiceType.OTHER);
    assertNull(s3);

    List<CustomerService> list = custRepo.getServices(cust.getCust_id());
    assertNotNull(list);
    assertNotEquals(0, list.size());
  }
Beispiel #2
0
 private Customer addCustomer(String cust_name) {
   Customer cust = new Customer();
   cust.setCust_name(cust_name);
   cust.setMemo(UUID.randomUUID().toString());
   cust.setStatus(Status.AVAILABLE);
   int result = custRepo.addCustomer(cust);
   assertNotEquals(0, result);
   this.CUST_ID_ = cust.getCust_id();
   return cust;
 }
Beispiel #3
0
 /** customer CRUD test */
 private void customerCRUD() {
   // Add
   Customer cust = addCustomer(UUID.randomUUID().toString());
   assertNotEquals(0, cust.getCust_id());
   // Update
   String memo = UUID.randomUUID().toString();
   String name = "CUSTOMER By JUnit 4 Modified";
   updateCustomer(cust, name, memo);
   cust = custRepo.getCustomer(CUST_ID_);
   assertEquals(name, cust.getCust_name());
   assertEquals(memo, cust.getMemo());
   // Select
   assertNotEquals(0, list().size());
   // Delete
   assertNotEquals(0, custRepo.delete(CUST_ID_));
   cust = custRepo.getCustomer(CUST_ID_);
   assertEquals(cust.getStatus(), Status.UNAVAILABLE);
 }
Beispiel #4
0
 private void updateCustomer(Customer cust, String name, String memo) {
   cust.setCust_name(name);
   cust.setMemo(memo);
   int result = custRepo.updateCustomer(cust);
   assertNotEquals(0, result);
 }