/**
* Test sim and exp ids.
*/
public void testSimAndExpIds() {
// first of all, we nee a brand new storage:
IWriteReadDataStorage bns = createDataStorage();
// let's have a look on how the storage reacts, if we try to write data
// without setting the ExpId, ConfId or SimId before:
long expid = bns.getNumberOfExperiments();
assertEquals(0, expid);
long confid = bns.getNumberOfConfigurations(expid);
assertEquals(0, confid);
assertEquals(0, bns.getNumberOfComputations(expid, confid));
// try to start a new configuration, though no ExpID is available:
try {
bns.setConfigurationID(null, UniqueIDGenerator.createUniqueID());
fail("You must specify the ExpID before.");
} catch (DataStorageException expected) {
}
// try to start a new simulation, though no ConfId and ExpID are available:
try {
bns.setComputationTaskID(null, null, UniqueIDGenerator.createUniqueID());
fail("You must specify the ExpID and ConfID before.");
} catch (DataStorageException expected) {
}
// this should throw an Exception, that no ExpId has been set:
try {
bns.writeData(42, "bla", 13.37, "zweiundvierzig");
fail("ExpID hast to be set before.");
} catch (DataStorageException expected) {
}
// this should throw an Exception, that no SimId has been set:
try {
bns.setExperimentID(UniqueIDGenerator.createUniqueID());
bns.writeData(42, "bla", 13.37, "zweiundvierzig");
fail("SimID has to be set before.");
} catch (DataStorageException expected) {
}
// this should throw an Exception, that no SimId has been set:
try {
bns.setConfigurationID(null, UniqueIDGenerator.createUniqueID());
bns.writeData(42, "bla", 13.37, "zweiundvierzig");
fail("ConfID has to be set before.");
} catch (DataStorageException expected) {
}
// this should not throw an exception, because now both Ids have been set:
bns.setComputationTaskID(null, null, UniqueIDGenerator.createUniqueID());
bns.writeData(42, "bla", 13.37, "zweiundvierzig");
// now the SimId should be reset and that's why we will expect again an
// exception like "no SimId set":
try {
bns.setExperimentID(UniqueIDGenerator.createUniqueID());
bns.writeData(42, "bla", 13.37, "zweiundvierzig");
fail("SimID has to be reset.");
} catch (DataStorageException expected) {
}
// TODO: