### Question:
ActionSpatial implements Sc2ApiSerializable<Spatial.ActionSpatial>, GeneralizableAbility<ActionSpatial> { @Override public ActionSpatial generalizeAbility(UnaryOperator<Ability> generalize) { return getUnitCommand() .map(command -> ActionSpatial.of(command.generalizeAbility(generalize))) .orElse(this); } private  ActionSpatial(Spatial.ActionSpatial sc2ApiActionSpatial); private  ActionSpatial(ActionSpatialUnitCommand unitCommand); private  ActionSpatial(ActionSpatialCameraMove cameraMove); private  ActionSpatial(ActionSpatialUnitSelectionPoint unitSelectionPoint); private  ActionSpatial(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial of(ActionSpatialUnitCommand unitCommand); static ActionSpatial of(ActionSpatialCameraMove cameraMove); static ActionSpatial of(ActionSpatialUnitSelectionPoint unitSelectionPoint); static ActionSpatial of(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial from(Spatial.ActionSpatial sc2ApiActionSpatial); @Override Spatial.ActionSpatial toSc2Api(); Optional<ActionSpatialUnitCommand> getUnitCommand(); Optional<ActionSpatialCameraMove> getCameraMove(); Optional<ActionSpatialUnitSelectionPoint> getUnitSelectionPoint(); Optional<ActionSpatialUnitSelectionRect> getUnitSelectionRect(); @Override ActionSpatial generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test void createsCopyWithGeneralizedAbility() { ActionSpatial actionSpatialWithUnitCommand = actionSpatialWithUnitCommand(); ActionSpatial actionSpatialWithCameraMove = actionSpatialWithCameraMove(); ActionSpatial actionSpatialWithSelectionPoint = actionSpatialWithSelectionPoint(); ActionSpatial actionSpatialWithSelectionRect = actionSpatialWithSelectionRect(); UnaryOperator<Ability> generalize = ability -> Abilities.ATTACK_REDIRECT; assertThat(actionSpatialWithUnitCommand.generalizeAbility(generalize)).isNotEqualTo(actionSpatialWithUnitCommand); assertThat(actionSpatialWithCameraMove.generalizeAbility(generalize)).isSameAs(actionSpatialWithCameraMove); assertThat(actionSpatialWithSelectionPoint.generalizeAbility(generalize)) .isSameAs(actionSpatialWithSelectionPoint); assertThat(actionSpatialWithSelectionRect.generalizeAbility(generalize)) .isSameAs(actionSpatialWithSelectionRect); }