Loading gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java +7 −2 Original line number Diff line number Diff line Loading @@ -85,9 +85,14 @@ public class GroupNameService { } public String getShortGroupName(String completeGroupName, Optional<String> groupPrefix) { if (groupPrefix.isPresent()) { 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; } Loading gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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(""))); } } Loading
gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java +7 −2 Original line number Diff line number Diff line Loading @@ -85,9 +85,14 @@ public class GroupNameService { } public String getShortGroupName(String completeGroupName, Optional<String> groupPrefix) { if (groupPrefix.isPresent()) { 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; } Loading
gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -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(""))); } }