Skip to content
Snippets Groups Projects
Commit 74a59c7c authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5987 [test] do some refactoring

parent 6688712d
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ import de.ozgcloud.command.CommandStatus; ...@@ -57,7 +57,7 @@ import de.ozgcloud.command.CommandStatus;
class CommandRepository { class CommandRepository {
private static final String MONGODB_ID = "id"; private static final String MONGODB_ID = "id";
private static final String MONGODB_STATUS = "status"; static final String MONGODB_STATUS = "status";
private static final String MONGODB_REFERENCE_STATUS = "$status"; private static final String MONGODB_REFERENCE_STATUS = "$status";
private static final String MONGODB_FINISHED_AT = "finishedAt"; private static final String MONGODB_FINISHED_AT = "finishedAt";
private static final String MONGODB_RELATION_VERSION = "relationVersion"; private static final String MONGODB_RELATION_VERSION = "relationVersion";
......
...@@ -142,7 +142,7 @@ class CommandServiceITCase { ...@@ -142,7 +142,7 @@ class CommandServiceITCase {
@Test @Test
void shouldRevokeFinishedCommand() { void shouldRevokeFinishedCommand() {
var commandId = saveSubCommandWithParent(); var commandId = saveSubCommandWithFailedParent();
commandService.setCommandFinished(commandId); commandService.setCommandFinished(commandId);
...@@ -152,17 +152,24 @@ class CommandServiceITCase { ...@@ -152,17 +152,24 @@ class CommandServiceITCase {
}); });
} }
private String saveSubCommandWithParent() { private String saveSubCommandWithFailedParent() {
var parentId = mongoOperations.save(CommandTestFactory.createBuilder().id(null).status(CommandStatus.ERROR) var parentId = mongoOperations.save(createFailedParentCommand()).getId();
return mongoOperations.save(createSubCommand(parentId)).getId();
}
private Command createFailedParentCommand() {
return CommandTestFactory.createBuilder().id(null).status(CommandStatus.ERROR)
.bodyObject(Map.of( .bodyObject(Map.of(
PersistedCommand.PROPERTY_EXECUTION_MODE, SubCommandExecutionMode.PARALLEL.name(), PersistedCommand.PROPERTY_EXECUTION_MODE, SubCommandExecutionMode.PARALLEL.name(),
PersistedCommand.PROPERTY_COMPLETE_IF_SUBS_COMPLETED, true PersistedCommand.PROPERTY_COMPLETE_IF_SUBS_COMPLETED, true
)).build()).getId(); )).build();
return mongoOperations.save(CommandTestFactory.createBuilder().id(null).vorgangId(vorgang.getId())
.previousState(Map.of("status", Vorgang.Status.NEU.name()))
.bodyObject(Map.of(PersistedCommand.PROPERTY_PARENT_ID, parentId)).build()).getId();
} }
private Command createSubCommand(String parentId) {
return CommandTestFactory.createBuilder().id(null).vorgangId(vorgang.getId())
.previousState(Map.of(CommandRepository.MONGODB_STATUS, Vorgang.Status.NEU.name()))
.bodyObject(Map.of(PersistedCommand.PROPERTY_PARENT_ID, parentId)).build();
}
} }
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment