commit
e2c76098ab
|
@ -53,17 +53,55 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>integration</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<test.mime>json</test.mime>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -14,12 +14,6 @@ public class Product {
|
|||
@Indexed(name = "name", type = "string")
|
||||
private String name;
|
||||
|
||||
@Indexed(name = "category", type = "string")
|
||||
private String category;
|
||||
|
||||
@Indexed(name = "description", type = "string")
|
||||
private String description;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -36,20 +30,4 @@ public class Product {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public interface ProductRepository extends SolrCrudRepository<Product, String> {
|
|||
|
||||
public List<Product> findByName(String name);
|
||||
|
||||
@Query("name:*?0* OR category:*?0* OR description:*?0*")
|
||||
@Query("id:*?0* OR name:*?0*")
|
||||
public Page<Product> findByCustomQuery(String searchTerm, Pageable pageable);
|
||||
|
||||
@Query(name = "Product.findByNamedQuery")
|
||||
|
|
|
@ -1 +1 @@
|
|||
Product.findByNamedQuery=name:*?0* OR category:*?0* OR description:*?0*
|
||||
Product.findByNamedQuery=id:*?0* OR name:*?0*
|
|
@ -35,8 +35,6 @@ public class ProductRepositoryIntegrationTest {
|
|||
final Product product = new Product();
|
||||
product.setId("P000089998");
|
||||
product.setName("Desk");
|
||||
product.setCategory("Furniture");
|
||||
product.setDescription("New Desk");
|
||||
productRepository.save(product);
|
||||
final Product retrievedProduct = productRepository.findOne(product.getId());
|
||||
assertEquals(product.getId(), retrievedProduct.getId());
|
||||
|
@ -47,15 +45,14 @@ public class ProductRepositoryIntegrationTest {
|
|||
final Product product = new Product();
|
||||
product.setId("P0001");
|
||||
product.setName("T-Shirt");
|
||||
product.setCategory("Kitchen");
|
||||
product.setDescription("New T-Shirt");
|
||||
|
||||
productRepository.save(product);
|
||||
|
||||
product.setCategory("Clothes");
|
||||
product.setName("Shirt");
|
||||
productRepository.save(product);
|
||||
|
||||
final Product retrievedProduct = productRepository.findOne(product.getId());
|
||||
assertEquals(product.getCategory(), retrievedProduct.getCategory());
|
||||
assertEquals(product.getName(), retrievedProduct.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -63,8 +60,6 @@ public class ProductRepositoryIntegrationTest {
|
|||
final Product product = new Product();
|
||||
product.setId("P0001");
|
||||
product.setName("Desk");
|
||||
product.setCategory("Furniture");
|
||||
product.setDescription("New Desk");
|
||||
productRepository.save(product);
|
||||
|
||||
productRepository.delete(product);
|
||||
|
@ -79,8 +74,6 @@ public class ProductRepositoryIntegrationTest {
|
|||
Product phone = new Product();
|
||||
phone.setId("P0001");
|
||||
phone.setName("Phone");
|
||||
phone.setCategory("Electronics");
|
||||
phone.setDescription("New Phone");
|
||||
productRepository.save(phone);
|
||||
|
||||
List<Product> retrievedProducts = productRepository.findByName("Phone");
|
||||
|
@ -92,22 +85,16 @@ public class ProductRepositoryIntegrationTest {
|
|||
final Product phone = new Product();
|
||||
phone.setId("P0001");
|
||||
phone.setName("Smart Phone");
|
||||
phone.setCategory("Electronics");
|
||||
phone.setDescription("New Item");
|
||||
productRepository.save(phone);
|
||||
|
||||
final Product phoneCover = new Product();
|
||||
phoneCover.setId("P0002");
|
||||
phoneCover.setName("Cover");
|
||||
phoneCover.setCategory("Phone");
|
||||
phoneCover.setDescription("New Product");
|
||||
phoneCover.setName("Phone Cover");
|
||||
productRepository.save(phoneCover);
|
||||
|
||||
final Product wirelessCharger = new Product();
|
||||
wirelessCharger.setId("P0003");
|
||||
wirelessCharger.setName("Charging Cable");
|
||||
wirelessCharger.setCategory("Cable");
|
||||
wirelessCharger.setDescription("Wireless Charger for Phone");
|
||||
wirelessCharger.setName("Phone Charging Cable");
|
||||
productRepository.save(wirelessCharger);
|
||||
|
||||
Page<Product> result = productRepository.findByCustomQuery("Phone", new PageRequest(0, 10));
|
||||
|
@ -119,22 +106,16 @@ public class ProductRepositoryIntegrationTest {
|
|||
final Product phone = new Product();
|
||||
phone.setId("P0001");
|
||||
phone.setName("Smart Phone");
|
||||
phone.setCategory("Electronics");
|
||||
phone.setDescription("New Item");
|
||||
productRepository.save(phone);
|
||||
|
||||
final Product phoneCover = new Product();
|
||||
phoneCover.setId("P0002");
|
||||
phoneCover.setName("Cover");
|
||||
phoneCover.setCategory("Phone");
|
||||
phoneCover.setDescription("New Product");
|
||||
phoneCover.setName("Phone Cover");
|
||||
productRepository.save(phoneCover);
|
||||
|
||||
final Product wirelessCharger = new Product();
|
||||
wirelessCharger.setId("P0003");
|
||||
wirelessCharger.setName("Charging Cable");
|
||||
wirelessCharger.setCategory("Cable");
|
||||
wirelessCharger.setDescription("Wireless Charger for Phone");
|
||||
wirelessCharger.setName("Phone Charging Cable");
|
||||
productRepository.save(wirelessCharger);
|
||||
|
||||
Page<Product> result = productRepository.findByNamedQuery("one", new PageRequest(0, 10));
|
||||
|
|
Loading…
Reference in New Issue