### Question:
RequestStrategyImplAnyInteresting implements RequestStrategy { @Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); }  @Override Piece choosePiece(BitSet interesting, Piece[] pieces);  }### Answer:
@Test public void choosePieceNoInterestingTest() { Piece actual = myRequestStrategy.choosePiece(new BitSet(), myPieces); Assert.assertNull(actual); }
@Test public void choosePieceOneInterestingTest() { BitSet interesting = new BitSet(); for (int i = 0; i < myPieces.length; i++) { interesting.clear(); interesting.set(i); Piece expected = myPieces[i]; Piece actual = myRequestStrategy.choosePiece(interesting, myPieces); Assert.assertEquals(expected, actual); } }
@Test public void choosePieceTest() { BitSet interesting = new BitSet(); int interestingFrom = 1; int interestingTo = 5; interesting.set(interestingFrom, interestingTo); Piece actual = myRequestStrategy.choosePiece(interesting, myPieces); Assert.assertTrue(actual.getIndex() >= interestingFrom && actual.getIndex() <= interestingTo); }