Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DaoDispatcher.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DaoDispatcher.java	(revision 3413)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DaoDispatcher.java	(revision 3414)
@@ -159,8 +159,8 @@
             result[1] = sourceDao.deleteAllSourceVersion(sourceID);
             result[0] = sourceDao.deleteSource(sourceID);
-            result[3] = 0;
+            result[2] = 0;
             for (Number versionID : versions) {
                 int[] deleteVersion = deleteVersionWithCachedRepresentations(versionID);
-                result[3] = result[3] + deleteVersion[1];
+                result[2] = result[2] + deleteVersion[0];
             }
         } else {
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/DaoDispatcherTest.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/DaoDispatcherTest.java	(revision 3413)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/DaoDispatcherTest.java	(revision 3414)
@@ -130,5 +130,5 @@
         mockery.checking(new Expectations() {
             {
-                oneOf(annotationDao).getInternalID(userIdentifier);
+                oneOf(userDao).getInternalID(userIdentifier);
                 will(returnValue(5));
             }
@@ -147,9 +147,9 @@
         mockery.checking(new Expectations() {
             {
-                oneOf(annotationDao).getExternalID(5);
+                oneOf(userDao).getExternalID(5);
                 will(returnValue(userIdentifier));
             }
         });
-        assertEquals(TestBackendConstants._TEST_USER_5_EXT_ID, daoDispatcher.getUserExternalIdentifier(5));
+        assertEquals(TestBackendConstants._TEST_USER_5_EXT_ID, daoDispatcher.getUserExternalIdentifier(5).toString());
     }
 
@@ -207,5 +207,5 @@
 
 
-        Number[] result = daoDispatcher.addCachedForVersion(6, newCached);
+        Number[] result = daoDispatcher.addCachedForVersion(versionID, newCached);
         assertEquals(2, result.length);
         assertEquals(newID, result[0]);
@@ -266,8 +266,8 @@
     @Test
     public void testDeleteSourceSourceWithVersions() throws SQLException {
-        // test 1
+        // test 1: source in use by some annotation
          mockery.checking(new Expectations() {
             {
-                oneOf(sourceDao).sourceIsInUse(5);
+                oneOf(sourceDao).sourceIsInUse(1);
                 will(returnValue(true));
             }
@@ -278,6 +278,5 @@
         assertEquals(0, result[1]);
 
-        // test 2
-        
+        // test 2 : source is not used by annotations     
         final List<Number> versionList = new ArrayList<Number>();
         versionList.add(7);
@@ -297,5 +296,13 @@
                 
                 oneOf(versionDao).versionIsInUse(7);
-                will(returnValue(false));
+                will(returnValue(false)); //not mentioned in the table "sources_versions" after deleteing(5,7)
+                
+                oneOf(versionDao).retrieveCachedRepresentationList(7);
+                will(returnValue(new ArrayList<Number>())); // no cached representations for version 7, the list is just empty
+                
+                oneOf(versionDao).deleteAllVersionCachedRepresentation(7);
+                
+                oneOf(versionDao).deleteVersion(7);
+                will(returnValue(1));
             }
         });
@@ -306,5 +313,5 @@
         assertEquals(1, resultTwo[0]); // source 7 is deleted
         assertEquals(1, resultTwo[1]); // row (5,7) in "sorces_versions" is deleted
-        assertEquals(0, resultTwo[2]); // version 7 is not foub=nd, not in use
+        assertEquals(1, resultTwo[2]); // version 7 is deleted
     }
 
