Search in sources :

Example 1 with SyncStats

use of com.google.idea.blaze.base.logging.utils.SyncStats in project intellij by bazelbuild.

the class JavaSyncTest method testSimpleSyncLogging.

@Test
public void testSimpleSyncLogging() throws Exception {
    setProjectView("directories:", "  java/com/google", "targets:", "  //java/com/google:lib");
    workspace.createFile(new WorkspacePath("java/com/google/Source.java"), "package com.google;", "public class Source {}");
    workspace.createFile(new WorkspacePath("java/com/google/Other.java"), "package com.google;", "public class Other {}");
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("java_library").addSource(sourceRoot("java/com/google/Source.java")).addSource(sourceRoot("java/com/google/Other.java"))).build();
    setTargetMap(targetMap);
    runBlazeSync(new BlazeSyncParams.Builder("Sync", SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
    errorCollector.assertNoIssues();
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
    assertThat(blazeProjectData).isNotNull();
    assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
    assertThat(blazeProjectData.workspaceLanguageSettings.getWorkspaceType()).isEqualTo(WorkspaceType.JAVA);
    List<SyncStats> syncStatsList = getSyncStats();
    assertThat(syncStatsList).hasSize(1);
    SyncStats syncStats = syncStatsList.get(0);
    assertThat(syncStats).isNotNull();
    assertThat(syncStats.workspaceType()).isEqualTo(WorkspaceType.JAVA);
    assertThat(syncStats.blazeProjectTargets()).containsExactly(TargetExpression.fromString("//java/com/google:lib"));
    assertThat(syncStats.syncMode()).isEqualTo(SyncMode.INCREMENTAL);
    assertThat(syncStats.syncResult()).isEqualTo(SyncResult.SUCCESS);
    assertThat(syncStats.startTimeInEpochTime()).isNotEqualTo(0);
    assertThat(syncStats.timedEvents()).isNotEmpty();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) SyncStats(com.google.idea.blaze.base.logging.utils.SyncStats) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Aggregations

TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)1 SyncStats (com.google.idea.blaze.base.logging.utils.SyncStats)1 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)1 Test (org.junit.Test)1