### Question:
Unit extends UnitSnapshot { public static Unit from(Raw.Unit sc2ApiUnit) { require("sc2api unit", sc2ApiUnit); return new Unit(sc2ApiUnit); } private  Unit(Raw.Unit sc2ApiUnit); private  Unit(Unit original, UnaryOperator<Ability> generalize); static Unit from(Raw.Unit sc2ApiUnit); Tag getTag(); UnitType getType(); int getOwner(); float getFacing(); float getRadius(); float getBuildProgress(); @Override Unit generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean canEqual(Object other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final int CLOAKED; }### Answer:
@Test void throwsExceptionWhenSc2ApiUnitIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from(nothing())) .withMessage("sc2api unit is required"); }
@Test void convertsAllFieldsFromSc2ApiUnit() { assertThatAllFieldsAreConverted(Unit.from(sc2ApiUnit())); }
@Test void throwsExceptionWhenDisplayTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearDisplayType).build())) .withMessage("display type is required"); }
@Test void throwsExceptionWhenAllianceIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearAlliance).build())) .withMessage("alliance is required"); }
@Test void throwsExceptionWhenTagIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearTag).build())) .withMessage("tag is required"); }
@Test void throwsExceptionWhenTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearUnitType).build())) .withMessage("unit type is required"); }
@Test void throwsExceptionWhenPositionIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearPos).build())) .withMessage("position is required"); }
@Test void hasDefaultValueForOnScreenFieldIfNotProvided() { Unit unit = Unit.from(without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearIsOnScreen).build()); assertThat(unit.isOnScreen()).as("unit: default on screen").isFalse(); }
@Test void hasDefaultValueForBlipFieldIfNotProvided() { Unit unit = Unit.from(without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearIsBlip).build()); assertThat(unit.isBlip()).as("unit: default blip").isFalse(); }
@Test void hasEmptyListOfOrdersWhenNotProvided() { assertThat(Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearOrders).build() ).getOrders()).as("unit: empty orders list").isEmpty(); }
@Test void hasEmptyListOfPassengersWhenNotProvided() { assertThat(Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearPassengers).build() ).getPassengers()).as("unit: empty passengers list").isEmpty(); }
@Test void hasEmptySetOfBuffsWhenNotProvided() { assertThat(Unit.from( without(() -> sc2ApiUnit().toBuilder(), Raw.Unit.Builder::clearBuffIds).build() ).getBuffs()).as("unit: empty buff set").isEmpty(); }