@Test(expected = IndexOutOfBoundsException.class) public void addCheckedIndividualDespiteArchiveFull() { Individual individual1 = mock(Individual.class); Individual individual2 = mock(Individual.class); BoundedArchive archive = new BoundedArchive(1) { @Override protected boolean updateWithNondominated(Collection<Individual> candidates) { individuals.addAll(candidates); return true; } }; archive.addCheckedIndividual(individual1); Assert.assertTrue(archive.contains(individual1)); Assert.assertEquals(1, archive.size()); archive.addCheckedIndividual(individual2); }
@Override public boolean addCheckedIndividual(Individual individual) { if (!contains(individual) && individuals.size() >= capacity) { throw new IndexOutOfBoundsException(); } return super.addCheckedIndividual(individual); }
BoundedArchive extends AbstractArchive { @Override public boolean addCheckedIndividual(Individual individual) { if (!contains(individual) && individuals.size() >= capacity) { throw new IndexOutOfBoundsException(); } return super.addCheckedIndividual(individual); } }
BoundedArchive extends AbstractArchive { @Override public boolean addCheckedIndividual(Individual individual) { if (!contains(individual) && individuals.size() >= capacity) { throw new IndexOutOfBoundsException(); } return super.addCheckedIndividual(individual); } @Inject  BoundedArchive(int capacity); }
BoundedArchive extends AbstractArchive { @Override public boolean addCheckedIndividual(Individual individual) { if (!contains(individual) && individuals.size() >= capacity) { throw new IndexOutOfBoundsException(); } return super.addCheckedIndividual(individual); } @Inject  BoundedArchive(int capacity); void setCapacity(int capacity); int getCapacity(); @Override boolean addCheckedIndividual(Individual individual); @Override boolean addCheckedIndividuals(Collection<? extends Individual> c); }
BoundedArchive extends AbstractArchive { @Override public boolean addCheckedIndividual(Individual individual) { if (!contains(individual) && individuals.size() >= capacity) { throw new IndexOutOfBoundsException(); } return super.addCheckedIndividual(individual); } @Inject  BoundedArchive(int capacity); void setCapacity(int capacity); int getCapacity(); @Override boolean addCheckedIndividual(Individual individual); @Override boolean addCheckedIndividuals(Collection<? extends Individual> c);  }