|
8 | 8 | import org.lfenergy.compas.scl.data.model.Version; |
9 | 9 | import org.lfenergy.compas.scl.extensions.model.SclFileType; |
10 | 10 |
|
| 11 | +import java.util.List; |
11 | 12 | import java.util.UUID; |
12 | 13 |
|
13 | 14 | import static org.junit.jupiter.api.Assertions.*; |
@@ -59,16 +60,35 @@ void findMetaInfoByUUID_WhenCalledWithUnknownUUID_ThenExceptionIsThrown() { |
59 | 60 | } |
60 | 61 |
|
61 | 62 | @Test |
62 | | - void deleteVersion_WhenCalledWithExistingUUID_ThenSpecificVersionIsDeleted() { |
63 | | - var uuid = UUID.randomUUID(); |
| 63 | + void delete_AllVersions_SoftDeleted() { |
| 64 | + UUID uuid = UUID.randomUUID(); |
| 65 | + Version version1 = new Version(1, 0, 0); |
| 66 | + Version version2 = new Version(2, 0, 0); |
| 67 | + |
| 68 | + var repository = getRepository(); |
| 69 | + repository.create(TYPE, uuid, "TestName", "<SCL></SCL>", version1, "tester", List.of("label")); |
| 70 | + repository.create(TYPE, uuid, "TestName", "<SCL></SCL>", version2, "tester", List.of("label")); |
| 71 | + |
| 72 | + repository.delete(TYPE, uuid); |
64 | 73 |
|
65 | | - getRepository().delete(TYPE, uuid); |
| 74 | + var items = repository.listVersionsByUUID(TYPE, uuid); |
| 75 | + assertEquals(0, items.size(), "All versions should be soft deleted"); |
66 | 76 | } |
67 | 77 |
|
68 | 78 | @Test |
69 | | - void deleteVersion_WhenCalledWithExistingUUIDAndVersion_ThenSpecificVersionIsDeleted() { |
70 | | - var uuid = UUID.randomUUID(); |
| 79 | + void delete_SpecificVersion_Deleted() { |
| 80 | + UUID uuid = UUID.randomUUID(); |
| 81 | + Version version1 = new Version(1, 0, 0); |
| 82 | + Version version2 = new Version(2, 0, 0); |
| 83 | + |
| 84 | + var repository = getRepository(); |
| 85 | + repository.create(TYPE, uuid, "TestName", "<SCL></SCL>", version1, "tester", List.of("label")); |
| 86 | + repository.create(TYPE, uuid, "TestName", "<SCL></SCL>", version2, "tester", List.of("label")); |
| 87 | + |
| 88 | + repository.delete(TYPE, uuid, version1); |
71 | 89 |
|
72 | | - getRepository().delete(TYPE, uuid, new Version(1, 3, 2)); |
| 90 | + var items = repository.listVersionsByUUID(TYPE, uuid); |
| 91 | + assertEquals(1, items.size(), "Only one version should remain"); |
| 92 | + assertEquals(version2.toString(), items.get(0).getVersion(), "Remaining version should be version2"); |
73 | 93 | } |
74 | 94 | } |
0 commit comments