Project

General

Profile

« Previous | Next » 

Revision 9281

Added by Jing Tao over 9 years ago

Increase serial version during the test of updateSystemMetadata method.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
2051 2051
        assertTrue(metadata.getArchived().equals(false));
2052 2052
        System.out.println("the checksum from request is "+metadata.getChecksum().getValue());
2053 2053
        assertTrue(metadata.getSize().equals(sysmeta.getSize()));
2054
        System.out.println("the identifier is "+guid.getValue());
2054 2055
        
2056
        
2057
        
2055 2058
        //update system metadata sucessfully
2056
        metadata.setArchived(true);
2057
        MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2059
        sysmeta.setArchived(true);
2060
        BigInteger serialVersion = metadata.getSerialVersion();
2061
        System.out.println("the current version is "+serialVersion.toString());
2062
        serialVersion = serialVersion.add(BigInteger.ONE);
2063
        System.out.println("the new version is "+serialVersion.toString());
2064
        sysmeta.setSerialVersion(serialVersion);
2065
        MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2058 2066
        SystemMetadata metadata2 = MNodeService.getInstance(request).getSystemMetadata(session, seriesId);
2059 2067
        assertTrue(metadata2.getIdentifier().equals(guid));
2060 2068
        assertTrue(metadata2.getSeriesId().equals(seriesId));
......
2063 2071
        
2064 2072
        Identifier newId = new Identifier();
2065 2073
        newId.setValue("newValue");
2066
        metadata.setIdentifier(newId);
2074
        sysmeta.setIdentifier(newId);
2075
        serialVersion = metadata.getSerialVersion();
2076
        serialVersion = serialVersion.add(BigInteger.ONE);
2077
        sysmeta.setSerialVersion(serialVersion);
2067 2078
        try {
2068
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2079
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2069 2080
            fail("We shouldn't get there");
2070 2081
        } catch (Exception e) {
2071 2082
            assertTrue(e instanceof InvalidRequest);
2072 2083
        }
2073 2084
        
2074 2085
        newId.setValue("newValue");
2075
        metadata.setSeriesId(newId);
2086
        sysmeta.setSeriesId(newId);
2076 2087
        try {
2077
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2088
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2078 2089
            fail("We shouldn't get there");
2079 2090
        } catch (Exception e) {
2080 2091
            assertTrue(e instanceof InvalidRequest);
2081 2092
        }
2082 2093
        
2083 2094
        Date newDate = new Date();
2084
        metadata.setDateUploaded(newDate);
2095
        sysmeta.setDateUploaded(newDate);
2085 2096
        try {
2086
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2097
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2087 2098
            fail("We shouldn't get there");
2088 2099
        } catch (Exception e) {
2089 2100
            assertTrue(e instanceof InvalidRequest);
......
2091 2102
        
2092 2103
        Checksum checkSum = new Checksum();
2093 2104
        checkSum.setValue("12345");
2094
        metadata.setChecksum(checkSum);
2105
        sysmeta.setChecksum(checkSum);
2095 2106
        try {
2096
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2107
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2097 2108
            fail("We shouldn't get there");
2098 2109
        } catch (Exception e) {
2099 2110
            assertTrue(e instanceof InvalidRequest);
2100 2111
        }
2101 2112
        
2102 2113
        BigInteger size = new BigInteger("4000");
2103
        metadata.setSize(size);
2114
        sysmeta.setSize(size);
2104 2115
        try {
2105
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, metadata);
2116
            MNodeService.getInstance(request).updateSystemMetadata(session, guid, sysmeta);
2106 2117
            fail("We shouldn't get there");
2107 2118
        } catch (Exception e) {
2108 2119
            assertTrue(e instanceof InvalidRequest);
......
2147 2158
        allow.addSubject(subject);
2148 2159
        accessPolicy.addAllow(allow);
2149 2160
        sysmeta1.setAccessPolicy(accessPolicy);
2161
        BigInteger serialVersion = metadata.getSerialVersion();
2162
        serialVersion = serialVersion.add(BigInteger.ONE);
2163
        sysmeta1.setSerialVersion(serialVersion);
2150 2164
        MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1);
2151 2165
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid1);
2152 2166
        assertTrue(metadata.getIdentifier().equals(guid1));
......
2158 2172
        assertTrue(isAuthorized);
2159 2173
        
2160 2174
        sysmeta2.setAccessPolicy(accessPolicy);
2175
        serialVersion = metadata.getSerialVersion();
2176
        serialVersion = serialVersion.add(BigInteger.ONE);
2177
        sysmeta2.setSerialVersion(serialVersion);
2161 2178
        MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2);
2162 2179
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid2);
2163 2180
        assertTrue(metadata.getIdentifier().equals(guid2));
......
2171 2188
        
2172 2189
        //update obsolets and obsoletedBy sucessfully - set p2 obsoletes p1
2173 2190
        sysmeta1.setObsoletedBy(guid2);
2191
        serialVersion = metadata.getSerialVersion();
2192
        serialVersion = serialVersion.add(BigInteger.ONE);
2193
        sysmeta1.setSerialVersion(serialVersion);
2174 2194
        MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1);
2175 2195
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid1);
2176 2196
        assertTrue(metadata.getIdentifier().equals(guid1));
......
2179 2199
        assertTrue(metadata.getChecksum().getValue().equals(sysmeta1.getChecksum().getValue()));
2180 2200
        
2181 2201
        sysmeta2.setObsoletes(guid1);
2202
        serialVersion = metadata.getSerialVersion();
2203
        serialVersion = serialVersion.add(BigInteger.ONE);
2204
        sysmeta2.setSerialVersion(serialVersion);
2182 2205
        MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2);
2183 2206
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid2);
2184 2207
        assertTrue(metadata.getIdentifier().equals(guid2));
......
2191 2214
        
2192 2215
        //update obsolets and obsoletedBy sucessfully - set p1 obsoletedBy p2
2193 2216
        sysmeta1.setObsoletedBy(guid2);
2217
        serialVersion = metadata.getSerialVersion();
2218
        serialVersion = serialVersion.add(BigInteger.ONE);
2219
        sysmeta1.setSerialVersion(serialVersion);
2194 2220
        MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1);
2195 2221
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid1);
2196 2222
        assertTrue(metadata.getIdentifier().equals(guid1));
......
2199 2225
        assertTrue(metadata.getChecksum().getValue().equals(sysmeta1.getChecksum().getValue()));
2200 2226
        
2201 2227
        sysmeta2.setObsoletes(guid1);
2228
        serialVersion = metadata.getSerialVersion();
2229
        serialVersion = serialVersion.add(BigInteger.ONE);
2230
        sysmeta2.setSerialVersion(serialVersion);
2202 2231
        MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2);
2203 2232
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid2);
2204 2233
        assertTrue(metadata.getIdentifier().equals(guid2));
......
2214 2243
        Identifier newId = new Identifier();
2215 2244
        newId.setValue("newValue");
2216 2245
        sysmeta1.setObsoletedBy(newId);
2246
        serialVersion = metadata.getSerialVersion();
2247
        serialVersion = serialVersion.add(BigInteger.ONE);
2248
        sysmeta1.setSerialVersion(serialVersion);
2217 2249
        try {
2218 2250
            MNodeService.getInstance(request).updateSystemMetadata(session, guid1, sysmeta1);
2219 2251
            fail("We shouldn't get there");
......
2223 2255
        }
2224 2256
       
2225 2257
        sysmeta2.setObsoletes(newId);
2258
        serialVersion = metadata.getSerialVersion();
2259
        serialVersion = serialVersion.add(BigInteger.ONE);
2260
        sysmeta2.setSerialVersion(serialVersion);
2226 2261
        try {
2227 2262
            MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2);
2228 2263
            fail("We shouldn't get there");
......
2249 2284
        
2250 2285
        //Setting p5 obosletes p1 fails since p2 already obsoletes p1
2251 2286
        sysmeta5.setObsoletes(guid1);
2287
        serialVersion = metadata.getSerialVersion();
2288
        serialVersion = serialVersion.add(BigInteger.ONE);
2289
        sysmeta5.setSerialVersion(serialVersion);
2252 2290
        try {
2253 2291
            MNodeService.getInstance(request).updateSystemMetadata(session, guid5, sysmeta5);
2254 2292
            fail("We shouldn't get there");
......
2287 2325
        //Setting p2 obsoletedBy p5 succeeds since the obosoletedBy of p2 is null and p5 doesn't obsolete anything
2288 2326
        sysmeta2.setObsoletes(guid1);
2289 2327
        sysmeta2.setObsoletedBy(guid5);
2328
        serialVersion = sysmeta2.getSerialVersion();
2329
        serialVersion = serialVersion.add(BigInteger.ONE);
2330
        sysmeta2.setSerialVersion(serialVersion);
2290 2331
        MNodeService.getInstance(request).updateSystemMetadata(session, guid2, sysmeta2);
2291 2332
        metadata = MNodeService.getInstance(request).getSystemMetadata(session, guid2);
2292 2333
        assertTrue(metadata.getIdentifier().equals(guid2));

Also available in: Unified diff