// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/mock/MockDataService.java
// public class MockDataService extends DataService {
// 
//     private static MockDataService INSTANCE;
// 
//     private List<Product> products;
//     private List<Category> categories;
//     private int nextProductId = 0;
// 
//     private MockDataService() {
//         categories = MockDataGenerator.createCategories();
//         products = MockDataGenerator.createProducts(categories);
//         nextProductId = products.size() + 1;
//     }
// 
//     public synchronized static DataService getInstance() {
//         if (INSTANCE == null) {
//             INSTANCE = new MockDataService();
//         }
//         return INSTANCE;
//     }
// 
//     @Override
//     public synchronized List<Product> getAllProducts() {
//         return products;
//     }
// 
//     @Override
//     public synchronized List<Category> getAllCategories() {
//         return categories;
//     }
// 
//     @Override
//     public synchronized void updateProduct(Product p) {
//         if (p.getId() < 0) {
//             // New product
//             p.setId(nextProductId++);
//             products.add(p);
//             return;
//         }
//         for (int i = 0; i < products.size(); i++) {
//             if (products.get(i).getId() == p.getId()) {
//                 products.set(i, p);
//                 return;
//             }
//         }
// 
//         throw new IllegalArgumentException("No product with id " + p.getId()
//                 + " found");
//     }
// 
//     @Override
//     public synchronized Product getProductById(int productId) {
//         for (int i = 0; i < products.size(); i++) {
//             if (products.get(i).getId() == productId) {
//                 return products.get(i);
//             }
//         }
//         return null;
//     }
// 
//     @Override
//     public synchronized void deleteProduct(int productId) {
//         Product p = getProductById(productId);
//         if (p == null) {
//             throw new IllegalArgumentException("Product with id " + productId
//                     + " not found");
//         }
//         products.remove(p);
//     }
// }


import org.junit.Before;
import org.junit.Test;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.mock.MockDataService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
package com.github.mcollovati.vertxvaadin.flowdemo.backend;



/**
 * Simple unit test for the back-end data service.
 */
public class DataServiceTest {

    private DataService service;

    @Before
    public void setUp() throws Exception {
        service = MockDataService.getInstance();
    }

    @Test
    public void testDataServiceCanFetchProducts() throws Exception {
        assertFalse(service.getAllProducts().isEmpty());
    }

    @Test
    public void testDataServiceCanFetchCategories() throws Exception {
        assertFalse(service.getAllCategories().isEmpty());
    }

    @Test
    public void testUpdateProduct_updatesTheProduct() throws Exception {
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/mock/MockDataService.java
// public class MockDataService extends DataService {
// 
//     private static MockDataService INSTANCE;
// 
//     private List<Product> products;
//     private List<Category> categories;
//     private int nextProductId = 0;
// 
//     private MockDataService() {
//         categories = MockDataGenerator.createCategories();
//         products = MockDataGenerator.createProducts(categories);
//         nextProductId = products.size() + 1;
//     }
// 
//     public synchronized static DataService getInstance() {
//         if (INSTANCE == null) {
//             INSTANCE = new MockDataService();
//         }
//         return INSTANCE;
//     }
// 
//     @Override
//     public synchronized List<Product> getAllProducts() {
//         return products;
//     }
// 
//     @Override
//     public synchronized List<Category> getAllCategories() {
//         return categories;
//     }
// 
//     @Override
//     public synchronized void updateProduct(Product p) {
//         if (p.getId() < 0) {
//             // New product
//             p.setId(nextProductId++);
//             products.add(p);
//             return;
//         }
//         for (int i = 0; i < products.size(); i++) {
//             if (products.get(i).getId() == p.getId()) {
//                 products.set(i, p);
//                 return;
//             }
//         }
// 
//         throw new IllegalArgumentException("No product with id " + p.getId()
//                 + " found");
//     }
// 
//     @Override
//     public synchronized Product getProductById(int productId) {
//         for (int i = 0; i < products.size(); i++) {
//             if (products.get(i).getId() == productId) {
//                 return products.get(i);
//             }
//         }
//         return null;
//     }
// 
//     @Override
//     public synchronized void deleteProduct(int productId) {
//         Product p = getProductById(productId);
//         if (p == null) {
//             throw new IllegalArgumentException("Product with id " + productId
//                     + " not found");
//         }
//         products.remove(p);
//     }
// }


// Path: flow-bookstore/bookstore-backend/src/test/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/DataServiceTest.java
import org.junit.Before;
import org.junit.Test;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.mock.MockDataService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

package com.github.mcollovati.vertxvaadin.flowdemo.backend;



/**
 * Simple unit test for the back-end data service.
 */
public class DataServiceTest {

    private DataService service;

    @Before
    public void setUp() throws Exception {
        service = MockDataService.getInstance();
    }

    @Test
    public void testDataServiceCanFetchProducts() throws Exception {
        assertFalse(service.getAllProducts().isEmpty());
    }

    @Test
    public void testDataServiceCanFetchCategories() throws Exception {
        assertFalse(service.getAllCategories().isEmpty());
    }

    @Test
    public void testUpdateProduct_updatesTheProduct() throws Exception {
        Product p = service.getAllProducts().iterator().next();