Search in sources :

Example 1 with SearchProductRequest

use of com.salesmanager.shop.model.catalog.SearchProductRequest in project shopizer by shopizer-ecommerce.

the class SearchApiIntegrationTest method searchItem.

/**
 * Add a product then search for it
 * This tests is disabled since it requires Elastic search server started
 *
 * @throws Exception
 */
@Test
public void searchItem() throws Exception {
    PersistableProduct product = super.product("TESTPRODUCT");
    final HttpEntity<PersistableProduct> entity = new HttpEntity<>(product, getHeader());
    final ResponseEntity<PersistableProduct> response = testRestTemplate.postForEntity("/api/v1/private/product?store=" + Constants.DEFAULT_STORE, entity, PersistableProduct.class);
    assertThat(response.getStatusCode(), is(CREATED));
    SearchProductRequest searchRequest = new SearchProductRequest();
    searchRequest.setQuery("TEST");
    final HttpEntity<SearchProductRequest> searchEntity = new HttpEntity<>(searchRequest, getHeader());
    final ResponseEntity<SearchProductList> searchResponse = testRestTemplate.postForEntity("/api/v1/search?store=" + Constants.DEFAULT_STORE, searchEntity, SearchProductList.class);
    assertThat(searchResponse.getStatusCode(), is(CREATED));
}
Also used : HttpEntity(org.springframework.http.HttpEntity) PersistableProduct(com.salesmanager.shop.model.catalog.product.PersistableProduct) SearchProductRequest(com.salesmanager.shop.model.catalog.SearchProductRequest) SearchProductList(com.salesmanager.shop.model.catalog.SearchProductList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SearchProductList (com.salesmanager.shop.model.catalog.SearchProductList)1 SearchProductRequest (com.salesmanager.shop.model.catalog.SearchProductRequest)1 PersistableProduct (com.salesmanager.shop.model.catalog.product.PersistableProduct)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 HttpEntity (org.springframework.http.HttpEntity)1