### Question:
PluginUtils { public static boolean doesPluginRequireRestart(final Plugin plugin) { if (Boolean.getBoolean(MAERA_DEV_MODE)) { return false; } for (final ModuleDescriptor<?> descriptor : plugin.getModuleDescriptors()) { if (descriptor.getClass().getAnnotation(RequiresRestart.class) != null) { return true; } } return false; }  static boolean doesPluginRequireRestart(final Plugin plugin); static Set<String> getPluginModulesThatRequireRestart(final Plugin plugin); static boolean doesModuleElementApplyToApplication(Element element, Set<String> keys); static int getDefaultEnablingWaitPeriod(); static final String MAERA_DEV_MODE; static final String MAERA_PLUGINS_ENABLE_WAIT; }### Answer:
@Test public void testDoesPluginRequireRestart() { Mock mockPlugin = new Mock(Plugin.class); mockPlugin.expectAndReturn("getModuleDescriptors", Arrays.asList(new DynamicModuleDescriptor(), new RequiresRestartModuleDescriptor())); assertTrue(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin.proxy())); mockPlugin.verify(); mockPlugin = new Mock(Plugin.class); mockPlugin.expectAndReturn("getModuleDescriptors", Arrays.asList(new DynamicModuleDescriptor())); assertFalse(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin.proxy())); mockPlugin.verify(); mockPlugin = new Mock(Plugin.class); mockPlugin.expectAndReturn("getModuleDescriptors", Arrays.asList()); assertFalse(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin.proxy())); mockPlugin.verify(); mockPlugin = new Mock(Plugin.class); mockPlugin.expectAndReturn("getModuleDescriptors", Arrays.asList(new RequiresRestartModuleDescriptor())); assertTrue(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin.proxy())); mockPlugin.verify(); }
@Test public void testDoesPluginRequireRestartDevMode() { try { System.setProperty("maera.dev.mode", "true"); Mock mockPlugin = new Mock(Plugin.class); assertFalse(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin.proxy())); mockPlugin.verify(); } finally { System.clearProperty("maera.dev.mode"); } Mock mockPlugin2 = new Mock(Plugin.class); mockPlugin2.expectAndReturn("getModuleDescriptors", Arrays.asList(new DynamicModuleDescriptor(), new RequiresRestartModuleDescriptor())); assertTrue(PluginUtils.doesPluginRequireRestart((Plugin) mockPlugin2.proxy())); mockPlugin2.verify(); }