use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.
the class ProductServicesTests method findByIdShouldReturnProductDTOWhenIdExists.
@Test
public void findByIdShouldReturnProductDTOWhenIdExists() {
ProductDTO result = service.findById(existingId);
Assertions.assertNotNull(result);
}
use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.
the class ProductControllerIT method updateShouldReturnNotFoundWhenIdDoesNotExist.
@Test
public void updateShouldReturnNotFoundWhenIdDoesNotExist() throws Exception {
String accessToken = tokenUtil.obtainAccessToken(mockMvc, username, password);
ProductDTO productDTO = Factory.createProductDTO();
String jsonBody = objectMapper.writeValueAsString(productDTO);
ResultActions result = mockMvc.perform(put("/products/{id}", nonExistingId).header("Authorization", "Bearer " + accessToken).content(jsonBody).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON));
result.andExpect(status().isNotFound());
}
use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.
the class ProductServiceIT method findAllPagedShouldReturnPageWhenPage0Size10.
@Test
public void findAllPagedShouldReturnPageWhenPage0Size10() {
PageRequest pageRequest = PageRequest.of(0, 10);
Page<ProductDTO> result = service.findAllPaged(0L, "", pageRequest);
Assertions.assertFalse(result.isEmpty());
Assertions.assertEquals(0, result.getNumber());
Assertions.assertEquals(10, result.getSize());
Assertions.assertEquals(countTotalProducts, result.getTotalElements());
}
use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.
the class ProductServiceIT method findAllPagedShouldReturnSortedPageWhenSortByName.
@Test
public void findAllPagedShouldReturnSortedPageWhenSortByName() {
PageRequest pageRequest = PageRequest.of(0, 10, Sort.by("name"));
Page<ProductDTO> result = service.findAllPaged(0L, "", pageRequest);
Assertions.assertFalse(result.isEmpty());
Assertions.assertEquals("Macbook Pro", result.getContent().get(0).getName());
Assertions.assertEquals("PC Gamer", result.getContent().get(1).getName());
Assertions.assertEquals("PC Gamer Alfa", result.getContent().get(2).getName());
}
use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.
the class ProductServicesTests method findAllPagedShouldReturnPage.
@Test
public void findAllPagedShouldReturnPage() {
Pageable pageable = PageRequest.of(0, 12);
Page<ProductDTO> result = service.findAllPaged(0L, "", pageable);
Assertions.assertNotNull(result);
// Mockito.verify(repositories, times(1)).find(pageable);
}
Aggregations