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 TypeEntity two = typeService.create(new TypeEntity(null, "test"));
final ProductEntity test = productService.create(new ProductEntity(null, "test", two ,100.00)); final ProductEntity test = productService.create(new ProductEntity(null, "test", two ,100.00));
final OrderEntity order = orderService.get(3L);
final Integer oldPrice = order.getCount();
Assertions.assertEquals(6, orderService.getAll().size()); final OrderEntity newOrder = orderService.update(3L, new OrderEntity(3L, one, test, 10));
Assertions.assertEquals(newEntity, orderService.get(3L));
Assertions.assertEquals(test, newEntity.getName()); Assertions.assertEquals(3, orderService.getAll(0L).size());
Assertions.assertNotEquals(oldName, newEntity.getName()); Assertions.assertEquals(newOrder, orderService.get(3L));
Assertions.assertEquals(10, newOrder.getCount());
Assertions.assertNotEquals(oldPrice, newOrder.getCount());
} }
@Test @Test
@Order(3) @Order(3)
void deleteTest() { void deleteTest() {
orderService.delete(3L); 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(2, orderService.getAll(0L).size());
Assertions.assertEquals(6, orderService.getAll().size()); Assertions.assertThrows(NotFoundException.class, () -> orderService.get(3L));
Assertions.assertEquals(7L, newEntity.getId());
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());
} }
} }