### Question:
BouquetPluginConfigFactory { public static BouquetPluginConfig create(Project project) { if (project.getPluginManager().hasPlugin(ANDROID_APP.getPluginName())) { return new BouquetPluginAndroidConfig(project, ANDROID_APP); } else if (project.getPluginManager().hasPlugin(ANDROID_LIBRARY.getPluginName())) { return new BouquetPluginAndroidConfig(project, ANDROID_LIBRARY); } else if (project.getPluginManager().hasPlugin(JAVA_APP.getPluginName())) { return new BouquetPluginJavaConfig(project, JAVA_APP); } else if (project.getPluginManager().hasPlugin(JAVA_LIBRARY.getPluginName())) { return new BouquetPluginJavaConfig(project, JAVA_LIBRARY); } else { throw new TaskInstantiationException("Android or Java plugins required"); } }  static BouquetPluginConfig create(Project project);  }### Answer:
@Test public void create() { PluginManager pluginManager = mock(PluginManager.class); when(project.getPluginManager()).thenReturn(pluginManager); when(pluginManager.hasPlugin(ANDROID_APP.getPluginName())).thenReturn(true).thenReturn(false).thenReturn(false).thenReturn(false); when(pluginManager.hasPlugin(ANDROID_LIBRARY.getPluginName())).thenReturn(true).thenReturn(false).thenReturn(false); when(pluginManager.hasPlugin(JAVA_APP.getPluginName())).thenReturn(true).thenReturn(false); when(pluginManager.hasPlugin(JAVA_LIBRARY.getPluginName())).thenReturn(true); BouquetPluginConfig bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginAndroidConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginAndroidConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginJavaConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginJavaConfig.class); }
@Test(expected = TaskInstantiationException.class) public void createInvalidProjectType() { PluginManager pluginManager = mock(PluginManager.class); when(project.getPluginManager()).thenReturn(pluginManager); when(pluginManager.hasPlugin(anyString())).thenReturn(false); BouquetPluginConfigFactory.create(project); }