Project

General

Profile

« Previous | Next » 

Revision 9201

Added by Jing Tao over 9 years ago

Add the code to test scenario that a user tries to update an archived object.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
482 482
        MNodeService.getInstance(request).create(session, guid, object, sysmeta);
483 483
      
484 484
      SystemMetadata newSysMeta = createSystemMetadata(newPid, session.getSubject(), object);
485
            
485
      newSysMeta.setArchived(true);
486 486
      // do the update
487 487
      Identifier updatedPid = 
488 488
        MNodeService.getInstance(request).update(session, pid, object, newPid, newSysMeta);
......
492 492
        MNodeService.getInstance(request).getSystemMetadata(session, updatedPid);
493 493

  
494 494
      assertEquals(updatedPid.getValue(), newPid.getValue());
495
//      assertTrue(updatedSysMeta.getObsolete(0).getValue().equals(pid.getValue()));
496
//      assertTrue(updatedSysMeta.getDerivedFrom(0).getValue().equals(pid.getValue()));        
495
      //assertTrue(updatedSysMeta.getObsolete(0).getValue().equals(pid.getValue()));
496
      //assertTrue(updatedSysMeta.getDerivedFrom(0).getValue().equals(pid.getValue())); 
497 497
      
498
      //try to update an archived object and need to get an exception
499
      Identifier newPid2 = new Identifier();
500
      newPid2.setValue("testUpdate." + (System.currentTimeMillis() + 2)); // ensure it is different from original
501
      SystemMetadata newSysMeta2 = createSystemMetadata(newPid2, session.getSubject(), object);
502
      try {
503
           updatedPid = 
504
                  MNodeService.getInstance(request).update(session, newPid, object, newPid2, newSysMeta2);
505
           fail("update an archived object should get an invalid request exception");
506
      } catch (Exception ee) {
507
          assertTrue( ee instanceof InvalidRequest);
508
      }
498 509
    } catch (UnsupportedEncodingException e) {
499 510
      e.printStackTrace();
500 511
      fail("Unexpected error: " + e.getMessage());

Also available in: Unified diff