Skip to content

Commit

Permalink
Use varargs to accept serverIds
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Nov 27, 2019
1 parent 4a86532 commit 338b44f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@ public class HazelcastTimerStoreEmptyTimersTest extends HazelcastTimerStoreTestB

@Test
public void emptyTimersShallResultInZeroTimersCountedForServer() {
String [] serverIds = new String[] { "a" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "a");

assertEquals("With no timers defined, zero timers is expected for given server id", "0", counts[0]);
}

@Test
public void emptyTimersShallResultInArrayOfTheSameSizeAsServerIds() {
String [] serverIds = new String[] { "a", "b", "c", "d" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "a", "b", "c", "d");

assertEquals("Size of counters array shall match the size of server ids array", serverIds.length, counts.length);
assertEquals("Size of counters array shall match the size of server ids array", 4, counts.length);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,21 @@ public void setUpTimers() {

@Test
public void twoTimersForTheSameMemberNameShallBeCountedForTheSameServerId() {
String [] serverIds = new String[] { "jb" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "jb");

assertEquals("2", counts[0]);
}

@Test
public void countOneTimer() {
String [] serverIds = new String[] { "hz" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "hz");

assertEquals("1", counts[0]);
}

@Test
public void noNullsExpectedInCountsForMissingTimers() {
String [] serverIds = new String[] { "jb", "ltd", "hz" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "jb", "ltd", "hz");

for (String count : counts) {
assertNotNull("Even for missing timers/server ids no null is expected but rather some representation of zero", count);
Expand All @@ -61,9 +55,7 @@ public void noNullsExpectedInCountsForMissingTimers() {

@Test
public void countersShallFollowServerIdOrder() {
String [] serverIds = new String[] { "hz", "ltd", "jb" };

String [] counts = callListTimers(timers, serverIds);
String [] counts = callListTimers(timers, "hz", "ltd", "jb");

assertEquals("1", counts[0]);
assertEquals("0", counts[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Collection;

public abstract class HazelcastTimerStoreTestBase {
public String[] callListTimers(Collection<HZTimer> timers, String[] serverIds) {
public String[] callListTimers(Collection<HZTimer> timers, String... serverIds) {
return HazelcastTimerStore.listTimers(timers, serverIds);
}
}
Expand Down

0 comments on commit 338b44f

Please sign in to comment.