Java源码示例:com.tngtech.archunit.core.importer.ImportOptions

示例1
private ImportOptions onlyAppAndRuntime() {
    return new ImportOptions().with(new ImportOption() {
        @Override
        public boolean includes(Location location) {
            return location.contains("archunit")
                    || location.contains("/rt.jar")
                    || location.contains("java.base");
        }
    });
}
 
示例2
private synchronized void initialize() {
    if (javaClasses == null) {
        ImportOptions importOptions = new ImportOptions();
        for (Class<? extends ImportOption> optionClass : importOptionTypes) {
            importOptions = importOptions.with(newInstanceOf(optionClass));
        }
        javaClasses = cacheClassFileImporter.importClasses(importOptions, locations);
    }
}
 
示例3
@Test
@UseDataProvider("test_classes_without_any_imported_classes")
public void when_there_are_only_nonexisting_sources_nothing_is_imported(TestAnalysisRequest analysisRequest) {
    JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, analysisRequest);

    assertThat(classes).isEmpty();

    verify(cacheClassFileImporter).importClasses(any(ImportOptions.class), locationCaptor.capture());
    assertThat(locationCaptor.getValue()).isEmpty();
}
 
示例4
@Test
public void concurrent_access() throws Exception {
    List<Future<?>> futures = new ArrayList<>();
    for (int i = 0; i < NUM_THREADS; i++) {
        futures.add(executorService.submit(repeatGetClassesToAnalyze(1000)));
    }
    for (Future<?> future : futures) {
        future.get(1, MINUTES);
    }
    verify(classFileImporter, atMost(TEST_CLASSES.size())).importClasses(any(ImportOptions.class), ArgumentMatchers.<Location>anyCollection());
    verifyNoMoreInteractions(classFileImporter);
}
 
示例5
private ImportOptions onlyAppAndRuntime() {
    return new ImportOptions().with(new ImportOption() {
        @Override
        public boolean includes(Location location) {
            return location.contains("archunit")
                    || location.contains("/rt.jar")
                    || location.contains("java.base");
        }
    });
}
 
示例6
JavaClasses importClasses(ImportOptions importOptions, Collection<Location> locations) {
    return new ClassFileImporter(importOptions).importLocations(locations);
}
 
示例7
private void verifyNumberOfImports(int number) {
    verify(cacheClassFileImporter, times(number)).importClasses(any(ImportOptions.class), ArgumentMatchers.<Location>anyCollection());
    verifyNoMoreInteractions(cacheClassFileImporter);
}