public void mergeChangedTextFlow() {
// set up HDocument with a text flow
HDocument to = new HDocument();
int originalTFRevision = 1;
to.setRevision(originalTFRevision);
HTextFlow originalTF = new HTextFlow(to, "id", "original text");
originalTF.setRevision(originalTFRevision);
// target locales that will have new, fuzzy and approved targets
HLocale newLoc, fuzzyLoc, apprLoc;
newLoc = new HLocale(LocaleId.DE);
fuzzyLoc = new HLocale(LocaleId.FR);
apprLoc = new HLocale(LocaleId.ES);
// Target Locale ids
Long newLocId = 1L, fuzzyLocId = 2L, apprLocId = 3L;
HTextFlowTarget newTarg, fuzzyTarg, apprTarg;
newTarg = new HTextFlowTarget(originalTF, newLoc);
fuzzyTarg = new HTextFlowTarget(originalTF, fuzzyLoc);
apprTarg = new HTextFlowTarget(originalTF, apprLoc);
int newTargVersionBefore = 1;
int fuzzyTargVersionBefore = 1;
int apprTargVersionBefore = 1;
newTarg.setVersionNum(newTargVersionBefore);
fuzzyTarg.setVersionNum(fuzzyTargVersionBefore);
apprTarg.setVersionNum(apprTargVersionBefore);
newTarg.setState(ContentState.New);
fuzzyTarg.setState(ContentState.NeedReview);
apprTarg.setState(ContentState.Approved);
originalTF.getTargets().put(newLocId, newTarg);
originalTF.getTargets().put(fuzzyLocId, fuzzyTarg);
originalTF.getTargets().put(apprLocId, apprTarg);
to.getAllTextFlows().put("id", originalTF);
// set up a textflow with the same id and different content
TextFlow changedTF =
new TextFlow(originalTF.getResId(), LocaleId.EN, "changed text");
List<TextFlow> from = new ArrayList<TextFlow>();
from.add(changedTF);
int newTFRevision = 2;