Skip to content

Commit

Permalink
avoid hardcoding group map size
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Jul 11, 2023
1 parent a579c20 commit 4861460
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* Tests for the {@link Groups} command.
*/
public class GroupsTest {

Configuration cfg;
Expand All @@ -51,17 +55,18 @@ public void testBasicConfiguration() {
@Test
public void testDeleteGroup() {
Map<String, Group> groups = cfg.getGroups();
int origSize = groups.size();
invokeMethod("deleteGroup",
new Class<?>[]{Map.class, String.class},
new Object[]{groups, "random not existing group"});

assertEquals(6, groups.size());
assertEquals(origSize, groups.size());

invokeMethod("deleteGroup",
new Class<?>[]{Map.class, String.class},
new Object[]{groups, "apache"});

assertEquals(5, groups.size());
assertEquals(origSize - 1, groups.size());

invokeMethod("deleteGroup",
new Class<?>[]{Map.class, String.class},
Expand All @@ -73,14 +78,15 @@ public void testDeleteGroup() {
@Test
public void testAddGroup() {
Map<String, Group> groups = cfg.getGroups();
int origSize = groups.size();
Group grp = findGroup(groups, "new fantastic group");
assertNull(grp);

invokeMethod("modifyGroup",
new Class<?>[]{Map.class, String.class, String.class, String.class},
new Object[]{groups, "new fantastic group", "some pattern", null});

assertEquals(7, groups.size());
assertEquals(origSize + 1, groups.size());

grp = findGroup(groups, "new fantastic group");
assertNotNull(grp);
Expand All @@ -91,6 +97,7 @@ public void testAddGroup() {
@Test
public void testAddGroupToParent() {
Map<String, Group> groups = cfg.getGroups();
int origSize = groups.size();
Group grp = findGroup(groups, "apache");
assertNotNull(grp);

Expand All @@ -101,7 +108,7 @@ public void testAddGroupToParent() {
new Class<?>[]{Map.class, String.class, String.class, String.class},
new Object[]{groups, "new fantastic group", "some pattern", "apache"});

assertEquals(7, groups.size());
assertEquals(origSize + 1, groups.size());

grp = findGroup(groups, "apache");
assertNotNull(grp);
Expand Down

0 comments on commit 4861460

Please sign in to comment.