Project

General

Profile

« Previous | Next » 

Revision 6338

Added by Chris Jones over 13 years ago

Test that the obsoletes and derivedFrom system metadata fields were set correctly.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
25 25

  
26 26
package edu.ucsb.nceas.metacat.dataone;
27 27

  
28
import static org.junit.Assert.assertTrue;
29

  
28 30
import java.io.ByteArrayInputStream;
29 31
import java.io.InputStream;
30 32
import java.io.UnsupportedEncodingException;
......
397 399
	    newPid.setValue("testUpdate." + System.currentTimeMillis());
398 400
	    Identifier pid = 
399 401
	    	MNodeService.getInstance().create(session, guid, object, sysmeta);
400
	    // TODO: before update(), modify the system metadata
401
	    
402
      
403
	    SystemMetadata newSysMeta = 
404
	    	MNodeService.getInstance().getSystemMetadata(session, pid);
405
      
406
      // update the obsoletesList
407
      newSysMeta.addObsolete(pid);
408
      
409
      // update the derivedFrom list
410
      newSysMeta.addDerivedFrom(pid);
411
      
412
	    // do the update
402 413
	    Identifier updatedPid = 
403
	    	MNodeService.getInstance().update(session, pid, object, newPid, sysmeta);
414
	    	MNodeService.getInstance().update(session, pid, object, newPid, newSysMeta);
415
      
416
	    // get the updated system metadata
417
      SystemMetadata updatedSysMeta = 
418
      	MNodeService.getInstance().getSystemMetadata(session, updatedPid);
419

  
404 420
	    assertEquals(updatedPid.getValue(), newPid.getValue());
421
      assertTrue(updatedSysMeta.getObsolete(0).getValue().equals(pid));
422
      assertTrue(updatedSysMeta.getDerivedFrom(0).getValue().equals(pid));	      
405 423
	    
406 424
    } catch (UnsupportedEncodingException e) {
407 425
	    e.printStackTrace();

Also available in: Unified diff