InstantRunAnalyticsHelper { @NonNull public static AndroidStudioStats.InstantRunStatus generateAnalyticsProto( @NonNull InstantRunBuildContext instantRunBuildContext) { AndroidStudioStats.InstantRunStatus.Builder builder = AndroidStudioStats.InstantRunStatus.newBuilder(); builder.setBuildMode(convert(instantRunBuildContext.getBuildMode())); builder.setPatchingPolicy(convert(instantRunBuildContext.getPatchingPolicy())); builder.setVerifierStatus(convert(instantRunBuildContext.getVerifierResult().orElse(null))); InstantRunBuildContext.Build last = instantRunBuildContext.getLastBuild(); if (last != null) { for (InstantRunBuildContext.Artifact artifact : last.getArtifacts()) { builder.addArtifact( AndroidStudioStats.InstantRunArtifact.newBuilder() .setType(convert(artifact.getType()))); } } return builder.build(); } private  InstantRunAnalyticsHelper(); @NonNull static AndroidStudioStats.InstantRunStatus generateAnalyticsProto(
            @NonNull InstantRunBuildContext instantRunBuildContext);  }
@Test public void testAnalyticsHelper() { when(mInstantRunBuildContext.getLastBuild()).thenReturn(mBuild); when(mInstantRunBuildContext.getBuildMode()).thenReturn(InstantRunBuildMode.HOT_WARM); when(mInstantRunBuildContext.getPatchingPolicy()) .thenReturn(InstantRunPatchingPolicy.MULTI_DEX); when(mInstantRunBuildContext.getVerifierResult()).thenReturn(Optional.of( InstantRunVerifierStatus.COMPATIBLE)); when(mBuild.getArtifacts()).thenReturn(ImmutableList.of( new InstantRunBuildContext.Artifact(InstantRunBuildContext.FileType.RESOURCES, new File("resources.ap_")), new InstantRunBuildContext.Artifact(InstantRunBuildContext.FileType.RELOAD_DEX, new File("reload.dex")) )); AndroidStudioStats.InstantRunStatus proto = InstantRunAnalyticsHelper.generateAnalyticsProto(mInstantRunBuildContext); assertEquals(AndroidStudioStats.InstantRunStatus.BuildMode.HOT_WARM, proto.getBuildMode()); assertEquals(AndroidStudioStats.InstantRunStatus.PatchingPolicy.MULTI_DEX, proto.getPatchingPolicy()); assertEquals(AndroidStudioStats.InstantRunStatus.VerifierStatus.COMPATIBLE, proto.getVerifierStatus()); assertEquals(2, proto.getArtifactCount()); List<AndroidStudioStats.InstantRunArtifact> artifacts = proto.getArtifactList(); assertEquals("RESOURCES", artifacts.get(0).getType().toString()); assertEquals("RELOAD_DEX", artifacts.get(1).getType().toString()); }