Search in sources :

Example 1 with JavaClassesDirectoryScannerPlugin

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));
}
Also used : JavaClassesDirectoryDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaClassesDirectoryDescriptor) JavaClassesDirectoryScannerPlugin(com.buschmais.jqassistant.plugin.java.impl.scanner.JavaClassesDirectoryScannerPlugin) FileResolver(com.buschmais.jqassistant.plugin.common.api.scanner.FileResolver) Test(org.junit.Test)

Example 2 with JavaClassesDirectoryScannerPlugin

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));
}
Also used : JavaClassesDirectoryDescriptor(com.buschmais.jqassistant.plugin.java.api.model.JavaClassesDirectoryDescriptor) JavaClassesDirectoryScannerPlugin(com.buschmais.jqassistant.plugin.java.impl.scanner.JavaClassesDirectoryScannerPlugin) FileResolver(com.buschmais.jqassistant.plugin.common.api.scanner.FileResolver) File(java.io.File) Test(org.junit.Test)

Aggregations

FileResolver (com.buschmais.jqassistant.plugin.common.api.scanner.FileResolver)2 JavaClassesDirectoryDescriptor (com.buschmais.jqassistant.plugin.java.api.model.JavaClassesDirectoryDescriptor)2 JavaClassesDirectoryScannerPlugin (com.buschmais.jqassistant.plugin.java.impl.scanner.JavaClassesDirectoryScannerPlugin)2 Test (org.junit.Test)2 File (java.io.File)1