001: /*
002: * Copyright 2007 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.repository.test;
017:
018: import org.outerj.daisy.repository.testsupport.AbstractDaisyTestCase;
019: import org.outerj.daisy.repository.*;
020: import org.outerj.daisy.repository.query.QueryManager;
021: import org.outerj.daisy.repository.schema.PartType;
022: import org.outerj.daisy.repository.schema.DocumentType;
023: import org.outerj.daisy.repository.schema.RepositorySchema;
024: import org.outerj.daisy.repository.schema.FieldType;
025: import org.outerj.daisy.repository.variant.Language;
026: import org.outerj.daisy.repository.user.Role;
027: import org.outerx.daisy.x10.SearchResultDocument;
028:
029: import java.util.Locale;
030:
031: /**
032: * Testcase for translation-management related functionality.
033: */
034: public abstract class AbstractTMTest extends AbstractDaisyTestCase {
035: protected boolean resetDataStores() {
036: return true;
037: }
038:
039: protected abstract RepositoryManager getRepositoryManager()
040: throws Exception;
041:
042: public void testTM() throws Exception {
043: RepositoryManager repositoryManager = getRepositoryManager();
044: Repository repository = repositoryManager
045: .getRepository(new Credentials("testuser", "testuser"));
046: repository.switchRole(Role.ADMINISTRATOR);
047:
048: //
049: // Create some languages
050: //
051: Language en = repository.getVariantManager().createLanguage(
052: "en");
053: en.save();
054:
055: Language nl = repository.getVariantManager().createLanguage(
056: "nl");
057: nl.save();
058:
059: Language fr = repository.getVariantManager().createLanguage(
060: "fr");
061: fr.save();
062:
063: Language it = repository.getVariantManager().createLanguage(
064: "it");
065: it.save();
066:
067: //
068: // Create some schema types
069: //
070: RepositorySchema repositorySchema = repository
071: .getRepositorySchema();
072:
073: PartType partType1 = repositorySchema.createPartType(
074: "partType1", "");
075: partType1.setDaisyHtml(true);
076: partType1.save();
077:
078: FieldType fieldType1 = repositorySchema.createFieldType(
079: "fieldType1", ValueType.STRING);
080: fieldType1.save();
081:
082: DocumentType documentType1 = repositorySchema
083: .createDocumentType("doctype1");
084: documentType1.addPartType(partType1, false);
085: documentType1.addFieldType(fieldType1, false);
086: documentType1.save();
087:
088: DocumentType documentType2 = repositorySchema
089: .createDocumentType("doctype2");
090: documentType2.addPartType(partType1, false);
091: documentType2.addFieldType(fieldType1, false);
092: documentType2.save();
093:
094: QueryManager qm = repository.getQueryManager();
095:
096: //
097: // test translation management document properties
098: //
099: {
100: // "en" is always used as the reference language version
101: //
102: // these version are created and after every stage, the calculated variant-level fields are checked
103: // note: change type does not influence the calculated fields, only the queries later on
104: // note: what is the effect of setting 'synced_with' on the reference variant?? (always null?)
105: //
106: // l v state synced_with => (fr)last_synced_with (fr)live_synced_with
107: // en V1 d -
108: // en V2 d -
109: // en V3 P -
110: // en V4 P -
111: // en V5 d -
112: //
113: // fr V1 d null null null
114: // fr V2 d null null null
115: // fr V3 d en:v3 null null
116: // fr V4 P en:v3 en:v3 en:v3
117: // fr V5 d en:v5 en:v5 en:v3
118: //
119: // then unpublish fr:v4
120: // fr V4 d en:v3 en:v5 null
121: // then publish fr:v5
122: // fr V5 P en:v5 en:v5 en:v5
123: // then republish fr:v4 (should not change last_ and live_synced_with
124: // fr V4 d en:v3 en:v5 en:v5
125:
126: byte[] part1Data = "<html><body><p>Hello this is the content of part1</p></body></html>"
127: .getBytes();
128:
129: Document enDoc = repository.createDocument(
130: "reference variant", documentType1.getId(), 1L, en
131: .getId());
132: enDoc.setNewVersionState(VersionState.DRAFT);
133: enDoc.setPart(partType1.getId(), "text/xml", part1Data);
134: enDoc.save(); // v1
135: assertEquals(1L, enDoc.getLastVersionId());
136: enDoc.setPart(partType1.getId(), "text/xml", part1Data);
137: enDoc.save(); // v2
138: assertEquals(2L, enDoc.getLastVersionId());
139: enDoc.setNewVersionState(VersionState.PUBLISH);
140: enDoc.setPart(partType1.getId(), "text/xml", part1Data);
141: enDoc.save(); // v3
142: assertEquals(3L, enDoc.getLastVersionId());
143: enDoc.setPart(partType1.getId(), "text/xml", part1Data);
144: enDoc.save(); // v4
145: assertEquals(4L, enDoc.getLastVersionId());
146: enDoc.setNewVersionState(VersionState.PUBLISH);
147: enDoc.setPart(partType1.getId(), "text/xml", part1Data);
148: enDoc.save(); // v5
149: assertEquals(5L, enDoc.getLastVersionId());
150:
151: Document frDoc = repository.createVariant(enDoc.getId(),
152: enDoc.getBranchId(), enDoc.getLanguageId(), enDoc
153: .getLastVersionId(), enDoc.getBranchId(),
154: fr.getId(), true);
155: frDoc.getLastVersion().setState(VersionState.DRAFT);
156: frDoc.getLastVersion().save();
157: frDoc.setName("translated variant"); // createVariant = v1, changing the name = v2
158: frDoc.setNewVersionState(VersionState.DRAFT);
159: frDoc.save(); // v2
160: assertEquals(2L, frDoc.getLastVersionId());
161:
162: VersionKey en_v3 = new VersionKey(enDoc.getId(), enDoc
163: .getBranchId(), enDoc.getLanguageId(), 3L);
164: VersionKey en_v4 = new VersionKey(enDoc.getId(), enDoc
165: .getBranchId(), enDoc.getLanguageId(), 4L);
166: VersionKey en_v5 = new VersionKey(enDoc.getId(), enDoc
167: .getBranchId(), enDoc.getLanguageId(), 5L);
168: VersionKey en_v6 = new VersionKey(enDoc.getId(), enDoc
169: .getBranchId(), enDoc.getLanguageId(), 6L);
170:
171: frDoc.setPart(partType1.getId(), "text/xml", part1Data);
172: frDoc.setNewSyncedWith(en.getId(), 3L);
173: frDoc.save(); // v3;
174: assertEquals(3L, frDoc.getLastVersionId());
175: // should work without and with refetching the document
176: // frDoc = repository.getDocument(frDoc.getId(), 1L, fr.getId(), true);
177: assertEquals(en_v3, frDoc.getLastVersion().getSyncedWith());
178: // note: not really relevant in the context of translation management, but it does not hurt
179: assertNull(
180: "livesyncedwithversion should be null when document has no published versions but was"
181: + frDoc.getLiveVersion(), frDoc
182: .getLiveVersion());
183:
184: // try unsetting synced with
185: {
186: Version frDocLastVersion = frDoc.getLastVersion();
187: VersionKey currentSyncedWith = frDocLastVersion
188: .getSyncedWith();
189: frDocLastVersion.setSyncedWith(-1, -1);
190: assertNull(frDocLastVersion.getSyncedWith());
191: frDocLastVersion.save();
192: frDocLastVersion = frDoc.getLastVersion();
193: assertNull(frDocLastVersion.getSyncedWith());
194: frDocLastVersion.setSyncedWith(currentSyncedWith
195: .getLanguageId(), currentSyncedWith
196: .getVersionId());
197: frDocLastVersion.save();
198: }
199:
200: frDoc.setPart(partType1.getId(), "text/xml", part1Data);
201: frDoc.setNewVersionState(VersionState.PUBLISH);
202: frDoc.save(); // v4;
203: assertEquals(4L, frDoc.getLastVersionId());
204: assertEquals(4L, frDoc.getLiveVersionId());
205: assertEquals(en_v3, frDoc.getLastVersion().getSyncedWith());
206: assertEquals(en_v3, frDoc.getLiveVersion().getSyncedWith());
207:
208: frDoc.setPart(partType1.getId(), "text/xml", part1Data);
209: frDoc.setNewVersionState(VersionState.DRAFT);
210: frDoc.setNewSyncedWith(en.getId(), 5L);
211: frDoc.save(); // v5;
212: assertEquals(5L, frDoc.getLastVersionId());
213: assertEquals(4L, frDoc.getLiveVersionId());
214: assertEquals(en_v5, frDoc.getLastVersion().getSyncedWith());
215: assertEquals(4L, frDoc.getLiveVersion().getId());
216: assertEquals(en_v3, frDoc.getLiveVersion().getSyncedWith());
217:
218: // now 4 gets unpublished (no live version anymore)
219: Version frVersion4 = frDoc.getVersion(4);
220: frVersion4.setState(VersionState.DRAFT);
221: frVersion4.save();
222: // need to refetch the document because live version is not updated. TODO: fix this :)
223: frDoc = repository.getDocument(frDoc.getId(), frDoc
224: .getBranchId(), frDoc.getLanguageId(), true);
225: assertEquals(-1L, frDoc.getLiveVersionId());
226: assertEquals(en_v5, frDoc.getLastVersion().getSyncedWith());
227: assertNull(
228: "live version should be null when document has no published versions but was"
229: + frDoc.getLiveVersion(), frDoc
230: .getLiveVersion());
231:
232: // now v5 gets published (live = v5)
233: Version frVersion5 = frDoc.getVersion(5);
234: frVersion5.setState(VersionState.PUBLISH);
235: frVersion5.save();
236: // need to refetch the document because live version is not updated. TODO: fix this :)
237: frDoc = repository.getDocument(frDoc.getId(), frDoc
238: .getBranchId(), frDoc.getLanguageId(), true);
239: assertEquals(5L, frDoc.getLiveVersionId());
240: assertEquals(en_v5, frDoc.getLastVersion().getSyncedWith());
241: assertEquals(en_v5, frDoc.getLiveVersion().getSyncedWith());
242:
243: try {
244: frDoc.setNewSyncedWith(en.getId(), 6L);
245: frDoc.setPart(partType1.getId(), "text/xml", part1Data); // make sure a new version would be created
246: frDoc.save();
247: fail("setting syncedWith to non-existing version should throw an exception, but it did not");
248: } catch (Exception e) {
249: //intentionally empty
250: }
251:
252: try {
253: frVersion5.setSyncedWith(en.getId(), 6L);
254: frVersion5.save();
255: fail("setting sycnedwith to non-existing version should throw an exception, but it did not");
256: } catch (Exception e) {
257: //intentionally empty
258: }
259:
260: // after deleting the reference variant, referenceLanguageId should be set to null
261: repository.deleteVariant(enDoc.getVariantKey());
262: assertEquals(
263: "The reference language should be -1 after deleting the reference variant",
264: -1, frDoc.getReferenceLanguageId());
265:
266: // need to refetch the document because versions objects are not updated.
267: frDoc = repository.getDocument(frDoc.getId(), frDoc
268: .getBranchId(), frDoc.getLanguageId(), true);
269: for (Version version : frDoc.getVersions().getArray()) {
270: assertNull(
271: "After a variant is deleted, the syncedWith-fields can no longer refer to that language ("
272: + en.getName() + ")", version
273: .getSyncedWith());
274: }
275: }
276:
277: //
278: // Test translation management queries
279: //
280: {
281: Document document = repository.createDocument("doc",
282: "doctype2", "main", "en");
283: document.setReferenceLanguageId(en.getId());
284: document.setField("fieldType1", "en value 1");
285: document.setNewVersionState(VersionState.DRAFT);
286: document.save();
287:
288: document.setField("fieldType1", "en value 2");
289: document.setNewVersionState(VersionState.DRAFT);
290: document.save();
291:
292: // Make fr variant, synced with first version
293: document = repository.createVariant(document.getId(),
294: "main", "en", -1, "main", "fr", false);
295: document.setField("fieldType1", "fr value 1");
296: document.setNewSyncedWith("en", 1);
297: document.setNewVersionState(VersionState.DRAFT);
298: document.save();
299:
300: // Make nl variant, synced with second version
301: document = repository.createVariant(document.getId(),
302: "main", "en", -1, "main", "nl", false);
303: document.setField("fieldType1", "nl value 1");
304: document.setNewSyncedWith("en", 2);
305: document.setNewVersionState(VersionState.DRAFT);
306: document.save();
307:
308: // Make 'it' variant, synced with nothing
309: document = repository.createVariant(document.getId(),
310: "main", "en", -1, "main", "it", false);
311: document.setField("fieldType1", "it value 1");
312: document.setNewVersionState(VersionState.DRAFT);
313: document.save();
314:
315: String defaultConditions = "documentType = 'doctype2' and referenceLanguage is not null and languageId != referenceLanguageId";
316: String lastOption = " option search_last_version = 'true'";
317:
318: // Test the fr translation is out of sync, the nl one in sync.
319: SearchResultDocument result = qm.performQuery(
320: "select id, language where LangNotInSync() and "
321: + defaultConditions + " order by language "
322: + lastOption, Locale.US);
323: System.out.println(result);
324: assertEquals(2, result.getSearchResult().getRows()
325: .sizeOfRowArray());
326: assertEquals("fr", result.getSearchResult().getRows()
327: .getRowArray(0).getValueArray(1));
328: assertEquals("it", result.getSearchResult().getRows()
329: .getRowArray(1).getValueArray(1));
330:
331: result = qm
332: .performQuery(
333: "select id, language where LangInSync() and "
334: + defaultConditions + lastOption,
335: Locale.US);
336: assertEquals(1, result.getSearchResult().getRows()
337: .sizeOfRowArray());
338: assertEquals("nl", result.getSearchResult().getRows()
339: .getRowArray(0).getValueArray(1));
340:
341: // Since there are no live versions yet, there is no liveMajorChangeId so we can't be in or not in sync with
342: result = qm
343: .performQuery(
344: "select id, language where LangNotInSync('live') and "
345: + defaultConditions + lastOption,
346: Locale.US);
347: assertEquals(1, result.getSearchResult().getRows()
348: .sizeOfRowArray());
349: assertEquals("it", result.getSearchResult().getRows()
350: .getRowArray(0).getValueArray(1));
351:
352: result = qm
353: .performQuery(
354: "select id, language where LangInSync('live') and "
355: + defaultConditions + lastOption,
356: Locale.US);
357: assertEquals(0, result.getSearchResult().getRows()
358: .sizeOfRowArray());
359:
360: // Test reverse search
361: result = qm
362: .performQuery(
363: "select id, language where ReverseLangNotInSync('fr', 'last') and documentType = 'doctype2' "
364: + lastOption, Locale.US);
365: assertEquals(1, result.getSearchResult().getRows()
366: .sizeOfRowArray());
367: assertEquals("en", result.getSearchResult().getRows()
368: .getRowArray(0).getValueArray(1));
369:
370: result = qm
371: .performQuery(
372: "select id, language where language = 'en' and ReverseLangNotInSync('fr', 'live') and documentType = 'doctype2' "
373: + lastOption, Locale.US);
374: // there is no live version of fr, so it is not in sync with the en language
375: assertEquals(1, result.getSearchResult().getRows()
376: .sizeOfRowArray());
377: assertEquals("en", result.getSearchResult().getRows()
378: .getRowArray(0).getValueArray(1));
379:
380: result = qm
381: .performQuery(
382: "select id, language where ReverseLangInSync('fr', 'last') and documentType = 'doctype2' "
383: + lastOption, Locale.US);
384: assertEquals(0, result.getSearchResult().getRows()
385: .sizeOfRowArray());
386:
387: result = qm
388: .performQuery(
389: "select id, language where ReverseLangInSync('nl', 'last') and documentType = 'doctype2' "
390: + lastOption, Locale.US);
391: assertEquals(1, result.getSearchResult().getRows()
392: .sizeOfRowArray());
393: assertEquals("en", result.getSearchResult().getRows()
394: .getRowArray(0).getValueArray(1));
395:
396: result = qm
397: .performQuery(
398: "select id, language where ReverseLangNotInSync('nl', 'last') and documentType = 'doctype2' "
399: + lastOption, Locale.US);
400: assertEquals(0, result.getSearchResult().getRows()
401: .sizeOfRowArray());
402:
403: result = qm
404: .performQuery(
405: "select id, language where ReverseLangNotInSync('default', 'last') and documentType = 'doctype2' "
406: + lastOption, Locale.US);
407: assertEquals(0, result.getSearchResult().getRows()
408: .sizeOfRowArray());
409:
410: result = qm
411: .performQuery(
412: "select id, language where ReverseLangNotInSync('fr', 'last') and documentType = 'doctype2' "
413: + lastOption, Locale.US);
414: assertEquals(1, result.getSearchResult().getRows()
415: .sizeOfRowArray());
416:
417: result = qm
418: .performQuery(
419: "select id, language where language = 'en' and ReverseLangNotInSync('fr', 'live') and documentType = 'doctype2' "
420: + lastOption, Locale.US);
421: assertEquals(1, result.getSearchResult().getRows()
422: .sizeOfRowArray()); // there is no fr live version, this is consider not-in-sync
423:
424: result = qm
425: .performQuery(
426: "select id, language where language = 'en' and ReverseLangNotInSync('it', 'last') and documentType = 'doctype2' "
427: + lastOption, Locale.US);
428: assertEquals(1, result.getSearchResult().getRows()
429: .sizeOfRowArray());
430:
431: result = qm
432: .performQuery(
433: "select id, language where language = 'en' and ReverseLangInSync('it', 'last') and documentType = 'doctype2' "
434: + lastOption, Locale.US);
435: assertEquals(0, result.getSearchResult().getRows()
436: .sizeOfRowArray());
437:
438: // Create a new nl version, do not set synced with
439: document = repository.getDocument(document.getId(), "main",
440: "nl", true);
441: document.setField("fieldType1", "nl value 2");
442: document.setNewVersionState(VersionState.DRAFT);
443: document.save();
444:
445: // synced with pointer is null for last version, which means we are not in sync
446: result = qm
447: .performQuery(
448: "select id, language where LangInSync() and "
449: + defaultConditions + lastOption,
450: Locale.US);
451: assertEquals(0, result.getSearchResult().getRows()
452: .sizeOfRowArray());
453: }
454:
455: //
456: // TM queries: test behavior in case major change version is not defined
457: //
458: {
459: DocumentCollection collection = repository
460: .getCollectionManager().createCollection("test3");
461: collection.save();
462:
463: Document document = repository.createDocument("doc",
464: "doctype2", "main", "en");
465: document.addToCollection(collection);
466: document.setReferenceLanguageId(en.getId());
467: document.setField("fieldType1", "en value 1");
468: document.setNewChangeType(ChangeType.MINOR);
469: document.setNewVersionState(VersionState.DRAFT);
470: document.save();
471:
472: document.setField("fieldType1", "en value 2");
473: document.setNewChangeType(ChangeType.MINOR);
474: document.setNewVersionState(VersionState.PUBLISH);
475: document.save();
476:
477: // Make fr variant, synced with first version
478: document = repository.createVariant(document.getId(),
479: "main", "en", -1, "main", "fr", false);
480: document.addToCollection(collection);
481: document.setField("fieldType1", "fr value 1");
482: document.setNewSyncedWith("en", 1);
483: document.setNewVersionState(VersionState.PUBLISH);
484:
485: // Make another fr variant, not synced at all
486: document = repository.createVariant(document.getId(),
487: "main", "en", -1, "main", "fr", false);
488: document.addToCollection(collection);
489: document.setField("fieldType1", "notsynced");
490: document.setNewVersionState(VersionState.PUBLISH);
491:
492: document.save();
493:
494: SearchResultDocument result = qm
495: .performQuery(
496: "select id, language where language = 'fr' and LangInSync() and InCollection('test3')",
497: Locale.US);
498: assertEquals(0, result.getSearchResult().getRows()
499: .sizeOfRowArray());
500:
501: result = qm
502: .performQuery(
503: "select id, language where language = 'fr' and LangInSync('live') and InCollection('test3')",
504: Locale.US);
505: assertEquals(0, result.getSearchResult().getRows()
506: .sizeOfRowArray());
507:
508: result = qm
509: .performQuery(
510: "select id, language, $fieldType1 where language = 'fr' and LangNotInSync() and InCollection('test3')",
511: Locale.US);
512: assertEquals(1, result.getSearchResult().getRows()
513: .sizeOfRowArray());
514: assertEquals("notsynced", result.getSearchResult()
515: .getRows().getRowArray(0).getValueArray(2));
516:
517: result = qm
518: .performQuery(
519: "select id, language, $fieldType1 where language = 'fr' and LangNotInSync('live') and InCollection('test3')",
520: Locale.US);
521: assertEquals(1, result.getSearchResult().getRows()
522: .sizeOfRowArray());
523: assertEquals("notsynced", result.getSearchResult()
524: .getRows().getRowArray(0).getValueArray(2));
525:
526: result = qm
527: .performQuery(
528: "select id, language where language = 'en' and ReverseLangInSync('fr') and InCollection('test3')",
529: Locale.US);
530: assertEquals(0, result.getSearchResult().getRows()
531: .sizeOfRowArray());
532:
533: result = qm
534: .performQuery(
535: "select id, language where language = 'en' and ReverseLangNotInSync('fr') and InCollection('test3')",
536: Locale.US);
537: assertEquals(0, result.getSearchResult().getRows()
538: .sizeOfRowArray());
539:
540: result = qm
541: .performQuery(
542: "select id, language where language = 'en' and ReverseLangInSync('fr', 'live') and InCollection('test3')",
543: Locale.US);
544: assertEquals(0, result.getSearchResult().getRows()
545: .sizeOfRowArray());
546:
547: result = qm
548: .performQuery(
549: "select id, language where language = 'en' and ReverseLangNotInSync('fr', 'live') and InCollection('test3')",
550: Locale.US);
551: assertEquals(0, result.getSearchResult().getRows()
552: .sizeOfRowArray());
553: }
554:
555: // Test the change-type and change-comment fields
556: {
557: // situations tested:
558: // v1 state v1 c-type v2 state v2 c-type ||| lastMajorCVersion liveMajorCVersion
559: // P M P M 2 2
560: // P M P m 1 1
561: // P M D M 2 1
562: // P M D m 1 1
563: // P m P M 2 2
564: // P m P m -1 -1
565: // P m D M 2 -1
566: // P m D m -1 -1
567: // D M P M 2 2
568: // D M P m 1 1
569: // D M D M 2 -1
570: // D M D m 1 -1
571: // D m P M 2 2
572: // D m P m -1 -1
573: // D m D M 2 -1
574: // D m D m -1 -1
575:
576: Document document = repository.createDocument("doc",
577: "doctype2", "main", "en");
578: document.setField("fieldType1", "version 1");
579: document.setNewChangeComment("comment for version 1");
580: document.save();
581:
582: assertEquals("New versions default to change type 'major'",
583: ChangeType.MAJOR, document.getLastVersion()
584: .getChangeType());
585:
586: document.setField("fieldType1", "version 2");
587: document.setNewChangeComment("comment for version 2");
588: document.save();
589:
590: VersionState v1State[] = new VersionState[16];
591: VersionState v2State[] = new VersionState[16];
592: ChangeType v1CType[] = new ChangeType[16];
593: ChangeType v2CType[] = new ChangeType[16];
594:
595: int[] lastMCVersion = new int[16];
596: for (int i = 0; i < 16; i++) {
597: v1State[i] = (i / 8) % 2 == 0 ? VersionState.PUBLISH
598: : VersionState.DRAFT;
599: v1CType[i] = (i / 4) % 2 == 0 ? ChangeType.MAJOR
600: : ChangeType.MINOR;
601: v2State[i] = (i / 2) % 2 == 0 ? VersionState.PUBLISH
602: : VersionState.DRAFT;
603: v2CType[i] = (i / 1) % 2 == 0 ? ChangeType.MAJOR
604: : ChangeType.MINOR;
605:
606: lastMCVersion[i] = (i / 1) % 2 == 0 ? 2
607: : (i / 4) % 2 == 0 ? 1 : -1;
608: }
609: int[] liveMCVersion = new int[] { 2, 1, 1, 1, 2, -1, -1,
610: -1, 2, 1, -1, -1, 2, -1, -1, -1 };
611:
612: for (int i = 0; i < 16; i++) {
613: String id = String.format("v1: %s %s v2: %s %s ",
614: v1State[i], v1CType[i], v2State[i], v2CType[i]);
615: Version v1 = document.getVersion(1);
616: v1.setState(v1State[i]);
617: v1.setChangeType(v1CType[i]);
618: v1.save();
619: Version v2 = document.getVersion(2);
620: v2.setState(v2State[i]);
621: v2.setChangeType(v2CType[i]);
622: v2.save();
623: document = repository.getDocument(document.getId(),
624: "main", "en", true);
625: assertEquals(id + " last major change version",
626: lastMCVersion[i], document
627: .getLastMajorChangeVersionId());
628: assertEquals(id + " live major change version",
629: liveMCVersion[i], document
630: .getLiveMajorChangeVersionId());
631: }
632: }
633: }
634: }
|