Resolved the issue of actionCollection updatedAt field not getting updated (#14323)
This commit is contained in:
parent
4e13fc5125
commit
74ac6b9a1c
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user