Skip to content
Snippets Groups Projects
Commit 97cfe1bd authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2737 filter for systemuser

parent 400ed7e5
Branches
Tags
No related merge requests found
......@@ -24,6 +24,8 @@ import lombok.extern.log4j.Log4j2;
public class M012_MigrationUserId {// NOSONAR
private static final String KOP_USERMANAGER_URL_KEY = "kop.usermanager.url";
private static final String SYSTEM_USER_PREFIX = "system";
static final String COLLECTION_VORGANG_NAME = "vorgang";
static final String ASSIGNED_TO_FIELD = "assignedTo";
......@@ -137,6 +139,10 @@ public class M012_MigrationUserId {// NOSONAR
}
private Optional<String> getNewInternalId(String currentId) {
if (currentId.startsWith(SYSTEM_USER_PREFIX)) {
return Optional.empty();
}
try {
return Optional.of(getInternalId(currentId));
} catch (HttpClientErrorException e) {
......
......@@ -54,7 +54,7 @@ kop:
notification:
mail-from: ea@ozg-sh.de
usermanager:
url: http://localhost:8080/api/migrate/user
url: http://localhost:9092/migration/user
aktenzeichen: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA
......
......@@ -289,6 +289,7 @@ class M012_MigrationUserIdITCase {
@Nested
class TestAttachedItemCreatedBy {
private static final String SYSTEM_NOTIFICATION_MANAGER_NEW_VORGANG = "system-notification_manager-new_vorgang";
private final static String CREATED_BY = UUID.randomUUID().toString();
private final static String NEW_CREATED_BY = new ObjectId().toHexString();
......@@ -298,7 +299,7 @@ class M012_MigrationUserIdITCase {
void init() {
dbUtils.dropVorgangAttachedItemCollection();
vorganAttachedItem = dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy());
vorganAttachedItem = dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy(CREATED_BY));
}
@Test
......@@ -311,6 +312,17 @@ class M012_MigrationUserIdITCase {
.containsEntry(M012_MigrationUserId.CREATED_BY_FIELD, NEW_CREATED_BY);
}
@Test
void shouldNotMigrateOnSystemUser() {
dbUtils.dropVorgangAttachedItemCollection();
vorganAttachedItem = dbUtils
.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy(SYSTEM_NOTIFICATION_MANAGER_NEW_VORGANG));
migrateVorgangAttachedItemCreatedBy();
verify(migration, never()).getInternalId(any());
}
@DisplayName("on exception")
@Nested
class TestOnException {
......@@ -362,7 +374,7 @@ class M012_MigrationUserIdITCase {
@Test
void shouldFindWithOldCreatedByData() {
dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy());
dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy(CREATED_BY));
var vorgangAttachedItems = findVorgangAttachedItem();
......@@ -387,9 +399,9 @@ class M012_MigrationUserIdITCase {
}
}
private static Document createVorgangAttachedItemWithCreatedBy() {
private static Document createVorgangAttachedItemWithCreatedBy(String createdById) {
return new Document(M012_MigrationUserId.VORGANG_ATTACHED_ITEM_ITEM_FIELD,
new Document(M012_MigrationUserId.CREATED_BY_FIELD, CREATED_BY));
new Document(M012_MigrationUserId.CREATED_BY_FIELD, createdById));
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment