@Test public void test009GetMemberWithMatchingMemberNameCaseInsensitive() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockMemberSelf = createMockMember("S", "Self"); final DistributedMember mockMemberOne = createMockMember("1", "One"); final DistributedMember mockMemberTwo = createMockMember("2", "Two"); mockContext.checking(new Expectations() {{ oneOf(mockCache).getMembers(); will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo))); oneOf(mockCache).getDistributedSystem(); will(returnValue(mockDistributedSystem)); oneOf(mockDistributedSystem).getDistributedMember(); will(returnValue(mockMemberSelf)); }}); final AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberSelf, commands.getMember(mockCache, "self")); }
@Test public void test007GetMemberWithMatchingMemberId() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockMemberSelf = createMockMember("S", "Self"); final DistributedMember mockMemberOne = createMockMember("1", "One"); final DistributedMember mockMemberTwo = createMockMember("2", "Two"); mockContext.checking(new Expectations() {{ oneOf(mockCache).getMembers(); will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo))); oneOf(mockCache).getDistributedSystem(); will(returnValue(mockDistributedSystem)); oneOf(mockDistributedSystem).getDistributedMember(); will(returnValue(mockMemberSelf)); }}); final AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberTwo, commands.getMember(mockCache, "2")); }
@Test public void test008GetMemberWithMatchingMemberName() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockMemberSelf = createMockMember("S", "Self"); final DistributedMember mockMemberOne = createMockMember("1", "One"); final DistributedMember mockMemberTwo = createMockMember("2", "Two"); mockContext.checking(new Expectations() {{ oneOf(mockCache).getMembers(); will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo))); oneOf(mockCache).getDistributedSystem(); will(returnValue(mockDistributedSystem)); oneOf(mockDistributedSystem).getDistributedMember(); will(returnValue(mockMemberSelf)); }}); final AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); assertSame(mockMemberOne, commands.getMember(mockCache, "One")); }
@Test(expected = MemberNotFoundException.class) public void test010GetMemberThrowsMemberNotFoundException() { final Cache mockCache = mockContext.mock(Cache.class, "Cache"); final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem"); final DistributedMember mockMemberSelf = createMockMember("S", "Self"); final DistributedMember mockMemberOne = createMockMember("1", "One"); final DistributedMember mockMemberTwo = createMockMember("2", "Two"); mockContext.checking(new Expectations() {{ oneOf(mockCache).getMembers(); will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo))); oneOf(mockCache).getDistributedSystem(); will(returnValue(mockDistributedSystem)); oneOf(mockDistributedSystem).getDistributedMember(); will(returnValue(mockMemberSelf)); }}); final AbstractCommandsSupport commands = createAbstractCommandsSupport(mockCache); try { commands.getMember(mockCache, "zero"); } catch (MemberNotFoundException expected) { assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, "zero"), expected.getMessage()); throw expected; } }