### Question:
DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); }  @Override CoinSelection select(Coin target, List<TransactionOutput> candidates); static boolean isSelectable(Transaction tx);  }### Answer:
@Test public void identicalInputs() throws Exception { Transaction t = new Transaction(UNITTEST); java.util.List<TransactionOutput> outputs = Arrays.asList( new TransactionOutput(UNITTEST, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(UNITTEST, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(UNITTEST, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(UNITTEST, t, Coin.valueOf(30302787), myAddress) ); t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.BUILDING); DefaultCoinSelector selector = new DefaultCoinSelector(); CoinSelection selection = selector.select(COIN.multiply(2), outputs); assertTrue(selection.gathered.size() == 4); }
@Test public void identicalInputs() throws Exception { Transaction t = new Transaction(PARAMS); java.util.List<TransactionOutput> outputs = Arrays.asList( new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress), new TransactionOutput(PARAMS, t, Coin.valueOf(30302787), myAddress) ); t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.BUILDING); DefaultCoinSelector selector = new DefaultCoinSelector(); CoinSelection selection = selector.select(COIN.multiply(2), outputs); assertTrue(selection.gathered.size() == 4); }