Changeset 3347


Ignore:
Timestamp:
08/09/13 15:32:09 (11 years ago)
Author:
olhsha
Message:

nrefactored method addAnnotation from annotation-dao is tested

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/SourceDao.java

    r3345 r3347  
    2323import eu.dasish.annotation.schema.Source;
    2424import eu.dasish.annotation.schema.SourceInfo;
     25import java.sql.SQLException;
    2526import java.util.List;
    2627import java.util.Map;
     
    105106     * The side-effect: the joint table "annotations_target_sources" is extended by the pairs (annotationID, addedSoiurceID).
    106107     */
    107     public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources);       
     108    public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException;       
    108109   
    109110       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java

    r3345 r3347  
    209209    @Override
    210210    public Annotation addAnnotation(Annotation annotation, Number ownerID) throws SQLException {
    211         if (annotation == null) {
    212             return null;
    213         }
     211
     212        Annotation result = makeDeepCopy(annotation);
     213
     214        ResourceREF ownerRef = new ResourceREF();
     215        ownerRef.setRef(String.valueOf(ownerID));
     216        result.setOwner(ownerRef);
     217
     218        // generate a new annotation ID
     219        AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier();
     220        result.setURI(annotationIdentifier.toString());
     221
     222        Map<String, Object> params = new HashMap<String, Object>();
     223        params.put("externalId", annotationIdentifier.toString());
     224        //params.put("timeStamp", annotation.getTimeStamp()); is generated while adding the annotation in the DB as "now"
     225        params.put("ownerId", ownerID);
     226        params.put("headline", annotation.getHeadline());
     227        params.put("bodyXml", annotation.getBody().getAny().get(0).toString());
     228
    214229        try {
    215             Annotation result = makeFreshCopy(annotation);
    216 
    217             ResourceREF ownerRef = new ResourceREF();
    218             ownerRef.setRef(String.valueOf(ownerID));
    219             result.setOwner(ownerRef);
    220 
    221             // generate a new annotation ID
    222             AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier();
    223             result.setURI(annotationIdentifier.toString());
    224 
    225             Map<String, Object> params = new HashMap<String, Object>();
    226             params.put("externalId", annotationIdentifier.toString());
    227             //params.put("timeStamp", annotation.getTimeStamp()); is generated while adding the annotation in the DB as "now"
    228             params.put("ownerId", ownerID);
    229             params.put("headline", annotation.getHeadline());
    230             params.put("bodyXml", annotation.getBody().getAny().get(0).toString());
    231230
    232231            String sql = "INSERT INTO " + annotationTableName + "(" + external_id + "," + owner_id + "," + headline + "," + body_xml + " ) VALUES (:externalId, :ownerId, :headline, :bodyXml)";
    233232            final int affectedRows = getSimpleJdbcTemplate().update(sql, params);
     233           
     234            if (affectedRows != 1) {
     235                throw (new SQLException("Cannot add the annotation properly"));
     236            }
    234237
    235238            Number internalID = getInternalID(annotationIdentifier);
    236 
    237239
    238240            //retrieve taime stamp for the just added annotation
     
    248250            //replace the temporary sourceId-references in the body with the persistent externalId
    249251            String body = annotation.getBody().getAny().get(0).toString();
    250             String newBody =  updateTargetRefsInBody(body, sourcePairs);
     252            String newBody = updateTargetRefsInBody(body, sourcePairs);
    251253            List<Object> bodyXML = result.getBody().getAny();
    252254            bodyXML.clear();
    253255            bodyXML.add(newBody);
    254256            String sqlUpdate = "UPDATE " + annotationTableName + " SET " + body_xml + "= ? WHERE " + annotation_id + "= " + internalID;
    255             int affectedRowsBodyUpd = getSimpleJdbcTemplate().update(sqlUpdate, bodyXML);
    256            
    257            
     257            int affectedRowsBodyUpd = getSimpleJdbcTemplate().update(sqlUpdate, newBody);
     258            if (affectedRows != 1) {
     259                throw (new SQLException("Cannot update the body with persistent reference ID"));
     260            }
     261
    258262            return result;
    259263        } catch (DataAccessException exception) {
     
    270274    //////////// helpers ///////////////////////
    271275    /////////////////////////////////////////////////
    272    
    273     private String updateTargetRefsInBody(String body, Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs){
     276    private String updateTargetRefsInBody(String body, Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs) {
    274277        String result = body;
    275278        for (NewOrExistingSourceInfo tempSource : sourcePairs.keySet()) {
    276                 NewSourceInfo newSource = tempSource.getNewSource();
    277                 if (newSource != null) {
    278                     result=result.replaceAll(newSource.getId(),sourcePairs.get(tempSource).getSource().getRef() );
    279                 }
     279            NewSourceInfo newSource = tempSource.getNewSource();
     280            if (newSource != null) {
     281                result = result.replaceAll(newSource.getId(), sourcePairs.get(tempSource).getSource().getRef());
    280282            }
     283        }
    281284        return result;
    282285    }
    283    
     286
    284287    private XMLGregorianCalendar retrieveTimeStamp(Number internalID) {
    285288        String sqlTime = "SELECT " + time_stamp + " FROM " + annotationTableName + " WHERE " + annotation_id + "= ?";
     
    311314
    312315    ////////////////////////////////////////// 
    313     private Annotation makeFreshCopy(Annotation annotation) {
     316    private Annotation makeDeepCopy(Annotation annotation) {
    314317
    315318        if (annotation == null) {
     
    318321
    319322        Annotation result = new Annotation();
    320         result.setBody(annotation.getBody());
     323       
     324       
     325        AnnotationBody body = new AnnotationBody();
     326        String bodyString = annotation.getBody().getAny().get(0).toString();
     327        body.getAny().add(bodyString);
     328        result.setBody(body);
     329       
    321330        result.setHeadline(annotation.getHeadline());
    322         result.setOwner(annotation.getOwner());
    323         result.setPermissions(annotation.getPermissions());
    324         result.setTargetSources(annotation.getTargetSources());
     331       
     332        ResourceREF owner = new ResourceREF();
     333        owner.setRef(annotation.getOwner().getRef());
     334        result.setOwner(owner);
     335       
     336//        ResourceREF permissions = new ResourceREF();
     337//        permissions.setRef(annotation.getPermissions().getRef());
     338//        result.setPermissions(permissions);
     339       
     340        result.setPermissions(null); //we do not have permissions there
     341       
     342        NewOrExistingSourceInfos noesi = new NewOrExistingSourceInfos();
     343        noesi.getTarget().addAll(annotation.getTargetSources().getTarget());       
     344        result.setTargetSources(noesi);
     345       
    325346        result.setTimeStamp(annotation.getTimeStamp());
    326347        result.setURI(annotation.getURI());
     
    329350    }
    330351}
    331 //List<NewOrExistingSourceInfo> targets = annotation.getTargetSources().getTarget();
    332 //        if (clear) {
    333 //            targets.clear();
    334 //        }
    335 //       
    336 //        targets.addAll(sourcesUpdated);
    337 //       
    338 //        /// time to update body
    339 //        Number annotationInternalId = getInternalID(annotationIdentifier);
    340 //        String sqlUpdate = "UPDATE " + annotationTableName + " SET " + body_xml + "= ? WHERE " + annotation_id + "= " + annotationInternalId;
    341 //        int affectedRowsBodyUpd = getSimpleJdbcTemplate().update(sqlUpdate, bodyXML);
    342 //
    343 //        List<Object> body = annotation.getBody().getAny();
    344 //        body.clear();
    345 //        body.add(bodyXML);
    346         //body is updated
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java

    r3345 r3347  
    230230     ////////////////////////////////////////////////////////////////////////
    231231    @Override
    232     public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) {
     232    public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException {
    233233
    234234        Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>();
     
    243243                Source newSource = constructNewSource(noeSourceInfo.getNewSource());
    244244                Source addedSource = addSource(newSource);
    245                 addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(addedSource.getURI())));
     245                int affectedRows = addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(addedSource.getURI())));
     246               
    246247                //  create updated source info
    247248                SourceInfo updatedSourceInfo = new SourceInfo();
     
    256257           
    257258        }
    258        
    259        
    260259        return result;
    261260    }
     
    268267   
    269268 
    270     private int addAnnotationSourcePair(Number annotationID, Number sourceID) {
     269    private int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException{
    271270        // source is "old" i.e. exists in the DB, onlu the table annotations_target_sources should be updated
    272271        Map<String, Object> paramsAnnotationsSources = new HashMap<String, Object>();
     
    274273        paramsAnnotationsSources.put("sourceId",  sourceID);
    275274        String sqlAnnotationsSources = "INSERT INTO " + annotationsSourcesTableName + "(" + annotation_id + "," + source_id + " ) VALUES (:annotationId, :sourceId)";
    276         return (getSimpleJdbcTemplate().update(sqlAnnotationsSources, paramsAnnotationsSources));
     275        int affectedRows = getSimpleJdbcTemplate().update(sqlAnnotationsSources, paramsAnnotationsSources);
     276        if (affectedRows != 1) {
     277            throw (new SQLException("Cannot add annotation properly"));
     278
     279        }       
     280        return (affectedRows);
    277281    }
    278282   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java

    r3334 r3347  
    5555       sourceInfo.setLink(TestBackendConstants._TEST_SOURCE_1_LINK);
    5656       sourceInfo.setRef(TestBackendConstants._TEST_SOURCE_1_EXT_ID);
    57        sourceInfo.setVersion(Integer.toString(TestBackendConstants._TEST_SOURCE_1_VERSION_ID));
     57       sourceInfo.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID);
    5858       
    5959       NewOrExistingSourceInfo noeSourceInfo =  new NewOrExistingSourceInfo();
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java

    r3345 r3347  
    2828import eu.dasish.annotation.schema.AnnotationInfo;
    2929import eu.dasish.annotation.schema.NewOrExistingSourceInfo;
     30import eu.dasish.annotation.schema.NewOrExistingSourceInfo;
    3031import eu.dasish.annotation.schema.NewOrExistingSourceInfos;
     32import eu.dasish.annotation.schema.NewSourceInfo;
    3133import eu.dasish.annotation.schema.ResourceREF;
    3234import eu.dasish.annotation.schema.Source;
     
    3436import java.sql.SQLException;
    3537import java.util.ArrayList;
     38import java.util.HashMap;
    3639import java.util.List;
     40import java.util.Map;
    3741import org.jmock.Expectations;
    3842import org.jmock.Mockery;
     
    251255     */
    252256    @Test
    253     @Ignore
    254257    public void testAddAnnotationExistingSource() throws SQLException{
    255258        System.out.println("test_addAnnotation with an existing source");
     
    259262        assertEquals(null, annotationToAdd.getTimeStamp());
    260263       
     264        NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo();
     265        SourceInfo si = new SourceInfo();
     266        si.setLink(TestBackendConstants._TEST_SOURCE_1_LINK);
     267        si.setRef(TestBackendConstants._TEST_SOURCE_1_EXT_ID);
     268        si.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID);
     269        noesi.setSource(si);
     270       
     271        final Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> map = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>();
     272        map.put(noesi, noesi);
     273       
     274       
    261275        mockery.checking(new Expectations() {
    262276            { 
    263                oneOf(sourceDao).getInternalID(new SourceIdentifier(TestBackendConstants._TEST_SOURCE_1_EXT_ID));
    264                 will(returnValue(1));
     277               oneOf(sourceDao).addTargetSources(with(aNonNull(Number.class)), with(aNonNull(List.class)));
     278                will(returnValue(map));
    265279            }
    266280        });
     
    268282        Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5);       
    269283        assertFalse(null==result.getURI());
    270         assertFalse(null==result.getTimeStamp());
     284        assertFalse(null==result.getTimeStamp());       
    271285        assertEquals(annotationToAdd.getBody().getAny().get(0), result.getBody().getAny().get(0));
    272286        assertEquals(annotationToAdd.getHeadline(), result.getHeadline());
    273287        assertEquals(String.valueOf(5), result.getOwner().getRef());
    274288        assertEquals(annotationToAdd.getPermissions(), result.getPermissions());
    275         assertEquals(annotationToAdd.getTargetSources(), result.getTargetSources());
     289       
     290        SourceInfo expectedSi = annotationToAdd.getTargetSources().getTarget().get(0).getSource();
     291        SourceInfo resultSi = result.getTargetSources().getTarget().get(0).getSource();
     292        assertEquals(expectedSi.getLink(), resultSi.getLink());
     293        assertEquals(expectedSi.getRef(), resultSi.getRef());
     294        assertEquals(expectedSi.getVersion(), resultSi.getVersion());
    276295    }
    277296   
     
    281300     */
    282301    @Test
    283     @Ignore
    284302    public void testAddAnnotationNewSource() throws SQLException{
    285303        System.out.println("test_addAnnotation with a new source");
    286304       
    287         final Annotation annotationToAddNewSource = testInstances.getAnnotationToAddNewSource();// existing sources
    288        
    289        
    290         final Source addedSource  = new Source();
    291         final SourceIdentifier sourceIdentifier = new SourceIdentifier();
    292         addedSource.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK);
    293         addedSource.setURI(sourceIdentifier.toString());
     305       
     306        Annotation annotationToAdd = testInstances.getAnnotationToAddNewSource();// existing sources
     307        assertEquals(null, annotationToAdd.getURI());
     308        assertEquals(null, annotationToAdd.getTimeStamp());
     309       
     310       
     311        NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo();
     312        NewSourceInfo nsi = new NewSourceInfo();
     313        nsi.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK);
     314        nsi.setId(TestBackendConstants._TEST_TEMP_SOURCE_ID);
     315        nsi.setVersion(null);
     316        noesi.setNewSource(nsi);
     317       
     318       
     319        NewOrExistingSourceInfo noesiTwo = new NewOrExistingSourceInfo();
     320        SourceInfo si = new SourceInfo();
     321        si.setLink(TestBackendConstants._TEST_NEW_SOURCE_LINK);
     322        si.setRef((new SourceIdentifier()).toString());
     323        si.setVersion(null);
     324        noesiTwo.setSource(si);
     325       
     326        final Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> map = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>();
     327        map.put(noesi, noesiTwo);
     328       
    294329       
    295330        mockery.checking(new Expectations() {
    296             {
    297                oneOf(sourceDao).addSource(with(aNonNull(Source.class)));
    298                will(returnValue(addedSource));
    299                
    300                oneOf(sourceDao).getInternalID(sourceIdentifier);
    301                will(returnValue(5)); 
    302                
     331            { 
     332               oneOf(sourceDao).addTargetSources(with(aNonNull(Number.class)), with(aNonNull(List.class)));
     333                will(returnValue(map));
    303334            }
    304335        });
    305336       
    306         Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAddNewSource, 5);
     337        Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5);       
    307338        assertFalse(null==result.getURI());
    308339        assertFalse(null==result.getTimeStamp());
    309         //assertEquals(annotationToAddNewSource.getBody().getAny().get(0).toString(), result.getBody().getAny().get(0));
    310         assertEquals(annotationToAddNewSource.getHeadline(), result.getHeadline());
     340        assertEquals(annotationToAdd.getHeadline(), result.getHeadline());
    311341        assertEquals(String.valueOf(5), result.getOwner().getRef());
    312         assertEquals(annotationToAddNewSource.getPermissions(), result.getPermissions());
    313         //assertEquals(annotationToAddNewSource.getTargetSources(), result.getTargetSources());
    314        
     342        assertEquals(annotationToAdd.getPermissions(), result.getPermissions());
     343       
     344        NewSourceInfo expectedSi = annotationToAdd.getTargetSources().getTarget().get(0).getNewSource();
     345        SourceInfo resultSi = result.getTargetSources().getTarget().get(0).getSource();
     346        assertEquals(expectedSi.getLink(), resultSi.getLink());       
     347        assertEquals(expectedSi.getVersion(), resultSi.getVersion());   
     348        //the reference is replaced with the persistent one
     349        assertEquals(si.getRef(), resultSi.getRef());
     350        ///// 
     351       
     352        // checking the bodies: the temporary reference should be replaced
     353        String expBody = annotationToAdd.getBody().getAny().get(0).toString().replaceAll(TestBackendConstants._TEST_TEMP_SOURCE_ID, si.getRef());
     354        assertEquals(expBody, result.getBody().getAny().get(0).toString());
    315355    }
    316356   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java

    r3346 r3347  
    2727import eu.dasish.annotation.schema.Source;
    2828import eu.dasish.annotation.schema.SourceInfo;
     29import java.sql.SQLException;
    2930import java.util.ArrayList;
    3031import java.util.List;
    3132import java.util.Map;
    32 import java.util.UUID;
    3333import org.jmock.Expectations;
    3434import org.jmock.Mockery;
     
    5050    "/spring-config/sourceDao.xml"})
    5151public class JdbcSourceDaoTest extends JdbcResourceDaoTest {
    52 
     52   
    5353    @Autowired
    5454    JdbcSourceDao jdbcSourceDao;
     
    103103        final Number internalVersionID = 1;
    104104        final VersionIdentifier externalVersionID = new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID);
    105 
     105       
    106106        mockery.checking(new Expectations() {
    107107            {
     
    110110            }
    111111        });
    112 
     112       
    113113        Source result = jdbcSourceDao.getSource(internalID);
    114114        assertEquals(TestBackendConstants._TEST_SOURCE_1_EXT_ID, result.getURI());
     
    127127        int result = jdbcSourceDao.deleteSourceVersionRows(internalID);
    128128        assertEquals(1, result);
    129 
     129       
    130130        Number internalIDNoExist = 5;
    131131        int resultTwo = jdbcSourceDao.deleteSourceVersionRows(internalIDNoExist);
     
    150150                oneOf(versionDao).retrieveVersionList(internalIDToBeDeleted);
    151151                will(returnValue(versions));
    152 
     152               
    153153                oneOf(versionDao).deleteVersion(5);
    154154                will(returnValue(1)); // no other sources refer to this version # 5
    155155            }
    156156        });
    157 
     157       
    158158        int resultTwo = jdbcSourceDao.deleteSource(internalIDToBeDeleted);
    159159        assertEquals(1, resultTwo); // the source will be deleted because it is not referred by any annotation
     
    166166    public void testAddSource() {
    167167        System.out.println("addSource");
    168 
     168       
    169169        String link = "http://www.sagradafamilia.cat/";
    170170        String version = null;
    171 
     171       
    172172        Source freshSource = new Source();
    173173        freshSource.setLink(link);
    174174        freshSource.setVersion(version);
    175 
     175       
    176176        Source result = jdbcSourceDao.addSource(freshSource);
    177177        assertEquals(link, result.getLink());
     
    188188        System.out.println("getSourceInfos");
    189189        Number annotationID = 2;
    190 
     190       
    191191        mockery.checking(new Expectations() {
    192192            {
    193193                oneOf(versionDao).getExternalID(1);
    194194                will(returnValue(new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID)));
    195 
     195               
    196196                oneOf(versionDao).getExternalID(3);
    197197                will(returnValue(new VersionIdentifier(TestBackendConstants._TEST_VERSION_3_EXT_ID)));
    198198            }
    199199        });
    200 
     200       
    201201        List<SourceInfo> result = jdbcSourceDao.getSourceInfos(annotationID);
    202202        assertEquals(2, result.size());
     
    207207        assertEquals(TestBackendConstants._TEST_SOURCE_1_LINK, result.get(0).getLink());
    208208        assertEquals(TestBackendConstants._TEST_SOURCE_2_LINK, result.get(1).getLink());
    209 
     209       
    210210    }
    211211
     
    216216    public void testContructNewOrExistingSourceInfo() {
    217217        System.out.println("contructNewOrExistingSourceInfo");
    218 
     218       
    219219        List<SourceInfo> sourceInfoList = new ArrayList<SourceInfo>();
    220 
     220       
    221221        SourceInfo sourceInfoOne = new SourceInfo();
    222222        sourceInfoOne.setLink(TestBackendConstants._TEST_SOURCE_1_LINK);
    223223        sourceInfoOne.setRef(TestBackendConstants._TEST_SOURCE_1_EXT_ID);
    224224        sourceInfoOne.setRef(TestBackendConstants._TEST_VERSION_1_EXT_ID);
    225 
     225       
    226226        SourceInfo sourceInfoTwo = new SourceInfo();
    227227        sourceInfoTwo.setLink(TestBackendConstants._TEST_SOURCE_2_LINK);
    228228        sourceInfoTwo.setRef(TestBackendConstants._TEST_SOURCE_2_EXT_ID);
    229229        sourceInfoTwo.setRef(TestBackendConstants._TEST_VERSION_3_EXT_ID);
    230 
     230       
    231231        sourceInfoList.add(sourceInfoOne);
    232232        sourceInfoList.add(sourceInfoTwo);
    233 
     233       
    234234        NewOrExistingSourceInfos result = jdbcSourceDao.contructNewOrExistingSourceInfo(sourceInfoList);
    235235        assertEquals(2, result.getTarget().size());
    236236        assertEquals(sourceInfoOne, result.getTarget().get(0).getSource());
    237237        assertEquals(sourceInfoTwo, result.getTarget().get(1).getSource());
    238 
     238       
    239239    }
    240240
     
    248248    public void testAddTargetSourcesOnExistingSource() {
    249249        System.out.println("addTargetSources : adding the old source");
    250    
     250        
    251251        NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo();
    252252        SourceInfo si = new SourceInfo();
     
    259259        listnoesi.add(noesi);
    260260       
    261         Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesi);
    262         assertEquals(1, result.size());
    263         assertEquals(result.get(noesi), noesi);
    264     }   
    265        
    266        
    267      /**
     261        try {
     262            Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesi);
     263            assertEquals(1, result.size());
     264            assertEquals(result.get(noesi), noesi);
     265        } catch (SQLException e) {
     266            System.out.println(e);
     267        }
     268    }
     269
     270    /**
    268271     * Test of addTargetSources method, of class JdbcSourceDao. public
    269272     * Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo>
     
    272275     */
    273276    @Test
    274      public void testAddTargetSourcesOnNewSource() {       
     277    public void testAddTargetSourcesOnNewSource() {
    275278        System.out.println("addTargetSources : adding the new source");
    276    
     279        
    277280        NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo();
    278281        NewSourceInfo nsi = new NewSourceInfo();
     
    285288        listnoesiTwo.add(noesi);
    286289       
    287         Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesiTwo);
    288         assertEquals(1, result.size());
    289         assertEquals(noesi.getNewSource().getLink(), result.get(noesi).getSource().getLink());
    290         assertEquals(noesi.getNewSource().getVersion(), result.get(noesi).getSource().getVersion());
    291        
    292         SourceIdentifier sourceIdentifier = new SourceIdentifier(result.get(noesi).getSource().getRef());
    293         assertFalse(null == sourceIdentifier.getUUID()); // check if a proper uuid has been assigned
     290        try {
     291            Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = jdbcSourceDao.addTargetSources(5, listnoesiTwo);
     292            assertEquals(1, result.size());
     293            assertEquals(noesi.getNewSource().getLink(), result.get(noesi).getSource().getLink());
     294            assertEquals(noesi.getNewSource().getVersion(), result.get(noesi).getSource().getVersion());
     295           
     296            SourceIdentifier sourceIdentifier = new SourceIdentifier(result.get(noesi).getSource().getRef());
     297            assertFalse(null == sourceIdentifier.getUUID()); // check if a proper uuid has been assigned
     298        } catch (SQLException e) {
     299            System.out.print(e);
     300        }
    294301       
    295302    }
Note: See TracChangeset for help on using the changeset viewer.