### Question:
PlayerUtils { public static String getUuidOrName(OfflinePlayer player) { try { return player.getUniqueId().toString(); } catch (NoSuchMethodError ignore) { return player.getName(); } } private  PlayerUtils(); static String getUuidOrName(OfflinePlayer player); static String getPlayerIp(Player p); static boolean isNpc(Player player);  }### Answer:
@Test public void shouldGetUuid() { UUID uuid = UUID.randomUUID(); Player player = mock(Player.class); given(player.getUniqueId()).willReturn(uuid); String result = PlayerUtils.getUuidOrName(player); assertThat(result, equalTo(uuid.toString())); }
@Test public void shouldFallbackToName() { Player player = mock(Player.class); doThrow(NoSuchMethodError.class).when(player).getUniqueId(); String name = "Bobby12"; given(player.getName()).willReturn(name); String result = PlayerUtils.getUuidOrName(player); assertThat(result, equalTo(name)); }