NIFI-12858 Corrected Order of Previous Property Values

- Reversed default order of previous values to return oldest entries before newest entries

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #8673.
This commit is contained in:
exceptionfactory 2024-04-19 10:12:19 -05:00 committed by Pierre Villard
parent d9e48f8645
commit 259a734a4b
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
2 changed files with 20 additions and 3 deletions

View File

@ -135,7 +135,8 @@ public class EntityStoreAuditService implements AuditService, Closeable {
final Map<String, List<PreviousValue>> previousValuesFound = new LinkedHashMap<>();
final EntityIterable actionEntities = storeTransaction.find(EntityType.ACTION.getEntityType(), ActionEntity.SOURCE_ID.getProperty(), componentId);
for (Entity actionEntity : actionEntities) {
// Reverse default ordering to return oldest entries before newest entries
for (Entity actionEntity : actionEntities.reverse()) {
final Entity configureDetails = actionEntity.getLink(ActionLink.CONFIGURE_DETAILS.getProperty());
if (configureDetails != null) {
final String name = getProperty(configureDetails, ConfigureDetailsEntity.NAME);

View File

@ -95,6 +95,8 @@ class EntityStoreAuditServiceTest {
private static final String SECOND_VALUE = "SecondValue";
private static final String THIRD_VALUE = "ThirdValue";
private static final String DATABASE_FILE_EXTENSION = ".xd";
@TempDir
@ -331,7 +333,14 @@ class EntityStoreAuditServiceTest {
secondConfigureDetails.setValue(SECOND_VALUE);
secondAction.setActionDetails(secondConfigureDetails);
final Collection<Action> actions = Arrays.asList(firstAction, secondAction);
final FlowChangeAction thirdAction = newAction();
thirdAction.setOperation(Operation.Configure);
final FlowChangeConfigureDetails thirdConfigureDetails = new FlowChangeConfigureDetails();
thirdConfigureDetails.setName(SECOND_PROPERTY_NAME);
thirdConfigureDetails.setValue(THIRD_VALUE);
thirdAction.setActionDetails(thirdConfigureDetails);
final Collection<Action> actions = Arrays.asList(firstAction, secondAction, thirdAction);
service.addActions(actions);
final Map<String, List<PreviousValue>> previousValues = service.getPreviousValues(SOURCE_ID);
@ -348,7 +357,14 @@ class EntityStoreAuditServiceTest {
final List<PreviousValue> secondPreviousValues = previousValues.get(SECOND_PROPERTY_NAME);
assertNotNull(secondPreviousValues);
final PreviousValue secondPreviousValue = secondPreviousValues.get(0);
final PreviousValue thirdPreviousValue = secondPreviousValues.get(0);
assertNotNull(thirdPreviousValue);
assertEquals(THIRD_VALUE, thirdPreviousValue.getPreviousValue());
assertNotNull(thirdPreviousValue.getTimestamp());
assertEquals(USER_IDENTITY, thirdPreviousValue.getUserIdentity());
final PreviousValue secondPreviousValue = secondPreviousValues.get(1);
assertNotNull(secondPreviousValue);
assertEquals(SECOND_VALUE, secondPreviousValue.getPreviousValue());
assertNotNull(secondPreviousValue.getTimestamp());