Search in sources :

Example 6 with MockArtifactLocationDecoder

use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.

the class JarCacheTest method refresh_fullSync_remoteArtifact_lintJarCached.

@Test
public void refresh_fullSync_remoteArtifact_lintJarCached() throws IOException {
    ArtifactLocationDecoder remoteArtifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
    true);
    testRefreshLintJarCached(remoteArtifactLocationDecoder, SyncMode.FULL);
}
Also used : MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) Test(org.junit.Test)

Example 7 with MockArtifactLocationDecoder

use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.

the class JarCacheTest method refresh_incrementalSync_remoteArtifact_lintJarCached.

@Test
public void refresh_incrementalSync_remoteArtifact_lintJarCached() throws IOException {
    ArtifactLocationDecoder remoteArtifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
    true);
    testRefreshLintJarCached(remoteArtifactLocationDecoder, SyncMode.INCREMENTAL);
}
Also used : MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) Test(org.junit.Test)

Example 8 with MockArtifactLocationDecoder

use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.

the class JarCacheTest method refresh_fullSync_localArtifact_lintJarCached.

@Test
public void refresh_fullSync_localArtifact_lintJarCached() throws IOException {
    ArtifactLocationDecoder localArtifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
    false);
    testRefreshLintJarCached(localArtifactLocationDecoder, SyncMode.FULL);
}
Also used : MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) Test(org.junit.Test)

Example 9 with MockArtifactLocationDecoder

use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.

the class JarCacheTest method refresh_lintJarCachedAndRepackaged.

@Test
public void refresh_lintJarCachedAndRepackaged() throws IOException {
    ArtifactLocationDecoder artifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
    true);
    // arrange: set up a project that have PluginProcessorJars and register a fake repackager that
    // will repackage jars
    fakeJarRepackager.setEnable(true);
    File jar = workspaceRoot.fileForPath(new WorkspacePath(PLUGIN_PROCESSOR_JAR));
    BlazeProjectData blazeProjectData = setupProjectWithLintRuleJar(jar, artifactLocationDecoder);
    // act: refresh all the file caches, which in turn will fetch the plugin processor jar to local
    // and use FakeJarRepackager to repackage it
    FileCache.EP_NAME.extensions().forEach(ep -> ep.onSync(getProject(), context, ProjectViewSet.builder().add(ProjectView.builder().build()).build(), blazeProjectData, null, SyncMode.FULL));
    // assert
    File cacheDir = JarCacheFolderProvider.getInstance(project).getJarCacheFolder();
    File[] cachedFiles = cacheDir.listFiles();
    assertThat(cachedFiles).hasLength(2);
    assertThat(stream(cachedFiles).filter(file -> !file.getName().startsWith(fakeJarRepackager.getRepackagePrefix()) && new File(cacheDir, fakeJarRepackager.getRepackagePrefix() + file.getName()).exists()).count()).isEqualTo(1);
    for (File file : cachedFiles) {
        byte[] actualJarContent = Files.readAllBytes(file.toPath());
        byte[] expectedJarContent = Files.readAllBytes(jar.toPath());
        assertThat(actualJarContent).isEqualTo(expectedJarContent);
    }
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildSystemProviderWrapper(com.google.idea.blaze.base.bazel.BuildSystemProviderWrapper) EmptyJarTracker(com.google.idea.blaze.java.sync.importer.emptylibrary.EmptyJarTracker) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) BuildSystemName(com.google.idea.blaze.base.settings.BuildSystemName) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) RemoteArtifactPrefetcher(com.google.idea.blaze.base.prefetch.RemoteArtifactPrefetcher) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) SyncMode(com.google.idea.blaze.base.sync.SyncMode) Writer(java.io.Writer) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) FakeBuildSystemProvider(com.google.idea.blaze.base.bazel.FakeBuildSystemProvider) DefaultPrefetcher(com.google.idea.blaze.base.prefetch.DefaultPrefetcher) Arrays.stream(java.util.Arrays.stream) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) GlobSet(com.google.idea.blaze.base.projectview.section.Glob.GlobSet) ZipOutputStream(java.util.zip.ZipOutputStream) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) RunWith(org.junit.runner.RunWith) BlazeJavaSyncPlugin(com.google.idea.blaze.java.sync.BlazeJavaSyncPlugin) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) StandardCopyOption(java.nio.file.StandardCopyOption) ExperimentService(com.google.idea.common.experiments.ExperimentService) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) FileCache(com.google.idea.blaze.base.filecache.FileCache) OutputSink(com.google.idea.blaze.base.scope.OutputSink) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableList(com.google.common.collect.ImmutableList) FakeBuildSystem(com.google.idea.blaze.base.bazel.FakeBuildSystem) BlazeJavaUserSettings(com.google.idea.blaze.java.settings.BlazeJavaUserSettings) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) BlazeTestCase(com.google.idea.blaze.base.BlazeTestCase) BlazeLibrarySorter(com.google.idea.blaze.base.sync.libraries.BlazeLibrarySorter) StringWriter(java.io.StringWriter) SyncState(com.google.idea.blaze.base.model.SyncState) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Rule(org.junit.Rule) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TemporaryFolder(org.junit.rules.TemporaryFolder) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) File(java.io.File) Test(org.junit.Test)

Example 10 with MockArtifactLocationDecoder

use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.

the class JarCacheTest method refresh_incrementalSync_localArtifact_lintJarCached.

@Test
public void refresh_incrementalSync_localArtifact_lintJarCached() throws IOException {
    ArtifactLocationDecoder localArtifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
    false);
    testRefreshLintJarCached(localArtifactLocationDecoder, SyncMode.INCREMENTAL);
}
Also used : MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) Test(org.junit.Test)

Aggregations

MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)13 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)9 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)7 File (java.io.File)7 Test (org.junit.Test)7 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)5 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)5 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)5 DefaultPrefetcher (com.google.idea.blaze.base.prefetch.DefaultPrefetcher)4 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)3 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)3 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)3 Before (org.junit.Before)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 BlazeTestCase (com.google.idea.blaze.base.BlazeTestCase)2 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)2