### Question:
UnloadableStaticPluginFactory implements PluginFactory { public Plugin create(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException { Validate.notNull(deploymentUnit, "The deployment unit is required"); return create(new JarPluginArtifact(deploymentUnit.getPath()), moduleDescriptorFactory); } UnloadableStaticPluginFactory(String pluginDescriptorFileName); String canCreate(PluginArtifact pluginArtifact); Plugin create(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory); Plugin create(PluginArtifact pluginArtifact, ModuleDescriptorFactory moduleDescriptorFactory);  }### Answer:
@Test public void testCreate() { UnloadableStaticPluginFactory factory = new UnloadableStaticPluginFactory("foo.xml"); PluginArtifact artifact = mock(PluginArtifact.class); when(artifact.getResourceAsStream("foo.xml")).thenReturn(new ByteArrayInputStream( "<maera-plugin key=\"foo\" />".getBytes() )); when(artifact.toString()).thenReturn("plugin.jar"); UnloadablePlugin plugin = (UnloadablePlugin) factory.create(artifact, new DefaultModuleDescriptorFactory(new DefaultHostContainer())); assertNotNull(plugin); assertEquals("foo", plugin.getKey()); assertTrue(plugin.getErrorText().contains("plugin.jar")); }
@Test public void testCreateWithNoKey() { UnloadableStaticPluginFactory factory = new UnloadableStaticPluginFactory("foo.xml"); PluginArtifact artifact = mock(PluginArtifact.class); when(artifact.getResourceAsStream("foo.xml")).thenReturn(new ByteArrayInputStream( "<maera-plugin />".getBytes() )); when(artifact.toString()).thenReturn("plugin.jar"); UnloadablePlugin plugin = (UnloadablePlugin) factory.create(artifact, new DefaultModuleDescriptorFactory(new DefaultHostContainer())); assertNotNull(plugin); assertEquals(null, plugin.getKey()); assertTrue(plugin.getErrorText().contains("plugin.jar")); }