Avoid unit test failures when cfb.properties is not found in the classpath.
[cfb.git] / prod / net / jaekl / cfb / store / DbStore.java
index 3860ca5637e5c2fd31f93bec95b1d59900dec6d5..e50f7403910830d798e7cd8ca1b3296f056f42bc 100644 (file)
@@ -17,6 +17,8 @@ import net.jaekl.cfb.db.driver.DbDriver;
 import net.jaekl.cfb.xml.BugCollection;
 import net.jaekl.cfb.xml.BugInstance;
 import net.jaekl.cfb.xml.LocalVariable;
+import net.jaekl.cfb.xml.messages.BugCategory;
+import net.jaekl.cfb.xml.messages.BugPattern;
 import net.jaekl.cfb.xml.messages.MessageCollection;
 
 public class DbStore {
@@ -42,7 +44,7 @@ public class DbStore {
                return getAnalysis(priorId);
        }
        
-       public boolean put(Analysis analysis) throws SQLException, TypeMismatchException {
+       public boolean put(Analysis analysis) throws SQLException, TypeMismatchException, StoreException {
                if (null == analysis) {
                        return false;
                }
@@ -82,6 +84,13 @@ public class DbStore {
                        Location secondLoc = (locs.size() > 1) ? locs.get(1) : null;
                        Location thirdLoc  = (locs.size() > 2) ? locs.get(2) : null;
                        
+                       if (BugPattern.UNKNOWN.getId() == bugId) {
+                               throw new StoreException(StoreException.Type.UNKNOWN_PATTERN, ""+bug.getType());
+                       }
+                       if (BugCategory.UNKNOWN.getId() == categoryId) {
+                               throw new StoreException(StoreException.Type.UNKNOWN_CATEGORY, ""+bug.getCategory());
+                       }
+                       
                        values[row][0] = foundId;
                        values[row][1] = runId;
                        values[row][2] = bugId;