Changeset 3347
- Timestamp:
- 08/09/13 15:32:09 (11 years ago)
- 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 23 23 import eu.dasish.annotation.schema.Source; 24 24 import eu.dasish.annotation.schema.SourceInfo; 25 import java.sql.SQLException; 25 26 import java.util.List; 26 27 import java.util.Map; … … 105 106 * The side-effect: the joint table "annotations_target_sources" is extended by the pairs (annotationID, addedSoiurceID). 106 107 */ 107 public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) ;108 public Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> addTargetSources(Number annotationID, List<NewOrExistingSourceInfo> sources) throws SQLException; 108 109 109 110 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r3345 r3347 209 209 @Override 210 210 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 214 229 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 ID222 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());231 230 232 231 String sql = "INSERT INTO " + annotationTableName + "(" + external_id + "," + owner_id + "," + headline + "," + body_xml + " ) VALUES (:externalId, :ownerId, :headline, :bodyXml)"; 233 232 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 233 234 if (affectedRows != 1) { 235 throw (new SQLException("Cannot add the annotation properly")); 236 } 234 237 235 238 Number internalID = getInternalID(annotationIdentifier); 236 237 239 238 240 //retrieve taime stamp for the just added annotation … … 248 250 //replace the temporary sourceId-references in the body with the persistent externalId 249 251 String body = annotation.getBody().getAny().get(0).toString(); 250 String newBody = 252 String newBody = updateTargetRefsInBody(body, sourcePairs); 251 253 List<Object> bodyXML = result.getBody().getAny(); 252 254 bodyXML.clear(); 253 255 bodyXML.add(newBody); 254 256 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 258 262 return result; 259 263 } catch (DataAccessException exception) { … … 270 274 //////////// helpers /////////////////////// 271 275 ///////////////////////////////////////////////// 272 273 private String updateTargetRefsInBody(String body, Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs){ 276 private String updateTargetRefsInBody(String body, Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> sourcePairs) { 274 277 String result = body; 275 278 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()); 280 282 } 283 } 281 284 return result; 282 285 } 283 286 284 287 private XMLGregorianCalendar retrieveTimeStamp(Number internalID) { 285 288 String sqlTime = "SELECT " + time_stamp + " FROM " + annotationTableName + " WHERE " + annotation_id + "= ?"; … … 311 314 312 315 ////////////////////////////////////////// 313 private Annotation make FreshCopy(Annotation annotation) {316 private Annotation makeDeepCopy(Annotation annotation) { 314 317 315 318 if (annotation == null) { … … 318 321 319 322 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 321 330 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 325 346 result.setTimeStamp(annotation.getTimeStamp()); 326 347 result.setURI(annotation.getURI()); … … 329 350 } 330 351 } 331 //List<NewOrExistingSourceInfo> targets = annotation.getTargetSources().getTarget();332 // if (clear) {333 // targets.clear();334 // }335 //336 // targets.addAll(sourcesUpdated);337 //338 // /// time to update body339 // 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 230 230 //////////////////////////////////////////////////////////////////////// 231 231 @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 { 233 233 234 234 Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> result = new HashMap<NewOrExistingSourceInfo, NewOrExistingSourceInfo>(); … … 243 243 Source newSource = constructNewSource(noeSourceInfo.getNewSource()); 244 244 Source addedSource = addSource(newSource); 245 addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(addedSource.getURI()))); 245 int affectedRows = addAnnotationSourcePair(annotationID, getInternalID(new SourceIdentifier(addedSource.getURI()))); 246 246 247 // create updated source info 247 248 SourceInfo updatedSourceInfo = new SourceInfo(); … … 256 257 257 258 } 258 259 260 259 return result; 261 260 } … … 268 267 269 268 270 private int addAnnotationSourcePair(Number annotationID, Number sourceID) {269 private int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException{ 271 270 // source is "old" i.e. exists in the DB, onlu the table annotations_target_sources should be updated 272 271 Map<String, Object> paramsAnnotationsSources = new HashMap<String, Object>(); … … 274 273 paramsAnnotationsSources.put("sourceId", sourceID); 275 274 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); 277 281 } 278 282 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java
r3334 r3347 55 55 sourceInfo.setLink(TestBackendConstants._TEST_SOURCE_1_LINK); 56 56 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); 58 58 59 59 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 28 28 import eu.dasish.annotation.schema.AnnotationInfo; 29 29 import eu.dasish.annotation.schema.NewOrExistingSourceInfo; 30 import eu.dasish.annotation.schema.NewOrExistingSourceInfo; 30 31 import eu.dasish.annotation.schema.NewOrExistingSourceInfos; 32 import eu.dasish.annotation.schema.NewSourceInfo; 31 33 import eu.dasish.annotation.schema.ResourceREF; 32 34 import eu.dasish.annotation.schema.Source; … … 34 36 import java.sql.SQLException; 35 37 import java.util.ArrayList; 38 import java.util.HashMap; 36 39 import java.util.List; 40 import java.util.Map; 37 41 import org.jmock.Expectations; 38 42 import org.jmock.Mockery; … … 251 255 */ 252 256 @Test 253 @Ignore254 257 public void testAddAnnotationExistingSource() throws SQLException{ 255 258 System.out.println("test_addAnnotation with an existing source"); … … 259 262 assertEquals(null, annotationToAdd.getTimeStamp()); 260 263 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 261 275 mockery.checking(new Expectations() { 262 276 { 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)); 265 279 } 266 280 }); … … 268 282 Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5); 269 283 assertFalse(null==result.getURI()); 270 assertFalse(null==result.getTimeStamp()); 284 assertFalse(null==result.getTimeStamp()); 271 285 assertEquals(annotationToAdd.getBody().getAny().get(0), result.getBody().getAny().get(0)); 272 286 assertEquals(annotationToAdd.getHeadline(), result.getHeadline()); 273 287 assertEquals(String.valueOf(5), result.getOwner().getRef()); 274 288 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()); 276 295 } 277 296 … … 281 300 */ 282 301 @Test 283 @Ignore284 302 public void testAddAnnotationNewSource() throws SQLException{ 285 303 System.out.println("test_addAnnotation with a new source"); 286 304 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 294 329 295 330 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)); 303 334 } 304 335 }); 305 336 306 Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd NewSource, 5);337 Annotation result = jdbcAnnotationDao.addAnnotation(annotationToAdd, 5); 307 338 assertFalse(null==result.getURI()); 308 339 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()); 311 341 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()); 315 355 } 316 356 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java
r3346 r3347 27 27 import eu.dasish.annotation.schema.Source; 28 28 import eu.dasish.annotation.schema.SourceInfo; 29 import java.sql.SQLException; 29 30 import java.util.ArrayList; 30 31 import java.util.List; 31 32 import java.util.Map; 32 import java.util.UUID;33 33 import org.jmock.Expectations; 34 34 import org.jmock.Mockery; … … 50 50 "/spring-config/sourceDao.xml"}) 51 51 public class JdbcSourceDaoTest extends JdbcResourceDaoTest { 52 52 53 53 @Autowired 54 54 JdbcSourceDao jdbcSourceDao; … … 103 103 final Number internalVersionID = 1; 104 104 final VersionIdentifier externalVersionID = new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID); 105 105 106 106 mockery.checking(new Expectations() { 107 107 { … … 110 110 } 111 111 }); 112 112 113 113 Source result = jdbcSourceDao.getSource(internalID); 114 114 assertEquals(TestBackendConstants._TEST_SOURCE_1_EXT_ID, result.getURI()); … … 127 127 int result = jdbcSourceDao.deleteSourceVersionRows(internalID); 128 128 assertEquals(1, result); 129 129 130 130 Number internalIDNoExist = 5; 131 131 int resultTwo = jdbcSourceDao.deleteSourceVersionRows(internalIDNoExist); … … 150 150 oneOf(versionDao).retrieveVersionList(internalIDToBeDeleted); 151 151 will(returnValue(versions)); 152 152 153 153 oneOf(versionDao).deleteVersion(5); 154 154 will(returnValue(1)); // no other sources refer to this version # 5 155 155 } 156 156 }); 157 157 158 158 int resultTwo = jdbcSourceDao.deleteSource(internalIDToBeDeleted); 159 159 assertEquals(1, resultTwo); // the source will be deleted because it is not referred by any annotation … … 166 166 public void testAddSource() { 167 167 System.out.println("addSource"); 168 168 169 169 String link = "http://www.sagradafamilia.cat/"; 170 170 String version = null; 171 171 172 172 Source freshSource = new Source(); 173 173 freshSource.setLink(link); 174 174 freshSource.setVersion(version); 175 175 176 176 Source result = jdbcSourceDao.addSource(freshSource); 177 177 assertEquals(link, result.getLink()); … … 188 188 System.out.println("getSourceInfos"); 189 189 Number annotationID = 2; 190 190 191 191 mockery.checking(new Expectations() { 192 192 { 193 193 oneOf(versionDao).getExternalID(1); 194 194 will(returnValue(new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID))); 195 195 196 196 oneOf(versionDao).getExternalID(3); 197 197 will(returnValue(new VersionIdentifier(TestBackendConstants._TEST_VERSION_3_EXT_ID))); 198 198 } 199 199 }); 200 200 201 201 List<SourceInfo> result = jdbcSourceDao.getSourceInfos(annotationID); 202 202 assertEquals(2, result.size()); … … 207 207 assertEquals(TestBackendConstants._TEST_SOURCE_1_LINK, result.get(0).getLink()); 208 208 assertEquals(TestBackendConstants._TEST_SOURCE_2_LINK, result.get(1).getLink()); 209 209 210 210 } 211 211 … … 216 216 public void testContructNewOrExistingSourceInfo() { 217 217 System.out.println("contructNewOrExistingSourceInfo"); 218 218 219 219 List<SourceInfo> sourceInfoList = new ArrayList<SourceInfo>(); 220 220 221 221 SourceInfo sourceInfoOne = new SourceInfo(); 222 222 sourceInfoOne.setLink(TestBackendConstants._TEST_SOURCE_1_LINK); 223 223 sourceInfoOne.setRef(TestBackendConstants._TEST_SOURCE_1_EXT_ID); 224 224 sourceInfoOne.setRef(TestBackendConstants._TEST_VERSION_1_EXT_ID); 225 225 226 226 SourceInfo sourceInfoTwo = new SourceInfo(); 227 227 sourceInfoTwo.setLink(TestBackendConstants._TEST_SOURCE_2_LINK); 228 228 sourceInfoTwo.setRef(TestBackendConstants._TEST_SOURCE_2_EXT_ID); 229 229 sourceInfoTwo.setRef(TestBackendConstants._TEST_VERSION_3_EXT_ID); 230 230 231 231 sourceInfoList.add(sourceInfoOne); 232 232 sourceInfoList.add(sourceInfoTwo); 233 233 234 234 NewOrExistingSourceInfos result = jdbcSourceDao.contructNewOrExistingSourceInfo(sourceInfoList); 235 235 assertEquals(2, result.getTarget().size()); 236 236 assertEquals(sourceInfoOne, result.getTarget().get(0).getSource()); 237 237 assertEquals(sourceInfoTwo, result.getTarget().get(1).getSource()); 238 238 239 239 } 240 240 … … 248 248 public void testAddTargetSourcesOnExistingSource() { 249 249 System.out.println("addTargetSources : adding the old source"); 250 250 251 251 NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo(); 252 252 SourceInfo si = new SourceInfo(); … … 259 259 listnoesi.add(noesi); 260 260 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 /** 268 271 * Test of addTargetSources method, of class JdbcSourceDao. public 269 272 * Map<NewOrExistingSourceInfo, NewOrExistingSourceInfo> … … 272 275 */ 273 276 @Test 274 public void testAddTargetSourcesOnNewSource() {277 public void testAddTargetSourcesOnNewSource() { 275 278 System.out.println("addTargetSources : adding the new source"); 276 279 277 280 NewOrExistingSourceInfo noesi = new NewOrExistingSourceInfo(); 278 281 NewSourceInfo nsi = new NewSourceInfo(); … … 285 288 listnoesiTwo.add(noesi); 286 289 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 } 294 301 295 302 }
Note: See TracChangeset
for help on using the changeset viewer.