This commit is contained in:
Вячеслав Иванов 2024-03-27 20:12:54 +04:00
parent bd0a3ef8cf
commit 751b9a16ab

View File

@ -62,23 +62,32 @@ public class OrderServiceTests {
final TypeEntity two = typeService.create(new TypeEntity(null, "test"));
final ProductEntity test = productService.create(new ProductEntity(null, "test", two ,100.00));
Assertions.assertEquals(6, orderService.getAll().size());
Assertions.assertEquals(newEntity, orderService.get(3L));
Assertions.assertEquals(test, newEntity.getName());
Assertions.assertNotEquals(oldName, newEntity.getName());
final OrderEntity order = orderService.get(3L);
final Integer oldPrice = order.getCount();
final OrderEntity newOrder = orderService.update(3L, new OrderEntity(3L, one, test, 10));
Assertions.assertEquals(3, orderService.getAll(0L).size());
Assertions.assertEquals(newOrder, orderService.get(3L));
Assertions.assertEquals(10, newOrder.getCount());
Assertions.assertNotEquals(oldPrice, newOrder.getCount());
}
@Test
@Order(3)
void deleteTest() {
orderService.delete(3L);
Assertions.assertEquals(5, orderService.getAll().size());
final TypeEntity last = orderService.get(2L);
Assertions.assertEquals(2L, last.getId());
final TypeEntity newEntity = orderService.create(new TypeEntity(null, "Сырная"));
Assertions.assertEquals(6, orderService.getAll().size());
Assertions.assertEquals(7L, newEntity.getId());
Assertions.assertEquals(2, orderService.getAll(0L).size());
Assertions.assertThrows(NotFoundException.class, () -> orderService.get(3L));
final UserEntity one = userService.get(2L);
final TypeEntity two = typeService.create(new TypeEntity(null, "test"));
final ProductEntity test = productService.create(new ProductEntity(null, "test", two ,100.00));
final OrderEntity newOrder = orderService.create(new OrderEntity(null, one, test, 15));
Assertions.assertEquals(6, orderService.getAll(0L).size());
Assertions.assertEquals(7L, newOrder.getId());
}
}