use of com.hazelcast.cluster.MemberSelector in project hazelcast by hazelcast.
the class MemberSelectorsTest method testOrMemberSelector.
@Test
public void testOrMemberSelector() {
when(member.localMember()).thenReturn(true);
MemberSelector selector = MemberSelectors.or(LOCAL_MEMBER_SELECTOR, LITE_MEMBER_SELECTOR);
assertTrue(selector.select(member));
verify(member).localMember();
verify(member, never()).isLiteMember();
}
use of com.hazelcast.cluster.MemberSelector in project hazelcast by hazelcast.
the class MemberSelectorsTest method testOrMemberSelector2.
@Test
public void testOrMemberSelector2() {
MemberSelector selector = MemberSelectors.or(LOCAL_MEMBER_SELECTOR, LITE_MEMBER_SELECTOR);
assertFalse(selector.select(member));
verify(member).localMember();
verify(member).isLiteMember();
}
use of com.hazelcast.cluster.MemberSelector in project hazelcast by hazelcast.
the class AbstractExecutorNullTest method testNullability.
@Test
public void testNullability() {
Runnable sampleRunnable = (Runnable & Serializable) () -> {
};
Callable<Object> sampleCallable = (Callable & Serializable) () -> "";
Member sampleMember = getDriver().getCluster().getMembers().iterator().next();
Set<Member> sampleMembers = Collections.singleton(sampleMember);
MemberSelector sampleSelector = member -> true;
ExecutionCallback<Object> sampleCallback = new ExecutionCallback<Object>() {
@Override
public void onResponse(Object response) {
}
@Override
public void onFailure(Throwable t) {
}
};
MultiExecutionCallback sampleMultiExecutionCallback = new MultiExecutionCallback() {
@Override
public void onResponse(Member member, Object value) {
}
@Override
public void onComplete(Map<Member, Object> values) {
}
};
assertThrowsNPE(s -> s.execute((Runnable) null, sampleSelector));
assertThrowsNPE(s -> s.execute(sampleRunnable, null));
assertThrowsNPE(s -> s.executeOnKeyOwner(null, ""));
assertThrowsNPE(s -> s.executeOnKeyOwner(sampleRunnable, null));
assertThrowsNPE(s -> s.executeOnMember(null, sampleMember));
assertThrowsNPE(s -> s.executeOnMember(sampleRunnable, null));
assertThrowsNPE(s -> s.executeOnMembers(null, sampleMembers));
assertThrowsNPE(s -> s.executeOnMembers(sampleRunnable, (Collection<Member>) null));
assertThrowsNPE(s -> s.executeOnMembers(null, sampleSelector));
assertThrowsNPE(s -> s.executeOnMembers(sampleRunnable, (MemberSelector) null));
assertThrowsNPE(s -> s.executeOnAllMembers(null));
System.out.println("------------1");
assertThrowsNPE(s -> s.submit((Callable) null, sampleSelector));
assertThrowsNPE(s -> s.submit(sampleCallable, (MemberSelector) null));
assertThrowsNPE(s -> s.submitToKeyOwner((Callable) null, ""));
assertThrowsNPE(s -> s.submitToKeyOwner(sampleCallable, null));
assertThrowsNPE(s -> s.submitToMember((Callable) null, sampleMember));
assertThrowsNPE(s -> s.submitToMember(sampleCallable, null));
assertThrowsNPE(s -> s.submitToMembers((Callable) null, sampleMembers));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, (Collection<Member>) null));
assertThrowsNPE(s -> s.submitToMembers((Callable) null, sampleSelector));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, (MemberSelector) null));
assertThrowsNPE(s -> s.submitToAllMembers(null));
System.out.println("------------2");
assertThrowsNPE(s -> s.submit((Runnable) null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submit(sampleRunnable, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submit((Runnable) null, sampleSelector, sampleCallback));
assertThrowsNPE(s -> s.submit(sampleRunnable, (MemberSelector) null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submit(sampleRunnable, sampleSelector, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToKeyOwner((Runnable) null, "", sampleCallback));
assertThrowsNPE(s -> s.submitToKeyOwner(sampleRunnable, null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submitToKeyOwner(sampleRunnable, "", (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToMember((Runnable) null, sampleMember, sampleCallback));
assertThrowsNPE(s -> s.submitToMember(sampleRunnable, null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submitToMember(sampleRunnable, sampleMember, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToMembers((Runnable) null, sampleMembers, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleRunnable, (Collection) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleRunnable, sampleMembers, (MultiExecutionCallback) null));
assertThrowsNPE(s -> s.submitToMembers((Runnable) null, sampleSelector, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleRunnable, (MemberSelector) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleRunnable, sampleSelector, (MultiExecutionCallback) null));
assertThrowsNPE(s -> s.submitToAllMembers((Runnable) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToAllMembers(sampleRunnable, null));
System.out.println("------------3");
assertThrowsNPE(s -> s.submit((Callable<Object>) null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submit(sampleCallable, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submit((Callable) null, sampleSelector, sampleCallback));
assertThrowsNPE(s -> s.submit(sampleCallable, (MemberSelector) null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submit(sampleCallable, sampleSelector, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToKeyOwner((Callable) null, "", sampleCallback));
assertThrowsNPE(s -> s.submitToKeyOwner(sampleCallable, null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submitToKeyOwner(sampleCallable, "", (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToMember((Callable) null, sampleMember, sampleCallback));
assertThrowsNPE(s -> s.submitToMember(sampleCallable, null, sampleCallback));
getDriver().getExecutorService(RANDOM_NAME).submitToMember(sampleCallable, sampleMember, (ExecutionCallback) null);
assertThrowsNPE(s -> s.submitToMembers((Callable) null, sampleMembers, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, (Collection) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, sampleMembers, (MultiExecutionCallback) null));
assertThrowsNPE(s -> s.submitToMembers((Callable) null, sampleSelector, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, (MemberSelector) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToMembers(sampleCallable, sampleSelector, (MultiExecutionCallback) null));
assertThrowsNPE(s -> s.submitToAllMembers((Callable) null, sampleMultiExecutionCallback));
assertThrowsNPE(s -> s.submitToAllMembers(sampleCallable, null));
}
Aggregations