From e11781e6c18eca9d680ebbb7a08f7840b8b4214e Mon Sep 17 00:00:00 2001 From: Factorino73 Date: Wed, 20 Mar 2024 20:44:52 +0400 Subject: [PATCH] LabWork02 Fixes --- .../java/com/example/demo/items/service/ItemService.java | 5 +++++ .../com/example/demo/messages/service/MessageService.java | 5 +++++ .../java/com/example/demo/types/service/TypeService.java | 5 +++++ .../java/com/example/demo/users/service/UserService.java | 5 +++++ demo/src/test/java/com/example/demo/ItemServiceTests.java | 3 +++ demo/src/test/java/com/example/demo/MessageServiceTests.java | 3 +++ demo/src/test/java/com/example/demo/TypeServiceTests.java | 2 ++ demo/src/test/java/com/example/demo/UserServiceTests.java | 2 ++ 8 files changed, 30 insertions(+) diff --git a/demo/src/main/java/com/example/demo/items/service/ItemService.java b/demo/src/main/java/com/example/demo/items/service/ItemService.java index dbd12be..9c19f7d 100644 --- a/demo/src/main/java/com/example/demo/items/service/ItemService.java +++ b/demo/src/main/java/com/example/demo/items/service/ItemService.java @@ -56,4 +56,9 @@ public class ItemService { final ItemEntity existsEntity = get(id); return repository.delete(existsEntity); } + + // Удалить все элементы + public void deleteAll() { + repository.deleteAll(); + } } diff --git a/demo/src/main/java/com/example/demo/messages/service/MessageService.java b/demo/src/main/java/com/example/demo/messages/service/MessageService.java index cb63e9d..0c59e5c 100644 --- a/demo/src/main/java/com/example/demo/messages/service/MessageService.java +++ b/demo/src/main/java/com/example/demo/messages/service/MessageService.java @@ -55,4 +55,9 @@ public class MessageService { final MessageEntity existsEntity = get(id); return repository.delete(existsEntity); } + + // Удалить все элементы + public void deleteAll() { + repository.deleteAll(); + } } diff --git a/demo/src/main/java/com/example/demo/types/service/TypeService.java b/demo/src/main/java/com/example/demo/types/service/TypeService.java index a4b7b55..07e6ebd 100644 --- a/demo/src/main/java/com/example/demo/types/service/TypeService.java +++ b/demo/src/main/java/com/example/demo/types/service/TypeService.java @@ -48,4 +48,9 @@ public class TypeService { final TypeEntity existsEntity = get(id); return repository.delete(existsEntity); } + + // Удалить все элементы + public void deleteAll() { + repository.deleteAll(); + } } diff --git a/demo/src/main/java/com/example/demo/users/service/UserService.java b/demo/src/main/java/com/example/demo/users/service/UserService.java index d619c85..79e03af 100644 --- a/demo/src/main/java/com/example/demo/users/service/UserService.java +++ b/demo/src/main/java/com/example/demo/users/service/UserService.java @@ -50,4 +50,9 @@ public class UserService { final UserEntity existsEntity = get(id); return repository.delete(existsEntity); } + + // Удалить все элементы + public void deleteAll() { + repository.deleteAll(); + } } diff --git a/demo/src/test/java/com/example/demo/ItemServiceTests.java b/demo/src/test/java/com/example/demo/ItemServiceTests.java index bbcf68d..78559c1 100644 --- a/demo/src/test/java/com/example/demo/ItemServiceTests.java +++ b/demo/src/test/java/com/example/demo/ItemServiceTests.java @@ -65,5 +65,8 @@ public class ItemServiceTests { final ItemEntity newEntity = itemService.create(new ItemEntity(null, type, 50.00, 10)); Assertions.assertEquals(3, itemService.getAll(0L).size()); Assertions.assertEquals(4L, newEntity.getId()); + + typeService.deleteAll(); + itemService.deleteAll(); } } diff --git a/demo/src/test/java/com/example/demo/MessageServiceTests.java b/demo/src/test/java/com/example/demo/MessageServiceTests.java index 32dbe3b..eb2c6f7 100644 --- a/demo/src/test/java/com/example/demo/MessageServiceTests.java +++ b/demo/src/test/java/com/example/demo/MessageServiceTests.java @@ -67,5 +67,8 @@ public class MessageServiceTests { final MessageEntity newEntity = messageService.create(new MessageEntity(null, sender, "Message", LocalDateTime.now(), false)); Assertions.assertEquals(3, messageService.getAll(0L).size()); Assertions.assertEquals(4L, newEntity.getId()); + + userService.deleteAll(); + messageService.deleteAll(); } } diff --git a/demo/src/test/java/com/example/demo/TypeServiceTests.java b/demo/src/test/java/com/example/demo/TypeServiceTests.java index 611b67a..7d22458 100644 --- a/demo/src/test/java/com/example/demo/TypeServiceTests.java +++ b/demo/src/test/java/com/example/demo/TypeServiceTests.java @@ -59,5 +59,7 @@ class TypeServiceTests { final TypeEntity newEntity = typeService.create(new TypeEntity(null, "Infinity")); Assertions.assertEquals(3, typeService.getAll().size()); Assertions.assertEquals(4L, newEntity.getId()); + + typeService.deleteAll(); } } diff --git a/demo/src/test/java/com/example/demo/UserServiceTests.java b/demo/src/test/java/com/example/demo/UserServiceTests.java index b2d7cd9..1ddc9da 100644 --- a/demo/src/test/java/com/example/demo/UserServiceTests.java +++ b/demo/src/test/java/com/example/demo/UserServiceTests.java @@ -61,5 +61,7 @@ public class UserServiceTests { final UserEntity newEntity = userService.create(new UserEntity(null, "User4", "password4", "mail4@gmail.com")); Assertions.assertEquals(3, userService.getAll().size()); Assertions.assertEquals(4L, newEntity.getId()); + + userService.deleteAll(); } }