private Set<DistributedMember> getMemberIDs(String functionID, List<String> memberNameList) { Set<DistributedMember> memberIds = new HashSet<>(memberNameList.size()); DistributionManager distributionManager = internalCache.getDistributionManager(); for (String name : memberNameList) { DistributedMember member = distributionManager.getMemberWithName(name); if (member == null) { throw new IllegalArgumentException( "Member " + name + " not found to execute \"" + functionID + "\""); } memberIds.add(member); } if (memberIds.isEmpty()) { throw new IllegalArgumentException("No members found to execute \"" + functionID + "\""); } return memberIds; }
@Test(expected = DistributedSystemDisconnectedException.class) public void succeedsWithValidMembers() throws Exception { when(distributionManager.getMemberWithName(any(String.class))).thenReturn( new InternalDistributedMember("localhost", 0), new InternalDistributedMember("localhost", 1), null); final FunctionAPI.ExecuteFunctionOnMemberRequest request = FunctionAPI.ExecuteFunctionOnMemberRequest.newBuilder().setFunctionID(TEST_FUNCTION_ID) .addMemberName(TEST_MEMBER1).addMemberName(TEST_MEMBER2).build(); final Result<FunctionAPI.ExecuteFunctionOnMemberResponse> result = operationHandler.process(serializationService, request, mockedMessageExecutionContext()); // unfortunately FunctionService fishes for a DistributedSystem and throws an exception // if it can't find one. It uses a static method on InternalDistributedSystem, so no // mocking is possible. If the test throws DistributedSystemDisconnectedException it // means that the operation handler got to the point of trying get an execution // context }
@Test(expected = DistributedSystemDisconnectedException.class) public void succeedsWithValidMembers() throws Exception { when(distributionManager.getMemberWithName(any(String.class))).thenReturn( new InternalDistributedMember("localhost", 0), new InternalDistributedMember("localhost", 1), null); final FunctionAPI.ExecuteFunctionOnGroupRequest request = FunctionAPI.ExecuteFunctionOnGroupRequest.newBuilder().setFunctionID(TEST_FUNCTION_ID) .addGroupName(TEST_GROUP1).addGroupName(TEST_GROUP2).build(); final Result<FunctionAPI.ExecuteFunctionOnGroupResponse> result = operationHandler.process(serializationService, request, mockedMessageExecutionContext()); // unfortunately FunctionService fishes for a DistributedSystem and throws an exception // if it can't find one. It uses a static method on InternalDistributedSystem, so no // mocking is possible. If the test throws DistributedSystemDisconnectedException it // means that the operation handler got to the point of trying get an execution // context }