assertEquals(1, query.orderByModelVersion().desc().count());
assertEquals(1, query.orderByModelKey().desc().count());
}
public void testByLatestVersion() {
ModelQuery query = repositoryService.createModelQuery().latestVersion().modelKey("someKey");
Model model = query.singleResult();
assertNotNull(model);
// Add a new version of the model
Model newVersion = repositoryService.newModel();
newVersion.setName("my model");
newVersion.setKey("someKey");
newVersion.setCategory("test");
newVersion.setVersion(model.getVersion() + 1);
repositoryService.saveModel(newVersion);
// Verify query
model = query.singleResult();
assertNotNull(model);
assertTrue(model.getVersion() == 2);
// Cleanup
repositoryService.deleteModel(model.getId());