Example #1
0
  /** Tests */
  @Test
  public void testSorting() {
    Random random = new Random();

    List<ScoredEntity<Object>> entities = new LinkedList<ScoredEntity<Object>>();
    int numEntities = 173;
    for (int i = 0; i < numEntities; i++) {
      entities.add(new ScoredEntity<Object>(new Object(), random.nextInt(1000)));
    }

    List<ScoredEntity<Object>> sortedEntities = ScoredEntity.sort(entities, false);
    for (int i = 0; i < sortedEntities.size() - 1; i++) {
      assertTrue(sortedEntities.get(i).getScore() >= sortedEntities.get(i + 1).getScore());
    }
  }
Example #2
0
 @Test(expected = NullPointerException.class)
 public void testNPE() {
   ScoredEntity.sort(null, false);
 }