This commit is contained in:
Вячеслав Иванов 2024-03-29 13:46:48 +04:00
parent d59106789a
commit 9f24db1622
4 changed files with 8 additions and 13 deletions

View File

@ -39,7 +39,6 @@ public class OrderController {
private OrderDto toDto(OrderEntity entity) { private OrderDto toDto(OrderEntity entity) {
OrderDto dto = new OrderDto(productService); OrderDto dto = new OrderDto(productService);
dto.setId(entity.getId()); dto.setId(entity.getId());
dto.setUserId(entity.getUser().getId());
dto.setProductId(entity.getProduct().getId()); dto.setProductId(entity.getProduct().getId());
dto.setCount(entity.getCount()); dto.setCount(entity.getCount());
return dto; return dto;

View File

@ -38,13 +38,10 @@ public class OrderDto {
this.id = id; this.id = id;
} }
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Long getUserId() { public Long getUserId() {
return userId; return userId;
} }
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getProductId() { public Long getProductId() {
return productId; return productId;

View File

@ -37,7 +37,6 @@ public class OrderService {
public OrderEntity update(Long id, OrderEntity entity) { public OrderEntity update(Long id, OrderEntity entity) {
final OrderEntity existsEntity = get(id); final OrderEntity existsEntity = get(id);
existsEntity.setUser(entity.getUser());
existsEntity.setProduct(entity.getProduct()); existsEntity.setProduct(entity.getProduct());
existsEntity.setCount(entity.getCount()); existsEntity.setCount(entity.getCount());
return repository.update(existsEntity); return repository.update(existsEntity);

View File

@ -29,8 +29,8 @@ class TypeServiceTests {
typeService.create(new TypeEntity(null, "Пепперони")); typeService.create(new TypeEntity(null, "Пепперони"));
typeService.create(new TypeEntity(null, "Мясная")); typeService.create(new TypeEntity(null, "Мясная"));
final TypeEntity last = typeService.create(new TypeEntity(null, "Сырная")); final TypeEntity last = typeService.create(new TypeEntity(null, "Сырная"));
Assertions.assertEquals(3, typeService.getAll().size()); Assertions.assertEquals(9, typeService.getAll().size());
Assertions.assertEquals(last, typeService.get(3L)); Assertions.assertEquals(last, typeService.get(9L));
} }
@Test @Test
@ -40,7 +40,7 @@ class TypeServiceTests {
final TypeEntity entity = typeService.get(3L); final TypeEntity entity = typeService.get(3L);
final String oldName = entity.getName(); final String oldName = entity.getName();
final TypeEntity newEntity = typeService.update(3L, new TypeEntity(1L, test)); final TypeEntity newEntity = typeService.update(3L, new TypeEntity(1L, test));
Assertions.assertEquals(3, typeService.getAll().size()); Assertions.assertEquals(9, typeService.getAll().size());
Assertions.assertEquals(newEntity, typeService.get(3L)); Assertions.assertEquals(newEntity, typeService.get(3L));
Assertions.assertEquals(test, newEntity.getName()); Assertions.assertEquals(test, newEntity.getName());
Assertions.assertNotEquals(oldName, newEntity.getName()); Assertions.assertNotEquals(oldName, newEntity.getName());
@ -50,12 +50,12 @@ class TypeServiceTests {
@Order(3) @Order(3)
void deleteTest() { void deleteTest() {
typeService.delete(3L); typeService.delete(3L);
Assertions.assertEquals(2, typeService.getAll().size()); Assertions.assertEquals(8, typeService.getAll().size());
final TypeEntity last = typeService.get(2L); final TypeEntity last = typeService.get(2L);
Assertions.assertEquals(2L, last.getId()); Assertions.assertEquals(2L, last.getId());
final TypeEntity newEntity = typeService.create(new TypeEntity(null, "Сырная")); final TypeEntity newEntity = typeService.create(new TypeEntity(null, "Сырная"));
Assertions.assertEquals(3, typeService.getAll().size()); Assertions.assertEquals(9, typeService.getAll().size());
Assertions.assertEquals(4L, newEntity.getId()); Assertions.assertEquals(10L, newEntity.getId());
} }
} }