// Path: src/main/java/org/javiermf/features/Application.java
// @SpringBootApplication
// public class Application {
// 
//     public static void main(String[] args) throws Exception {
//         SpringApplication.run(Application.class, args);
//     }
// 
// }
// 
// Path: src/main/java/org/javiermf/features/daos/ProductsDAO.java
// @Repository
// public class ProductsDAO {
// 
//     @PersistenceContext
//     private EntityManager entityManager;
// 
//     QProduct qProduct = QProduct.product;
//     QFeature qFeature = QFeature.feature;
//     QFeatureConstraint qFeatureConstraint = QFeatureConstraint.featureConstraint;
// 
//     public List<Product> findAll() {
//         JPAQuery query = new JPAQuery(entityManager);
// 
//         return query.from(qProduct).list(qProduct);
//     }
// 
//     public Product findByName(String name) {
//         JPAQuery query = new JPAQuery(entityManager);
// 
//         query.from(qProduct).where(qProduct.name.eq(name));
//         Product product = query.singleResult(qProduct);
//         if (product == null) {
//             throw new ObjectNotFoundException(name);
//         }
//         return product;
//     }
// 
//     @Transactional
//     public void deleteByName(String productName) {
//         Product product = findByName(productName);
//         entityManager.remove(product);
// 
//     }
// 
//     @Transactional
//     public void deleteConstraintsForProduct(String productName) {
//         Product product = findByName(productName);
//         for (FeatureConstraint featureConstraint : product.getProductFeatureConstraints()) {
//             entityManager.remove(featureConstraint);
//         }
//         product.getProductFeatureConstraints().clear();
//     }
// 
//     @Transactional
//     public void insert(Product product) {
//         entityManager.persist(product);
//     }
// 
//     @Transactional
//     public void insertFeature(Feature feature) {
//         entityManager.persist(feature);
//     }
// 
//     @Transactional
//     public void deleteFeature(Feature feature) {
//         JPADeleteClause deleteClause = new JPADeleteClause(entityManager, qFeature);
//         deleteClause.where(qFeature.id.eq(feature.getId()));
//         deleteClause.execute();
//     }
// 
//     @Transactional
//     public void insertConstraint(FeatureConstraint constraint) {
//         entityManager.persist(constraint);
//     }
// 
//     @Transactional
//     public void deleteConstraintForProduct(String productName, Long constraintId) {
//         JPADeleteClause deleteClause = new JPADeleteClause(entityManager, qFeatureConstraint);
//         deleteClause.where(qFeatureConstraint.id.eq(constraintId));
//         deleteClause.execute();
//     }
// }


import org.apache.http.HttpStatus;
import org.javiermf.features.Application;
import org.javiermf.features.daos.ProductsDAO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import static com.jayway.restassured.RestAssured.when;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.util.MatcherAssertionErrors.assertThat;
package org.javiermf.features.services.rest;




@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@Sql({"/empty-db.sql", "/data-test.sql"})
@WebIntegrationTest
public class ProductResourceIntegrationTests {

    @Autowired
// Path: src/main/java/org/javiermf/features/Application.java
// @SpringBootApplication
// public class Application {
// 
//     public static void main(String[] args) throws Exception {
//         SpringApplication.run(Application.class, args);
//     }
// 
// }
// 
// Path: src/main/java/org/javiermf/features/daos/ProductsDAO.java
// @Repository
// public class ProductsDAO {
// 
//     @PersistenceContext
//     private EntityManager entityManager;
// 
//     QProduct qProduct = QProduct.product;
//     QFeature qFeature = QFeature.feature;
//     QFeatureConstraint qFeatureConstraint = QFeatureConstraint.featureConstraint;
// 
//     public List<Product> findAll() {
//         JPAQuery query = new JPAQuery(entityManager);
// 
//         return query.from(qProduct).list(qProduct);
//     }
// 
//     public Product findByName(String name) {
//         JPAQuery query = new JPAQuery(entityManager);
// 
//         query.from(qProduct).where(qProduct.name.eq(name));
//         Product product = query.singleResult(qProduct);
//         if (product == null) {
//             throw new ObjectNotFoundException(name);
//         }
//         return product;
//     }
// 
//     @Transactional
//     public void deleteByName(String productName) {
//         Product product = findByName(productName);
//         entityManager.remove(product);
// 
//     }
// 
//     @Transactional
//     public void deleteConstraintsForProduct(String productName) {
//         Product product = findByName(productName);
//         for (FeatureConstraint featureConstraint : product.getProductFeatureConstraints()) {
//             entityManager.remove(featureConstraint);
//         }
//         product.getProductFeatureConstraints().clear();
//     }
// 
//     @Transactional
//     public void insert(Product product) {
//         entityManager.persist(product);
//     }
// 
//     @Transactional
//     public void insertFeature(Feature feature) {
//         entityManager.persist(feature);
//     }
// 
//     @Transactional
//     public void deleteFeature(Feature feature) {
//         JPADeleteClause deleteClause = new JPADeleteClause(entityManager, qFeature);
//         deleteClause.where(qFeature.id.eq(feature.getId()));
//         deleteClause.execute();
//     }
// 
//     @Transactional
//     public void insertConstraint(FeatureConstraint constraint) {
//         entityManager.persist(constraint);
//     }
// 
//     @Transactional
//     public void deleteConstraintForProduct(String productName, Long constraintId) {
//         JPADeleteClause deleteClause = new JPADeleteClause(entityManager, qFeatureConstraint);
//         deleteClause.where(qFeatureConstraint.id.eq(constraintId));
//         deleteClause.execute();
//     }
// }


// Path: src/test/java/org/javiermf/features/services/rest/ProductResourceIntegrationTests.java
import org.apache.http.HttpStatus;
import org.javiermf.features.Application;
import org.javiermf.features.daos.ProductsDAO;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import static com.jayway.restassured.RestAssured.when;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.util.MatcherAssertionErrors.assertThat;

package org.javiermf.features.services.rest;




@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@Sql({"/empty-db.sql", "/data-test.sql"})
@WebIntegrationTest
public class ProductResourceIntegrationTests {

    @Autowired
    ProductsDAO productsDAO;