@Test public void choosePieceNoInterestingTest() { Piece actual = myRequestStrategy.choosePiece(new BitSet(), myPieces); Assert.assertNull(actual); }
@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())); }
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())); } }
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())); }  }
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); }
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);  }