Esempio n. 1
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);
   }
 }
Esempio n. 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);
 }
Esempio n. 3
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());
 }
Esempio n. 4
0
 private void insertData() {
   for (int i = 0; i < 3; i++) {
     CarritoEntity entity = new CarritoEntity();
     entity.setName(generateRandom(String.class));
     entity.setClientId(generateRandom(Long.class));
     em.persist(entity);
     data.add(entity);
   }
 }
Esempio n. 5
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());
  }