BooleanMapGenotype extends BooleanGenotype implements MapGenotype<K, Boolean> { @Override public void setValue(K key, Boolean value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = list.indexOf(key); while (size() <= i) { add(false); } set(i, value); } BooleanMapGenotype(List<K> list); void init(Random random); @Override void init(Random random, int n); @Override Boolean getValue(K key); @Override void setValue(K key, Boolean value); @Override boolean containsKey(K key); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override int getIndexOf(K key); @Override Collection<K> getKeys();  }
@Test(expected = IllegalArgumentException.class) public void testInvalidKeySetValue() { BooleanMapGenotype<Integer> geno = new BooleanMapGenotype<>(new MockList()); geno.setValue(3, true); }