Skip to content
Snippets Groups Projects
Commit 73dca533 authored by OZGCloud's avatar OZGCloud
Browse files

Merge remote-tracking branch 'origin/master' into OZG-3065_HandleException

parents 43d08082 cb5062ae
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,8 @@ import lombok.extern.log4j.Log4j2; ...@@ -24,6 +24,8 @@ import lombok.extern.log4j.Log4j2;
public class M012_MigrationUserId {// NOSONAR public class M012_MigrationUserId {// NOSONAR
private static final String KOP_USERMANAGER_URL_KEY = "kop.usermanager.url"; 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 COLLECTION_VORGANG_NAME = "vorgang";
static final String ASSIGNED_TO_FIELD = "assignedTo"; static final String ASSIGNED_TO_FIELD = "assignedTo";
...@@ -137,6 +139,10 @@ public class M012_MigrationUserId {// NOSONAR ...@@ -137,6 +139,10 @@ public class M012_MigrationUserId {// NOSONAR
} }
private Optional<String> getNewInternalId(String currentId) { private Optional<String> getNewInternalId(String currentId) {
if (currentId.startsWith(SYSTEM_USER_PREFIX)) {
return Optional.empty();
}
try { try {
return Optional.of(getInternalId(currentId)); return Optional.of(getInternalId(currentId));
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
......
...@@ -54,7 +54,7 @@ kop: ...@@ -54,7 +54,7 @@ kop:
notification: notification:
mail-from: ea@ozg-sh.de mail-from: ea@ozg-sh.de
usermanager: usermanager:
url: http://localhost:8080/api/migrate/user url: http://localhost:9092/migration/user
aktenzeichen: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA aktenzeichen: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA
......
...@@ -289,6 +289,7 @@ class M012_MigrationUserIdITCase { ...@@ -289,6 +289,7 @@ class M012_MigrationUserIdITCase {
@Nested @Nested
class TestAttachedItemCreatedBy { 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 CREATED_BY = UUID.randomUUID().toString();
private final static String NEW_CREATED_BY = new ObjectId().toHexString(); private final static String NEW_CREATED_BY = new ObjectId().toHexString();
...@@ -298,7 +299,7 @@ class M012_MigrationUserIdITCase { ...@@ -298,7 +299,7 @@ class M012_MigrationUserIdITCase {
void init() { void init() {
dbUtils.dropVorgangAttachedItemCollection(); dbUtils.dropVorgangAttachedItemCollection();
vorganAttachedItem = dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy()); vorganAttachedItem = dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy(CREATED_BY));
} }
@Test @Test
...@@ -311,6 +312,17 @@ class M012_MigrationUserIdITCase { ...@@ -311,6 +312,17 @@ class M012_MigrationUserIdITCase {
.containsEntry(M012_MigrationUserId.CREATED_BY_FIELD, NEW_CREATED_BY); .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") @DisplayName("on exception")
@Nested @Nested
class TestOnException { class TestOnException {
...@@ -362,7 +374,7 @@ class M012_MigrationUserIdITCase { ...@@ -362,7 +374,7 @@ class M012_MigrationUserIdITCase {
@Test @Test
void shouldFindWithOldCreatedByData() { void shouldFindWithOldCreatedByData() {
dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy()); dbUtils.saveVorgangAttachedItem(createVorgangAttachedItemWithCreatedBy(CREATED_BY));
var vorgangAttachedItems = findVorgangAttachedItem(); var vorgangAttachedItems = findVorgangAttachedItem();
...@@ -387,9 +399,9 @@ class M012_MigrationUserIdITCase { ...@@ -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, 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