### Question:
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String worldName = conf.getString(WORLD_NAME); if (worldName == null) { return null; } return Bukkit.getWorld(worldName); } }  @NotNull static ConfigurationSection locationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location locationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @NotNull static ConfigurationSection blockLocationToConfig(@NotNull Location location, boolean useUUID); @Nullable static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); @Nullable static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf); @Nullable static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID); static final String WORLD_UID; static final String WORLD_NAME; static final String X; static final String Y; static final String Z; static final String YAW; static final String PITCH; }### Answer:
@Test public void worldFromConfValidName() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); World w = WorldLoader.worldFromConfig(conf, false); Assert.assertNotNull(w); }
@Test public void worldFromConfValidUUID() { YamlConfiguration conf = new YamlConfiguration(); UUID uuid = UUID.randomUUID(); conf.set(WorldLoader.WORLD_UID, uuid.toString()); when(Bukkit.getWorld(uuid)).thenReturn(mock(World.class)); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNotNull(w); }
@Test public void worldFromConfInValidName() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_NAME, "aa"); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNull(w); }
@Test public void worldFromConfInValidUUID() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_UID, UUID.randomUUID()); World w = WorldLoader.worldFromConfig(conf, true); Assert.assertNull(w); }
@Test public void worldFromConfNullName() { World w = WorldLoader.worldFromConfig(new YamlConfiguration(), false); Assert.assertNull(w); }
@Test public void worldFromConfNullUUID() { World w = WorldLoader.worldFromConfig(new YamlConfiguration(), true); Assert.assertNull(w); }