import net.jaekl.cfb.db.driver.DbDriverMock;
import net.jaekl.cfb.util.Command;
import net.jaekl.cfb.xml.BugCollection;
+import net.jaekl.cfb.xml.LocalVariable;
import net.jaekl.cfb.xml.MessagesXmlData;
import org.junit.Before;
assertEquals(StoreException.Type.INVALID_LOC_ID, exc.getType());
}
}
+
+ @Test
+ public void testGetVar_nullReturnsNull() throws SQLException, TypeMismatchException, StoreException {
+ LocalVariable var = m_store.getVar(null);
+ assertNull(var);
+ }
+
+ @Test
+ public void testGetVar_invalidId() throws SQLException, TypeMismatchException {
+ try {
+ m_store.getVar(Long.valueOf(-3));
+ fail("Should have thrown a StoreException");
+ }
+ catch (StoreException exc) {
+ assertEquals(StoreException.Type.INVALID_VAR_ID, exc.getType());
+ }
+ }
+
+ @Test
+ public void testGetVarId_notFoundIsStored() throws SQLException, TypeMismatchException, StoreException {
+ LocalVariable var = new LocalVariable(2345678901L, "VariableNameDoesNotYetExist", "VARIABLE_READ");
+
+ Long varId = m_store.getVarId(var);
+ assertNotNull(varId);
+ assertTrue(varId.longValue() > 0);
+
+ Long secondVarId = m_store.getVarId(var);
+ assertEquals(varId, secondVarId);
+
+ LocalVariable loadedVar = m_store.getVar(secondVarId);
+ assertEquals(var, loadedVar);
+ }
}