Resolved the issue of actionCollection updatedAt field not getting updated (#14323)

This commit is contained in:
Vishnu Gp 2022-06-11 10:03:26 +05:30 committed by GitHub
parent 4e13fc5125
commit 74ac6b9a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import reactor.core.scheduler.Scheduler;
import javax.validation.Validator;
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@ -82,6 +83,8 @@ public abstract class BaseService<R extends BaseRepository<T, ID> & AppsmithRepo
resource.setPolicies(null);
}
resource.setUpdatedAt(Instant.now());
DBObject update = getDbObject(resource);
Update updateObj = new Update();

View File

@ -521,4 +521,42 @@ public class ActionCollectionServiceTest {
.verifyComplete();
}
/**
* For a given collection testActionCollection,
* When the collection is updated after creation,
* The updatedAt field should have a greater value than the updatedAt value when it was created.
*/
@Test
@WithUserDetails(value = "api_user")
public void testUpdateActionCollection_verifyUpdatedAtFieldUpdated() {
ActionCollectionDTO actionCollectionDTO = new ActionCollectionDTO();
actionCollectionDTO.setName("testActionCollection");
actionCollectionDTO.setApplicationId(testApp.getId());
actionCollectionDTO.setOrganizationId(testApp.getOrganizationId());
actionCollectionDTO.setPageId(testPage.getId());
actionCollectionDTO.setPluginId(datasource.getPluginId());
actionCollectionDTO.setPluginType(PluginType.JS);
ActionCollection createdActionCollection = layoutCollectionService.createCollection(actionCollectionDTO)
.flatMap(createdCollection -> {
// Delay after creating(before updating) record to get different updatedAt time
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return actionCollectionService.findById(createdCollection.getId(), READ_ACTIONS);
}).block();
Mono<ActionCollection> updatedActionCollectionMono = layoutCollectionService.updateUnpublishedActionCollection(createdActionCollection.getId(), actionCollectionDTO, null)
.flatMap(createdCollection -> actionCollectionService.findById(createdCollection.getId(), READ_ACTIONS));
StepVerifier.create(updatedActionCollectionMono)
.assertNext(updatedActionCollection -> {
assertThat(updatedActionCollection.getUpdatedAt().isAfter(createdActionCollection.getUpdatedAt())).isTrue();
})
.verifyComplete();
}
}