package org.tt.core.fetch.lexx;

import static org.junit.Assert.*;
import org.junit.Test;

import org.tt.core.entity.datafetcher.Department;

import java.util.List;

/**
 * Created by fau on 07/05/14.
 */
public class LexxDataFetcherTest  {
    @Test
    public void testGetDepartmentsWithMessage() throws Exception {
         LDFTestWrapper ldf = new LDFTestWrapper();
         List<Department> result = ldf.getDepartments();

        String actual = "";
        for (Department d: result)
        {
            if (d.getTag().equals("bf")) {
                actual = d.getMessage();
            }
        }

        assertEquals("Non-empty message getting failed", "Crucial information", actual);
    }

    @Test
    public void testGetGroups() throws Exception {

    }

    @Test
    public void testGetTT() throws Exception {

    }
}

@@ -30,42 +30,8 @@
 x;%0A%0A
-import static org.junit.Assert.*;%0A
 impo
@@ -49,17 +49,16 @@
 t.Test;%0A
-%0A
 import o
@@ -117,20 +117,144 @@
 va.util.
-List
+ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertArrayEquals;%0Aimport static org.junit.Assert.assertEquals
 ;%0A%0A/**%0A 
@@ -320,17 +320,16 @@
 herTest 
- 
 %7B%0A    @T
@@ -369,20 +369,480 @@
 ment
-sWithMessage
+ByTags() throws Exception %7B%0A        LDFTestWrapper ldf = new LDFTestWrapper();%0A        List%3CDepartment%3E result = ldf.getDepartments();%0A%0A        String%5B%5D expected = %7B%22bf%22,%22gf%22%7D;%0A%0A        List%3CString%3E actualTags = new ArrayList%3C%3E();%0A        for (Department d : result) %7B%0A            actualTags.add(d.getTag());%0A        %7D%0A%0A        assertArrayEquals(%22Department (tags) getting failed%22, expected, actualTags.toArray());%0A    %7D%0A%0A    @Test%0A    public void testGetDepartmentByNames
 () t
@@ -863,25 +863,24 @@
 n %7B%0A        
- 
 LDFTestWrapp
@@ -906,25 +906,24 @@
 tWrapper();%0A
- 
         List
@@ -985,20 +985,113 @@
 ring
- actual = %22%22
+%5B%5D expected = %7B%22Biology House%22, %22Geography House%22%7D;%0A%0A        List%3CString%3E actualNames = new ArrayList%3C%3E()
 ;%0A  
@@ -1113,16 +1113,17 @@
 rtment d
+ 
 : result
@@ -1123,25 +1123,30 @@
  result)
-%0A
+ %7B%0A   
         
 %7B%0A      
@@ -1141,213 +1141,1487 @@
     
-%7B%0A            if (d.getTag().equals(%22bf%22)) %7B%0A                actual = d.getMessage();%0A            %7D%0A        %7D%0A%0A        assertEquals(%22Non-empty message getting failed%22, %22Crucial information%22, actual);%0A    %7D
+ actualNames.add(d.getName());%0A        %7D%0A%0A        assertArrayEquals(%22Department (names) getting failed%22, expected, actualNames.toArray());%0A    %7D%0A%0A    @Test%0A    public void testGetDepartmentsWithMessage() throws Exception %7B%0A        LDFTestWrapper ldf = new LDFTestWrapper();%0A        List%3CDepartment%3E result = ldf.getDepartments();%0A%0A        String actual = %22%22;%0A        for (Department d : result) %7B%0A            if (d.getTag().equals(%22bf%22)) %7B%0A                actual = d.getMessage();%0A            %7D%0A        %7D%0A%0A        assertEquals(%22Non-empty message getting failed%22, %22Crucial information%22, actual);%0A    %7D%0A%0A    @Test%0A    public void testGetDepartmentsWithNoMessage() throws Exception %7B%0A        LDFTestWrapper ldf = new LDFTestWrapper();%0A        List%3CDepartment%3E result = ldf.getDepartments();%0A%0A        String actual = %22%22;%0A        for (Department d : result) %7B%0A            if (d.getTag().equals(%22gf%22)) %7B%0A                actual = d.getMessage();%0A            %7D%0A        %7D%0A%0A        assertEquals(%22Empty message getting failed%22, %22%22, actual);%0A    %7D%0A%0A//    @Test%0A//    public void testGetDepartments() throws Exception %7B%0A//        LDFTestWrapper ldf = new LDFTestWrapper();%0A//        List%3CDepartment%3E result = ldf.getDepartments();%0A//%0A//        Department%5B%5D expected = %7Bnew Department(%22bf%22, %22Biology House%22, %22Crucial Information%22),%0A//                new Department(%22gf%22, %22Geography House%22, %22%22)%7D;%0A//%0A//        assertArrayEquals(%22Department getting failed%22, expected, result.toArray());%0A//    %7D%0A
 %0A%0A  

Add proper tests for LDF