Search in sources :

Example 1 with CacheClassFileImporter

use of com.tngtech.archunit.junit.internal.ClassCache.CacheClassFileImporter in project ArchUnit by TNG.

the class ClassCacheTest method if_whole_classpath_is_set_true_then_the_whole_classpath_is_imported.

@Test
public void if_whole_classpath_is_set_true_then_the_whole_classpath_is_imported() {
    TestAnalysisRequest defaultOptions = new TestAnalysisRequest().withWholeClasspath(true);
    Class<?>[] expectedImportResult = new Class[] { getClass() };
    doReturn(new ClassFileImporter().importClasses(expectedImportResult)).when(cacheClassFileImporter).importClasses(any(ImportOptions.class), ArgumentMatchers.<Location>anyCollection());
    JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, defaultOptions);
    assertThatTypes(classes).matchExactly(expectedImportResult);
    verify(cacheClassFileImporter).importClasses(any(ImportOptions.class), locationCaptor.capture());
    assertThat(locationCaptor.getValue()).has(locationContaining("archunit")).has(locationContaining("asm")).has(locationContaining("google")).has(locationContaining("mockito"));
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) JavaClass(com.tngtech.archunit.core.domain.JavaClass) ImportOptions(com.tngtech.archunit.core.importer.ImportOptions) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) CacheClassFileImporter(com.tngtech.archunit.junit.internal.ClassCache.CacheClassFileImporter) Test(org.junit.Test)

Aggregations

JavaClass (com.tngtech.archunit.core.domain.JavaClass)1 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)1 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)1 ImportOptions (com.tngtech.archunit.core.importer.ImportOptions)1 CacheClassFileImporter (com.tngtech.archunit.junit.internal.ClassCache.CacheClassFileImporter)1 Test (org.junit.Test)1