Skip to content
Snippets Groups Projects
Commit 88db95b0 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6523 fix revoking of create_attached_item command

parent 30e33f70
No related branches found
No related tags found
No related merge requests found
...@@ -160,7 +160,7 @@ public class VorgangAttachedItemService { ...@@ -160,7 +160,7 @@ public class VorgangAttachedItemService {
} }
public void revokeCreate(Command command) { public void revokeCreate(Command command) {
handleRevoke(command, () -> delete(command.getRelationId(), command.getRelationVersion())); handleRevoke(command, () -> delete(command.getCreatedResource(), command.getRelationVersion() + 1));
} }
void delete(String id, long version) { void delete(String id, long version) {
......
...@@ -289,7 +289,8 @@ class VorgangAttachedItemITCase { ...@@ -289,7 +289,8 @@ class VorgangAttachedItemITCase {
private Command createRevokeCommand() { private Command createRevokeCommand() {
return CommandTestFactory.createBuilder().order(Order.CREATE_ATTACHED_ITEM.name()) return CommandTestFactory.createBuilder().order(Order.CREATE_ATTACHED_ITEM.name())
.relationId(persistedItem.getId()) .relationId(persistedItem.getId())
.relationVersion(persistedItem.getVersion()) .relationVersion(persistedItem.getVersion() - 1)
.createdResource(persistedItem.getId())
.bodyObject(VorgangAttachedItemTestFactory.asMap()).build(); .bodyObject(VorgangAttachedItemTestFactory.asMap()).build();
} }
} }
...@@ -298,11 +299,11 @@ class VorgangAttachedItemITCase { ...@@ -298,11 +299,11 @@ class VorgangAttachedItemITCase {
@Nested @Nested
class TestRevokeUpdateItem { class TestRevokeUpdateItem {
private final Map<String, Object> createItem = Map.<String, Object>of("EntryToRecoverByRevokeKey", "EntryToRecoverByRevokeValue", private final Map<String, Object> createItem = Map.of("EntryToRecoverByRevokeKey", "EntryToRecoverByRevokeValue",
VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, VorgangAttachedItemTestFactory.ITEM_FIELD_STRING_VALUE); VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, VorgangAttachedItemTestFactory.ITEM_FIELD_STRING_VALUE);
private VorgangAttachedItem persistedItem; private VorgangAttachedItem persistedItem;
private final Map<String, Object> updateItem = Map.<String, Object>of( private final Map<String, Object> updateItem = Map.of(
VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, "RevertByRevokeValue", VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, "RevertByRevokeValue",
"NewToRemoveByRevokeKey", "NewToRemoveByRevokeValue"); "NewToRemoveByRevokeKey", "NewToRemoveByRevokeValue");
private Command updatedCommand; private Command updatedCommand;
...@@ -391,11 +392,11 @@ class VorgangAttachedItemITCase { ...@@ -391,11 +392,11 @@ class VorgangAttachedItemITCase {
@Nested @Nested
class TestRevokePatchItem { class TestRevokePatchItem {
private final Map<String, Object> createItem = Map.<String, Object>of(VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, private final Map<String, Object> createItem = Map.of(VorgangAttachedItemTestFactory.ITEM_FIELD_NAME,
VorgangAttachedItemTestFactory.ITEM_FIELD_STRING_VALUE); VorgangAttachedItemTestFactory.ITEM_FIELD_STRING_VALUE);
private VorgangAttachedItem persistedItem; private VorgangAttachedItem persistedItem;
private final Map<String, Object> patchItem = Map.<String, Object>of(VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, "UpdatedStringValue"); private final Map<String, Object> patchItem = Map.of(VorgangAttachedItemTestFactory.ITEM_FIELD_NAME, "UpdatedStringValue");
private Command patchedCommand; private Command patchedCommand;
private String vorgangId; private String vorgangId;
......
...@@ -361,7 +361,7 @@ class VorgangAttachedItemServiceTest { ...@@ -361,7 +361,7 @@ class VorgangAttachedItemServiceTest {
@Nested @Nested
class TestRevokeCreate { class TestRevokeCreate {
private final Command command = CommandTestFactory.create(); private final Command command = CommandTestFactory.createBuilder().createdResource(CommandTestFactory.CREATED_RESOURCE).build();
@Test @Test
void shouldCallHandleRevoke() { void shouldCallHandleRevoke() {
...@@ -374,7 +374,7 @@ class VorgangAttachedItemServiceTest { ...@@ -374,7 +374,7 @@ class VorgangAttachedItemServiceTest {
void shouldCallDelete() { void shouldCallDelete() {
service.revokeCreate(command); service.revokeCreate(command);
verify(service).delete(CommandTestFactory.RELATION_ID, CommandTestFactory.RELATION_VERSION); verify(service).delete(CommandTestFactory.CREATED_RESOURCE, CommandTestFactory.RELATION_VERSION + 1);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment