Commit dc6408ee authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '640-setting-reactants' into 'devel_12.1.x'

Resolve "Setting reactants, modifiers and products sometimes fails in getCompleteReactionById"

See merge request !587
parents c7172518 96ba013b
Pipeline #8387 passed with stage
in 1 minute and 52 seconds
minerva (12.1.6) stable; urgency=medium
* Bug fix: logo on login page was broken with image link being full url
* Bug fix: plugin API had sometimes problems with fetching reactions
properly
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 10 Janc 2019 14:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 22 Jan 2019 14:00:00 +0200
minerva (12.1.5) stable; urgency=medium
* Bug fix: Drugbank changed output format which crashed drug connector
* Bug fix: word wrapping fixed in overlay table for long overlay names
in Firefox browser
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 10 Janc 2019 14:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 10 Jan 2019 14:00:00 +0200
minerva (12.1.4) stable; urgency=medium
* Bug fix: no check for limit on custom data overlays fixed
......
......@@ -237,17 +237,17 @@ MapModel.prototype.getCompleteReactionById = function (id) {
var i;
result = self._reactions[id];
for (i = 0; i < result.getReactants().length; i++) {
if (!(result.getReactants()[i] instanceof Alias)) {
if (!(result.getReactants()[i].getAlias() instanceof Alias)) {
result.getReactants()[i].setAlias(self._aliases[result.getReactants()[i].getAlias()]);
}
}
for (i = 0; i < result.getProducts().length; i++) {
if (!(result.getProducts()[i] instanceof Alias)) {
if (!(result.getProducts()[i].getAlias() instanceof Alias)) {
result.getProducts()[i].setAlias(self._aliases[result.getProducts()[i].getAlias()]);
}
}
for (i = 0; i < result.getModifiers().length; i++) {
if (!(result.getModifiers()[i] instanceof Alias)) {
if (!(result.getModifiers()[i].getAlias() instanceof Alias)) {
result.getModifiers()[i].setAlias(self._aliases[result.getModifiers()[i].getAlias()]);
}
}
......
......@@ -2,6 +2,7 @@
require("../../mocha-config");
var Alias = require('../../../../main/js/map/data/Alias');
var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement');
var MapModel = require('../../../../main/js/map/data/MapModel');
var NetworkError = require('../../../../main/js/NetworkError');
......@@ -95,21 +96,45 @@ describe('MapModel', function () {
});
});
it("getReactionById 1", function () {
var model = helper.createModel();
var reaction = helper.createReaction();
describe("getReactionById", function () {
it("not existing", function () {
var model = helper.createModel();
var reaction = helper.createReaction();
return model.getReactionById(reaction.getId()).then(function (result) {
assert.equal(null, result);
}, function (exception) {
assert.ok(exception instanceof NetworkError);
// check if this is exception about not finding file
model.addReaction(reaction);
return model.getReactionById(reaction.getId());
}).then(function (result) {
assert.equal(reaction, result);
});
});
return model.getReactionById(reaction.getId()).then(function (result) {
assert.equal(null, result);
}, function (exception) {
assert.ok(exception instanceof NetworkError);
// check if this is exception about not finding file
model.addReaction(reaction);
return model.getReactionById(reaction.getId());
}).then(function (result) {
assert.equal(reaction, result);
it("check reactants", function () {
var model;
return ServerConnector.getProject().then(function (project) {
model = project.getModels()[0];
return model.getReactionById(153510, true);
}).then(function (result) {
assert.ok(result.getReactants()[0].getAlias() instanceof Alias);
assert.ok(result.getProducts()[0].getAlias() instanceof Alias);
assert.ok(result.getModifiers()[0].getAlias() instanceof Alias);
//let assume we downloaded it partially
result.setIsComplete(false);
return model.getReactionById(153510, true);
}).then(function (result) {
assert.ok(result.getReactants()[0].getAlias() instanceof Alias);
assert.ok(result.getProducts()[0].getAlias() instanceof Alias);
assert.ok(result.getModifiers()[0].getAlias() instanceof Alias);
});
});
});
it("addReaction 2", function () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment