package org.zanata.common;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.zanata.common.DocumentType.*;

import java.util.List;

import org.testng.SkipException;
import org.testng.annotations.Test;

@Test(groups = { "unit-tests" })
public class DocumentTypeTest
{

   public void typeForExtantType()
   {
      assertThat(typeFor("txt"), is(PLAIN_TEXT));
   }

   @Test(enabled = true)
   public void typeForNonExistentTypeCurrentBehaviour()
   {
      assertThat(typeFor("unknown"), is(nullValue()));
   }

   @Test(enabled = false, expectedExceptions = IllegalArgumentException.class)
   public void typeForNonExistentTypeBetterBehaviour()
   {
      typeFor("unknown");
   }

   public void typeForKnownTypeAfterDot()
   {
      assertThat(typeFor(".txt"), is(nullValue()));
   }

   public void typeForKnownTypeWithPrefix()
   {
      assertThat(typeFor("foo.txt"), is(nullValue()));
   }

   public void getAllExtensionsNotEmpty()
   {
      List<String> allExtensions = getAllExtensions();
      assertThat(allExtensions, not(empty()));
      assertThat(allExtensions, containsInAnyOrder("po", "pot", "txt", "dtd", "idml",
            // "properties",
            "odt", "fodt", "odp", "fodp", "ods", "fods", "odg", "fodg", "odb", "odf"));
   }

   @Test(expectedExceptions = UnsupportedOperationException.class)
   public void getAllExtensionsReadOnlyCannotAdd()
   {
      List<String> allExtensions = getAllExtensions();
      allExtensions.add("newExtension");
   }

   @Test(expectedExceptions = UnsupportedOperationException.class)
   public void getAllExtensionsReadOnlyCannotClear()
   {
      List<String> allExtensions = getAllExtensions();
      allExtensions.clear();
   }

   @Test(expectedExceptions = UnsupportedOperationException.class)
   public void getAllExtensionsReadOnlyCannotRemove()
   {
      List<String> allExtensions = getAllExtensions();
      allExtensions.remove(0);
   }

}

@@ -322,12 +322,13 @@
 Test
-%0A
+ 
 %7B%0A%0A
+ 
    p
@@ -357,22 +357,21 @@
 ntType()
+ %7B
 %0A  
- %7B%0A
       as
@@ -411,27 +411,29 @@
 _TEXT));%0A   
+ 
 %7D%0A%0A
+ 
    @Test(ena
@@ -445,16 +445,17 @@
 = true)%0A
+ 
    publi
@@ -497,30 +497,29 @@
 tBehaviour()
-%0A  
  %7B%0A
+  
       assert
@@ -560,27 +560,29 @@
 lue()));%0A   
+ 
 %7D%0A%0A
+ 
    @Test(ena
@@ -643,32 +643,33 @@
 ption.class)%0A   
+ 
 public void type
@@ -703,22 +703,21 @@
 aviour()
+ %7B
 %0A  
- %7B%0A
       ty
@@ -733,27 +733,29 @@
 known%22);%0A   
+ 
 %7D%0A%0A
+ 
    public vo
@@ -783,22 +783,21 @@
 terDot()
-%0A  
  %7B%0A
+  
       as
@@ -835,35 +835,37 @@
 llValue()));%0A   
+ 
 %7D%0A%0A
+ 
    public void t
@@ -891,19 +891,16 @@
 Prefix()
-%0A  
  %7B%0A     
@@ -896,24 +896,26 @@
 x() %7B%0A      
+  
 assertThat(t
@@ -954,19 +954,21 @@
 )));%0A   
+ 
 %7D%0A%0A
+ 
    publi
@@ -1000,22 +1000,21 @@
 tEmpty()
+ %7B
 %0A  
- %7B%0A
       Li
@@ -1058,32 +1058,34 @@
 nsions();%0A      
+ 
+ 
 assertThat(allEx
@@ -1111,24 +1111,26 @@
 ()));%0A      
+  
 assertThat(a
@@ -1128,30 +1128,63 @@
 ertThat(
-allExtensions,
+%0A                allExtensions,%0A               
  contain
@@ -1230,16 +1230,28 @@
 %22idml%22,%0A
+            
         
@@ -1283,16 +1283,28 @@
         
+       
+     
 %22odt%22, %22
@@ -1346,16 +1346,40 @@
 , %22odg%22,
+%0A                       
  %22fodg%22,
@@ -1395,16 +1395,17 @@
 odf%22));%0A
+ 
    %7D%0A%0A  
@@ -1397,32 +1397,33 @@
 f%22));%0A    %7D%0A%0A   
+ 
 @Test(expectedEx
@@ -1465,32 +1465,33 @@
 ption.class)%0A   
+ 
 public void getA
@@ -1521,19 +1521,16 @@
 notAdd()
-%0A  
  %7B%0A     
@@ -1522,32 +1522,34 @@
 otAdd() %7B%0A      
+  
 List%3CString%3E all
@@ -1579,32 +1579,34 @@
 nsions();%0A      
+  
 allExtensions.ad
@@ -1624,16 +1624,17 @@
 sion%22);%0A
+ 
    %7D%0A%0A  
@@ -1626,32 +1626,33 @@
 on%22);%0A    %7D%0A%0A   
+ 
 @Test(expectedEx
@@ -1694,32 +1694,33 @@
 ption.class)%0A   
+ 
 public void getA
@@ -1752,19 +1752,16 @@
 tClear()
-%0A  
  %7B%0A     
@@ -1753,32 +1753,34 @@
 Clear() %7B%0A      
+  
 List%3CString%3E all
@@ -1810,32 +1810,34 @@
 nsions();%0A      
+  
 allExtensions.cl
@@ -1843,16 +1843,17 @@
 lear();%0A
+ 
    %7D%0A%0A  
@@ -1853,16 +1853,17 @@
   %7D%0A%0A   
+ 
 @Test(ex
@@ -1921,16 +1921,17 @@
 ass)%0A   
+ 
 public v
@@ -1972,19 +1972,16 @@
 Remove()
-%0A  
  %7B%0A     
@@ -1977,24 +1977,26 @@
 e() %7B%0A      
+  
 List%3CString%3E
@@ -2034,24 +2034,26 @@
 ns();%0A      
+  
 allExtension
@@ -2065,16 +2065,17 @@
 ove(0);%0A
+ 
    %7D%0A%0A%7D%0A

Apply new formatting for DocumentTypeTest