Add further unit tests.
[cfb.git] / test / net / jaekl / cfb / store / DbStoreTest.java
index f269a9cd126205bfe0a0dc2db63ff9a99fc37536..5c66c225fd38107d7e866d826bf43be269a68616 100644 (file)
@@ -137,7 +137,7 @@ public class DbStoreTest {
        }
 
        @Test
-       public void testGetPrior_withNoEntries() throws SQLException, TypeMismatchException {
+       public void testGetPrior_withNoEntries() throws SQLException, TypeMismatchException, StoreException {
                // First test:  getPrior(null) should return null
                Analysis actual = m_store.getPrior(null);
                assertNull(actual);
@@ -236,75 +236,42 @@ public class DbStoreTest {
                assertEquals(firstAnalysis.getEnd(), priorAnalysis.getEnd());
                assertEquals(firstAnalysis.getBugCollection(), priorAnalysis.getBugCollection());
        }
-/*
-       @Test
-       public void testGetBugType() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testGetCategoryName() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testGetLoc() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testGetLocId() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testFindLocId() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testStoreLoc() {
-               fail("Not yet implemented");
-       }
 
        @Test
-       public void testGetVarIdBugInstance() {
-               fail("Not yet implemented");
+       public void testGetLocId_nullReturnsNull() throws SQLException, TypeMismatchException {
+               Long locId = m_store.getLocId(null);
+               assertNull(locId);
        }
 
        @Test
-       public void testGetVar() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testGetVarIdLocalVariable() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testFindVarId() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testStoreVar() {
-               fail("Not yet implemented");
-       }
-
-       @Test
-       public void testGetPriorId() {
-               fail("Not yet implemented");
+       public void testGetLocId_notFoundIsStored() throws SQLException, TypeMismatchException {
+               Location loc = new Location(1234567890L, 
+                                                                       "ThisClassDoesNotExist", 
+                                                                       "thisMethodDoesNotExist", 
+                                                                       "INVALID_METHOD_ROLE", 
+                                                                       0, 90909);
+               Long locId = m_store.getLocId(loc);
+               assertNotNull(locId);
+               assertTrue(locId.longValue() > 0);
+               
+               Long secondLocId = m_store.getLocId(loc);
+               assertEquals(locId, secondLocId);
        }
 
        @Test
-       public void testGetAnalysis() {
-               fail("Not yet implemented");
+       public void testGetLoc_nullReturnsNull() throws SQLException, TypeMismatchException, StoreException {
+               Location loc = m_store.getLoc(null);
+               assertNull(loc);
        }
-
+       
        @Test
-       public void testGetBugCollection() {
-               fail("Not yet implemented");
+       public void testGetLoc_invalidId() throws SQLException, TypeMismatchException {
+               try {
+                       m_store.getLoc(Long.valueOf(-3));
+                       fail("Should have thrown a StoreException");
+               }
+               catch (StoreException exc) {
+                       assertEquals(StoreException.Type.INVALID_LOC_ID, exc.getType());
+               }
        }
-*/
 }