Project

General

Profile

« Previous | Next » 

Revision 9336

Added by Jing Tao about 9 years ago

Change the test method for the updateSystemMetadata method.

View differences:

test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
1239 1239
          String str2 = "object2";
1240 1240
          String str3 = "object3";
1241 1241
  
1242
          Date date = new Date();
1242 1243
          //insert test documents with a series id
1243 1244
          Session session = getCNSession();
1244 1245
          Identifier guid = new Identifier();
......
1277 1278
          //update system metadata sucessfully
1278 1279
          SystemMetadata sysmeta1c = new SystemMetadata();
1279 1280
          BeanUtils.copyProperties(sysmeta1c, sysmeta1);
1280
          version = version.add(BigInteger.ONE);
1281
          sysmeta1c.setSerialVersion(version);
1281
          sysmeta1c.setDateSysMetadataModified(date);
1282 1282
          CNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta1c);
1283 1283
          SystemMetadata metadata2 = CNodeService.getInstance(request).getSystemMetadata(session, seriesId);
1284 1284
          assertTrue(metadata2.getIdentifier().equals(guid));
1285 1285
          assertTrue(metadata2.getSeriesId().equals(seriesId));
1286 1286
          assertTrue(metadata2.getArchived().equals(true));
1287 1287
          assertTrue(metadata2.getChecksum().getValue().equals(metadata.getChecksum().getValue()));
1288
          assertTrue(metadata2.getDateSysMetadataModified().getTime() == date.getTime());
1288 1289
          
1289 1290
          SystemMetadata sysmeta2 = CNodeService.getInstance(request).getSystemMetadata(session, seriesId);
1290 1291
          version = sysmeta2.getSerialVersion();
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
2041 2041
        String str1 = "object1";
2042 2042
        String str2 = "object2";
2043 2043
        String str3 = "object3";
2044

  
2044
        
2045
        Date date = new Date();
2046
        Thread.sleep(2000);
2045 2047
        //insert test documents with a series id
2046 2048
        Session session = getTestSession();
2047 2049
        Identifier guid = new Identifier();
......
2063 2065
        assertTrue(metadata.getSize().equals(sysmeta.getSize()));
2064 2066
        System.out.println("the identifier is "+guid.getValue());
2065 2067
        
2066
        
2067
        
2068
        Date current = sysmeta.getDateSysMetadataModified();
2069
        //updating system metadata failed since the date doesn't match
2070
        sysmeta.setArchived(true);
2071
        sysmeta.setDateSysMetadataModified(date);
2072
        try {
2073
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2074
            fail("We shouldn't get there");
2075
        } catch (Exception e) {
2076
            assertTrue(e instanceof InvalidRequest);
2077
        }
2068 2078
        //update system metadata sucessfully
2069
        sysmeta.setArchived(true);
2079
        sysmeta.setDateSysMetadataModified(current);
2070 2080
        BigInteger serialVersion = metadata.getSerialVersion();
2071
        System.out.println("the current version is "+serialVersion.toString());
2072
        serialVersion = serialVersion.add(BigInteger.ONE);
2073
        System.out.println("the new version is "+serialVersion.toString());
2074
        sysmeta.setSerialVersion(serialVersion);
2081
        //System.out.println("the current version is "+serialVersion.toString());
2082
        //serialVersion = serialVersion.add(BigInteger.ONE);
2083
        //System.out.println("the new version is "+serialVersion.toString());
2084
        //sysmeta.setSerialVersion(serialVersion);
2075 2085
        MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2076 2086
        SystemMetadata metadata2 = MNodeService.getInstance(request).getSystemMetadata(session, seriesId);
2077 2087
        assertTrue(metadata2.getIdentifier().equals(guid));
2078 2088
        assertTrue(metadata2.getSeriesId().equals(seriesId));
2079 2089
        assertTrue(metadata2.getArchived().equals(true));
2080 2090
        assertTrue(metadata2.getChecksum().getValue().equals(metadata.getChecksum().getValue()));
2091
        assertTrue(metadata2.getDateSysMetadataModified().getTime() > current.getTime());
2081 2092
        
2082 2093
        Identifier newId = new Identifier();
2083 2094
        newId.setValue("newValue");
......
2128 2139
        } catch (Exception e) {
2129 2140
            assertTrue(e instanceof InvalidRequest);
2130 2141
        }
2131
}
2142
    }
2132 2143
    
2133 2144
    public void testUpdateObsoletesAndObsoletedBy() throws Exception {
2134 2145
        String str1 = "object1";

Also available in: Unified diff