예제 #1
0
  @Test
  public void getCarritoPaginationTest() {
    // Page 1
    CarritoPageDTO dto1 = carritoPersistence.getCarritos(1, 2);
    Assert.assertNotNull(dto1);
    Assert.assertEquals(dto1.getRecords().size(), 2);
    Assert.assertEquals(dto1.getTotalRecords().longValue(), 3L);
    // Page 2
    CarritoPageDTO dto2 = carritoPersistence.getCarritos(2, 2);
    Assert.assertNotNull(dto2);
    Assert.assertEquals(dto2.getRecords().size(), 1);
    Assert.assertEquals(dto2.getTotalRecords().longValue(), 3L);

    for (CarritoDTO dto : dto1.getRecords()) {
      boolean found = false;
      for (CarritoEntity entity : data) {
        if (dto.getId().equals(entity.getId())) {
          found = true;
        }
      }
      Assert.assertTrue(found);
    }

    for (CarritoDTO dto : dto2.getRecords()) {
      boolean found = false;
      for (CarritoEntity entity : data) {
        if (dto.getId().equals(entity.getId())) {
          found = true;
        }
      }
      Assert.assertTrue(found);
    }
  }
예제 #2
0
 @Test
 public void deleteCarritoTest() {
   CarritoEntity entity = data.get(0);
   carritoPersistence.deleteCarrito(entity.getId());
   CarritoEntity deleted = em.find(CarritoEntity.class, entity.getId());
   Assert.assertNull(deleted);
 }
예제 #3
0
  @Test
  public void updateCarritoTest() {
    CarritoEntity entity = data.get(0);

    CarritoDTO dto = new CarritoDTO();
    dto.setId(entity.getId());
    dto.setName(generateRandom(String.class));
    dto.setClientId(generateRandom(Long.class));

    carritoPersistence.updateCarrito(dto);

    CarritoEntity resp = em.find(CarritoEntity.class, entity.getId());

    Assert.assertEquals(dto.getName(), resp.getName());
    Assert.assertEquals(dto.getClientId(), resp.getClientId());
  }
예제 #4
0
 @Test
 public void getCarritoTest() {
   CarritoEntity entity = data.get(0);
   CarritoDTO dto = carritoPersistence.getCarrito(entity.getId());
   Assert.assertNotNull(dto);
   Assert.assertEquals(entity.getName(), dto.getName());
   Assert.assertEquals(entity.getClientId(), dto.getClientId());
 }
예제 #5
0
 @Test
 public void getCarritosTest() {
   List<CarritoDTO> list = carritoPersistence.getCarritos();
   Assert.assertEquals(list.size(), data.size());
   for (CarritoDTO dto : list) {
     boolean found = false;
     for (CarritoEntity entity : data) {
       if (dto.getId().equals(entity.getId())) {
         found = true;
       }
     }
     Assert.assertTrue(found);
   }
 }