use of com.buschmais.jqassistant.plugin.java.impl.scanner.JavaClassesDirectoryScannerPlugin in project jqa-java-plugin by buschmais.
the class JavaClassesDirectoryScannerPluginTest method createArtifact.
/**
* Verify that the plugin creates a new artifact if none exists in the
* context.
*
* @throws IOException
* If the test fails.
*/
@Test
public void createArtifact() throws IOException {
JavaClassesDirectoryScannerPlugin plugin = new JavaClassesDirectoryScannerPlugin();
when(context.peek(FileResolver.class)).thenReturn(mock(FileResolver.class));
JavaClassesDirectoryDescriptor artifact = mock(JavaClassesDirectoryDescriptor.class);
when(context.peekOrDefault(JavaArtifactFileDescriptor.class, null)).thenReturn(null);
when(store.create(JavaClassesDirectoryDescriptor.class)).thenReturn(artifact);
JavaClassesDirectoryDescriptor descriptor = plugin.scan(directory, "/", JavaScope.CLASSPATH, scanner);
verify(context).peekOrDefault(JavaArtifactFileDescriptor.class, null);
verify(store).create(JavaClassesDirectoryDescriptor.class);
assertThat(descriptor, is(artifact));
}
use of com.buschmais.jqassistant.plugin.java.impl.scanner.JavaClassesDirectoryScannerPlugin in project jqa-java-plugin by buschmais.
the class JavaClassesDirectoryScannerPluginTest method useArtifactFromContext.
/**
* Verify that the plugin re-uses an existing artifact which exists in the
* context (e.g. for dependency resolution).
*
* @throws IOException
* If the test fails.
*/
@Test
public void useArtifactFromContext() throws IOException {
JavaClassesDirectoryScannerPlugin plugin = new JavaClassesDirectoryScannerPlugin();
File directory = Files.createTempDirectory("directory").toFile();
when(context.peek(FileResolver.class)).thenReturn(mock(FileResolver.class));
JavaClassesDirectoryDescriptor artifact = mock(JavaClassesDirectoryDescriptor.class);
when(context.peekOrDefault(JavaArtifactFileDescriptor.class, null)).thenReturn(artifact);
when(store.addDescriptorType(artifact, JavaClassesDirectoryDescriptor.class)).thenReturn(mock(JavaClassesDirectoryDescriptor.class));
JavaClassesDirectoryDescriptor descriptor = plugin.scan(directory, "/", JavaScope.CLASSPATH, scanner);
verify(context).peekOrDefault(JavaArtifactFileDescriptor.class, null);
verify(store, never()).create(JavaClassesDirectoryDescriptor.class);
assertThat(descriptor, is(artifact));
}
Aggregations