Skip to content
Snippets Groups Projects
Commit 4d153a80 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Group names bugfix

parent e7c7f84d
No related branches found
No related tags found
No related merge requests found
......@@ -85,8 +85,13 @@ public class GroupNameService {
}
public String getShortGroupName(String completeGroupName, Optional<String> groupPrefix) {
if (groupPrefix.isPresent()) {
return completeGroupName.substring(groupPrefix.get().length() + 1);
if (groupPrefix.isPresent() && !groupPrefix.get().isBlank()) {
if (groupPrefix.get().endsWith(".")) {
// this branch is kept for retro-compatibility with old API, it will be removed in the future
return completeGroupName.substring(groupPrefix.get().length());
} else {
return completeGroupName.substring(groupPrefix.get().length() + 1);
}
}
return completeGroupName;
}
......
......@@ -99,4 +99,19 @@ public class GroupNameServiceTest {
public void extractGroupNamesTestNull() {
assertTrue(groupNameService.extractGroupNames(null).isEmpty());
}
@Test
public void testGetShortGroupNameOld() {
assertEquals("INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("LBT.")));
}
@Test
public void testGetShortGroupName() {
assertEquals("INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("LBT")));
}
@Test
public void testGetShortGroupNameEmpty() {
assertEquals("LBT.INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("")));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment