package org.zanata.rest.service;

import static org.zanata.model.tm.TransMemoryUnit.tu;
import static org.zanata.model.tm.TransMemoryUnitVariant.tuv;

import java.util.Iterator;

import javax.annotation.Nonnull;
import javax.ws.rs.core.StreamingOutput;

import org.testng.annotations.Test;
import org.zanata.common.LocaleId;
import org.zanata.model.tm.TransMemoryUnit;
import org.zanata.model.tm.TransMemory;

import com.google.common.collect.Lists;

public class ExportTransUnitTest extends TMXStreamingOutputTest
{

   @Test
   public void exportTransMemory() throws Exception
   {
      StreamingOutput output = streamSourceContents();
      checkAllLocales(output);
   }

   private TMXStreamingOutput<TransMemoryUnit> streamSourceContents()
   {
      return new TMXStreamingOutput<TransMemoryUnit>(createTestData(), new ExportTMXTransUnitStrategy());
   }

   private @Nonnull Iterator<TransMemoryUnit> createTestData()
   {
      TransMemory tm = null;
      String fr = LocaleId.FR.getId();
      String de = LocaleId.DE.getId();
      String sourceLoc = sourceLocale.getId();
      return Lists.<TransMemoryUnit>newArrayList(
            tu(
                  tm,
                  "doc0:resId0",
                  "doc0:resId0",
                  sourceLoc,
                  "source0",
                  tuv(fr, "targetFR0"),
                  tuv(de, "targetDE0")),
            tu(
                  tm,
                  "doc0:resId1",
                  "doc0:resId1",
                  sourceLoc,
                  "SOURCE0",
                  tuv(fr, "TARGETfr0")),
            tu(
                  tm,
                  "doc1:resId0",
                  "doc1:resId0",
                  sourceLoc,
                  "source0",
                  tuv(fr, "targetFR0")),
            tu(
                  tm,
                  "doc1:resId1",
                  "doc1:resId1",
                  sourceLoc,
                  "SOURCE0",
                  tuv(de, "TARGETde0"))).iterator();
   }

}

@@ -1272,39 +1272,50 @@
                %22
+%3Cseg%3E
 source0
+%3C/seg%3E
 %22,%0A             
@@ -1320,32 +1320,37 @@
        tuv(fr, %22
+%3Cseg%3E
 targetFR0%22),%0A   
@@ -1342,16 +1342,22 @@
 argetFR0
+%3C/seg%3E
 %22),%0A    
@@ -1379,16 +1379,21 @@
 uv(de, %22
+%3Cseg%3E
 targetDE
@@ -1393,16 +1393,22 @@
 argetDE0
+%3C/seg%3E
 %22)),%0A   
@@ -1548,39 +1548,50 @@
                %22
+%3Cseg%3E
 SOURCE0
+%3C/seg%3E
 %22,%0A             
@@ -1604,16 +1604,21 @@
 uv(fr, %22
+%3Cseg%3E
 TARGETfr
@@ -1618,16 +1618,22 @@
 ARGETfr0
+%3C/seg%3E
 %22)),%0A   
@@ -1781,23 +1781,34 @@
        %22
+%3Cseg%3E
 source0
+%3C/seg%3E
 %22,%0A     
@@ -1829,16 +1829,21 @@
 uv(fr, %22
+%3Cseg%3E
 targetFR
@@ -1843,16 +1843,22 @@
 argetFR0
+%3C/seg%3E
 %22)),%0A   
@@ -2006,23 +2006,34 @@
        %22
+%3Cseg%3E
 SOURCE0
+%3C/seg%3E
 %22,%0A     
@@ -2054,16 +2054,21 @@
 uv(de, %22
+%3Cseg%3E
 TARGETde
@@ -2068,16 +2068,22 @@
 ARGETde0
+%3C/seg%3E
 %22))).ite

Fix broken test