Commit 69bd8b4e authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Bugfix in group names parsing

parent e0a092f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -144,7 +144,7 @@ public class GroupNameService {
                currentName += c;
                currentName += c;
            }
            }
        }
        }
        names.add(currentName);
        names.add(currentName.replace("\\.", "."));
        return names;
        return names;
    }
    }


+23 −0
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Optional;
import java.util.Set;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
@@ -76,4 +77,26 @@ public class GroupNameServiceTest {
        assertEquals(1, names.get("ROOT").size());
        assertEquals(1, names.get("ROOT").size());
        assertEquals("ROOT", names.get("ROOT").get(0));
        assertEquals("ROOT", names.get("ROOT").get(0));
    }
    }

    @Test
    public void extractGroupNamesTest() {

        List<String> names = groupNameService.extractGroupNames("group1.people.name\\.surname.another\\.composite");

        assertEquals(4, names.size());
        assertEquals("group1", names.get(0));
        assertEquals("people", names.get(1));
        assertEquals("name.surname", names.get(2));
        assertEquals("another.composite", names.get(3));
    }

    @Test
    public void extractGroupNamesTestEmpty() {
        assertTrue(groupNameService.extractGroupNames("").isEmpty());
    }

    @Test
    public void extractGroupNamesTestNull() {
        assertTrue(groupNameService.extractGroupNames(null).isEmpty());
    }
}
}