### Question:
Potion { public void setLevel(int level) { Validate.notNull(this.type, "No-effect potions don't have a level."); int max = type.getMaxLevel(); Validate.isTrue(level > 0 && level <= max, "Level must be " + (max == 1 ? "" : "between 1 and ") + max + " for this potion"); this.level = level; } Potion(PotionType type); @SuppressWarnings("javadoc") @Deprecated  Potion(PotionType type, Tier tier); @SuppressWarnings("javadoc") @Deprecated  Potion(PotionType type, Tier tier, boolean splash); @SuppressWarnings("javadoc") @Deprecated  Potion(PotionType type, Tier tier, boolean splash, boolean extended);  Potion(PotionType type, int level); @Deprecated  Potion(PotionType type, int level, boolean splash); @Deprecated  Potion(PotionType type, int level, boolean splash, boolean extended);  Potion(int name); Potion splash(); Potion extend(); void apply(ItemStack to); void apply(LivingEntity to); @Override boolean equals(Object obj); Collection<PotionEffect> getEffects(); int getLevel(); @Deprecated Tier getTier(); PotionType getType(); boolean hasExtendedDuration(); @Override int hashCode(); boolean isSplash(); void setHasExtendedDuration(boolean isExtended); void setSplash(boolean isSplash); @Deprecated void setTier(Tier tier); void setType(PotionType type); void setLevel(int level); @Deprecated short toDamageValue(); ItemStack toItemStack(int amount); @Deprecated static Potion fromDamage(int damage); static Potion fromItemStack(ItemStack item); static PotionBrewer getBrewer(); static void setPotionBrewer(PotionBrewer other); @Deprecated int getNameId();  }### Answer:
@Test public void setLevel() { Potion potion = new Potion(PotionType.POISON); assertEquals(1, potion.getLevel()); potion.setLevel(2); assertEquals(2, potion.getLevel()); assertTrue((potion.toDamageValue() & 0x3F) == (PotionType.POISON.getDamageValue() | 0x20)); }
@Test(expected=IllegalArgumentException.class) public void maxLevelSet() { Potion potion = new Potion(PotionType.POISON); potion.setLevel(3); }