### Question:
MatcherFrame { public boolean selectMatch() { OptionalInt receiver = context.allocateNextReceiver(receiverIndex); while (receiver.isPresent()) { receiverIndex = receiver.getAsInt(); Person rhs = context.lookupReceiver(receiverIndex); if (!lhs.equals(rhs)) { pair = new GiverAssignment(lhs, rhs); if (context.isPossibleMatch(pair)) { return true; } } receiver = context.allocateNextReceiver(receiverIndex); } pair = null; return false; } MatcherFrame(final MatcherContext context, final Person lhs); boolean selectMatch(); GiverAssignment getPair();  }### Answer:
@Test public void testEmpty() { MatcherContext context = new MatcherContext(RECEIVERS_NONE, RESTRICTIONS_EMPTY); MatcherFrame target = new MatcherFrame(context, PERSON_1); boolean isMatch = target.selectMatch(); assertAll( () -> assertFalse(isMatch), () -> assertEquals(Set.of(), context.getRemainingReceivers()), () -> assertThrows(IllegalStateException.class, target::getPair) ); }
@Test public void testThirdSelectMatch() { MatcherContext context = new MatcherContext(RECEIVERS_ALL, RESTRICTIONS_EMPTY); MatcherFrame target = new MatcherFrame(context, PERSON_1); target.selectMatch(); target.selectMatch(); boolean isMatch = target.selectMatch(); assertAll( () -> assertFalse(isMatch), () -> assertEquals(Set.of(PERSON_1, PERSON_2, PERSON_3), context.getRemainingReceivers()), () -> assertThrows(IllegalStateException.class, target::getPair) ); }