### Question:
PluginHookService { public Location getMultiverseSpawn(World world) { if (multiverse != null) { MVWorldManager manager = multiverse.getMVWorldManager(); if (manager.isMVWorld(world)) { return manager.getMVWorld(world).getSpawnLocation(); } } return null; } @Inject  PluginHookService(PluginManager pluginManager); void setEssentialsSocialSpyStatus(Player player, boolean socialSpyStatus); File getEssentialsDataFolder(); File getCmiDataFolder(); Location getMultiverseSpawn(World world); boolean isEssentialsAvailable(); boolean isCmiAvailable(); boolean isMultiverseAvailable(); void tryHookToEssentials(); void tryHookToCmi(); void tryHookToMultiverse(); void unhookEssentials(); void unhookCmi(); void unhookMultiverse();  }### Answer:
@Test public void shouldReturnNullForUnavailableMultiverse() { PluginManager pluginManager = mock(PluginManager.class); PluginHookService pluginHookService = new PluginHookService(pluginManager); World world = mock(World.class); Location result = pluginHookService.getMultiverseSpawn(world); assertThat(result, nullValue()); }
@Test public void shouldGetMultiverseSpawn() { Location location = mock(Location.class); MultiverseWorld multiverseWorld = mock(MultiverseWorld.class); given(multiverseWorld.getSpawnLocation()).willReturn(location); World world = mock(World.class); MVWorldManager mvWorldManager = mock(MVWorldManager.class); given(mvWorldManager.isMVWorld(world)).willReturn(true); given(mvWorldManager.getMVWorld(world)).willReturn(multiverseWorld); MultiverseCore multiverse = mock(MultiverseCore.class); given(multiverse.getMVWorldManager()).willReturn(mvWorldManager); PluginManager pluginManager = mock(PluginManager.class); setPluginAvailable(pluginManager, MULTIVERSE, multiverse); PluginHookService pluginHookService = new PluginHookService(pluginManager); Location spawn = pluginHookService.getMultiverseSpawn(world); assertThat(spawn, equalTo(location)); verify(mvWorldManager).isMVWorld(world); verify(mvWorldManager).getMVWorld(world); verify(multiverseWorld).getSpawnLocation(); }
@Test public void shouldReturnNullForNonMvWorld() { World world = mock(World.class); MVWorldManager mvWorldManager = mock(MVWorldManager.class); given(mvWorldManager.isMVWorld(world)).willReturn(false); PluginManager pluginManager = mock(PluginManager.class); MultiverseCore multiverse = mock(MultiverseCore.class); setPluginAvailable(pluginManager, MULTIVERSE, multiverse); given(multiverse.getMVWorldManager()).willReturn(mvWorldManager); PluginHookService pluginHookService = new PluginHookService(pluginManager); Location spawn = pluginHookService.getMultiverseSpawn(world); assertThat(spawn, nullValue()); verify(mvWorldManager).isMVWorld(world); verify(mvWorldManager, never()).getMVWorld(world); }