System.out.println("Trying to add the cloned reaction to the model, which should not be possible");
// Trying to add the
boolean operationSuccessful = m.addReaction(clonedReaction);
if (operationSuccessful != false) {
throw new SBMLException("It should not be possible to add two elements with the same id in a ListOf class !!");
}
// Here the parent is still null as it should as the cloned reaction
// was not added to the model as her id is the same as the reaction 'r'
System.out.println("Cloned reaction parent and model still null : " + clonedReaction.getParent() + " " + clonedReaction.getModel() + "\n");
// setting a new unit id the the cloned reaction
clonedReaction.setId("id2");
System.out.println("Trying to add the cloned reaction to the model, with a new unique id. It is still not possible as the metaids are not unique.");
try {
m.addReaction(clonedReaction);
throw new SBMLException("It should not be possible to add two elements with the same metaid in a SBML document !!");
} catch (IllegalArgumentException e) {
// success, the exception should be thrown there
}
// setting a new unique metaid to the reaction but not it's sub-elements
clonedReaction.setMetaId("meta3");
System.out.println("Trying to add the cloned reaction to the model, with a new unique id and metaid. It is still not possible as the metaids are not unique.");
try {
operationSuccessful = m.addReaction(clonedReaction);
throw new SBMLException("It should not be possible to add a reaction that has any sub-elements with a non unique metaid !!");
} catch (IllegalArgumentException e) {
// success, the exception should be thrown there
}
System.out.println("Trying to add the cloned reaction to the model, with a new unique id and metaid for all sub-elements.");
// setting a new unique metaid to the reaction and all it's sub-elements
clonedReaction.getReactant(0).setMetaId("meta4");
// At the moment (rev 768), the reaction cannot be added to the model as the metaid 'meta3' as
// been added in the list of metaids in the previous call to addReaction() where only the speciesReference id
// was invalid
try {
operationSuccessful = m.addReaction(clonedReaction);
if (operationSuccessful != true) {
throw new SBMLException("It should be possible to add a reaction with an unique ids and metaids to a model !!");
}
} catch (IllegalArgumentException e) {
// bug here
System.out.println("Bug detected : there is a problem in the recursive adding of metaids !!!");
System.out.println("The reaction was not added to the model where it should have been");