package ru.matevosyan;

import org.junit.Test;

import java.util.TreeSet;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

/**
 * Created by Admin on 07.05.2017.
 */
public class DepartmentTest {
    @Test
            public void whenPassDepartmentSerThanCheckSortedDepartment() {
        TreeSet<String> depCode = new TreeSet<>();
        Department department = new Department(depCode);

        depCode.add("K1\\SK1");
        depCode.add("K1\\SK2");
        depCode.add("K1\\SK1\\SSK1");
        depCode.add("K1\\SK1\\SSK2");
        depCode.add("K2\\SK1\\SSK1");
        depCode.add("K2\\SK1\\SSK2");
        depCode.add("K2");

        assertThat(department.getName().first(), is("K1\\SK1"));
        System.out.printf("%s", department.getName());
    }
}
@@ -37,24 +37,102 @@
 unit.Test;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A
 import java.
@@ -322,24 +322,16 @@
   @Test%0A
-        
     publ
@@ -388,16 +388,34 @@
 ment() %7B
+%0A%0A        //assign
 %0A       
@@ -512,24 +512,338 @@
 (depCode);%0A%0A
+        TreeSet%3CString%3E code = new TreeSet%3C%3E();%0A        DepartmentCode departmentCode = new DepartmentCode(code);%0A%0A        List%3CString%3E codeExpected = new ArrayList%3C%3E();%0A        Iterator iterator = department.getName().iterator();%0A        int i = 0;%0A%0A        //act%0A        code.add(%22K1%22);%0A        code.add(%22K2%22);%0A%0A
         depC
@@ -1086,51 +1086,136 @@
     
-assertThat(department.getName().first(), is
+codeExpected.add(%22K1%22);%0A        codeExpected.add(%22K1%5C%5CSK1%22);%0A        codeExpected.add(%22K1%5C%5CSK1%5C%5CSSK1%22);%0A        codeExpected.add
 (%22K1
@@ -1219,18 +1219,23 @@
 %22K1%5C%5CSK1
+%5C%5CSSK2
 %22
-)
 );%0A     
@@ -1241,54 +1241,338 @@
     
-System.out.printf(%22%25s%22, department.getName());
+codeExpected.add(%22K1%5C%5CSK2%22);%0A        codeExpected.add(%22K2%22);%0A        codeExpected.add(%22K2%5C%5CSK1%5C%5CSSK1%22);%0A        codeExpected.add(%22K2%5C%5CSK1%5C%5CSSK2%22);%0A%0A        depCode.addAll(departmentCode.getCode());%0A%0A        //assert%0A        while (iterator.hasNext()) %7B%0A            assertThat(iterator.next(), is(codeExpected.get(i++)));%0A        %7D
 %0A   

change test