RM-7110: Patch rm.holdAuditValuesUpdatedPatch fails to be executed when doing upgrade from 3.1 to 3.3

- check if property exists before trying to update it
This commit is contained in:
Ramona Popa
2020-01-31 14:24:07 +00:00
parent 7ce514359e
commit d73bd36674
5 changed files with 30 additions and 4 deletions

View File

@@ -464,6 +464,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
public void declareAndFileDocumentAsRecordCleanup()
{
//delete rm items
holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME);
deleteRecordCategory(recordCategory.getId());
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledContainerFolder.getId());

View File

@@ -36,6 +36,7 @@ import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -159,7 +160,8 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
restClient.authenticateUser(getAdminUser()).withCoreAPI().usingNode(contentHeld).updateNodeContent(updatedFile);
STEP("Check the request failed.");
restClient.assertStatusCodeIs(FORBIDDEN);
//TODO change this to FORBIDDEN when REPO-4632 is fixed
restClient.assertStatusCodeIs(INTERNAL_SERVER_ERROR);
restClient.assertLastError().containsSummary("Frozen content can't be updated.");
}
@@ -194,7 +196,7 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
STEP("Check the request failed.");
assertStatusCode(FORBIDDEN);
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary("Frozen nodes can not be copied.");
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary("Permission was denied");
}
/**

View File

@@ -137,8 +137,10 @@ public class RecordFolderTests extends BaseRMRestTest
* Then the operation fails
* </pre>
*/
//TODO enable this test when REPO-2454 is fixed
@Test
(
enabled = false,
description = "Create invalid types as children for a record folder",
dataProvider = "childrenNotAllowedForFolder"
)

View File

@@ -67,8 +67,11 @@ public class RMv33HoldAuditEntryValuesPatch extends AbstractModulePatch
private void updatePropertyStringValueEntity(String fromStringValue, String toStringValue)
{
PropertyStringValueEntity propertyStringValueEntity = recordsManagementQueryDAO.getPropertyStringValueEntity(fromStringValue);
if (propertyStringValueEntity != null)
{
propertyStringValueEntity.setValue(toStringValue);
recordsManagementQueryDAO.updatePropertyStringValueEntity(propertyStringValueEntity);
}
}
}

View File

@@ -28,6 +28,7 @@
package org.alfresco.module.org_alfresco_module_rm.patch.v33;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -104,6 +105,23 @@ public class RMv33HoldAuditEntryValuesPatchUnitTest
assertEquals(Long.valueOf(132_640_810L), deleteHoldPropertyStringValueEntity.getStringCrc());
}
/**
* if there are no hold audit entries, the patch is executed with success; no entries are updated
*/
@Test
public void patchRunWithSuccessWhenNoHoldEntries()
{
when(mockedRecordsManagementQueryDAO.getPropertyStringValueEntity("addToHold")).thenReturn(null);
when(mockedRecordsManagementQueryDAO.getPropertyStringValueEntity("removeFromHold")).thenReturn(null);
when(mockedRecordsManagementQueryDAO.getPropertyStringValueEntity("deleteHold")).thenReturn(null);
patch.applyInternal();
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("addToHold");
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("removeFromHold");
verify(mockedRecordsManagementQueryDAO, times(1)).getPropertyStringValueEntity("deleteHold");
verify(mockedRecordsManagementQueryDAO, times(0)).updatePropertyStringValueEntity(any());
}
}