### Question:
InstantRunBuildContext { public String toXml() throws ParserConfigurationException { return toXml( currentBuild.buildMode == InstantRunBuildMode.FULL ? PersistenceMode.FULL_BUILD : PersistenceMode.INCREMENTAL_BUILD); } InstantRunBuildContext(
            boolean isInstantRunMode,
            @NonNull AndroidVersion androidVersion,
            @Nullable String targetAbi,
            @Nullable String density,
            boolean createSeparateApkForResources); @VisibleForTesting  InstantRunBuildContext(
            @NonNull BuildIdAllocator buildIdAllocator,
            boolean isInstantRunMode,
            @NonNull AndroidVersion androidVersion,
            @Nullable String targetAbi,
            @Nullable String density,
            boolean createSeparateApkForResources); boolean isInInstantRunMode(); void setBuildHasFailed(); boolean getBuildHasFailed(); long getBuildId(); void startRecording(@NonNull TaskType taskType); long stopRecording(@NonNull TaskType taskType); void setVerifierStatus(@NonNull InstantRunVerifierStatus verifierStatus); void setInstantRunEligibilityStatus(@NonNull InstantRunVerifierStatus verifierStatus); @NonNull InstantRunVerifierStatus getVerifierResult(); boolean hasVerifierStatusBeenSet(InstantRunVerifierStatus status); boolean hasPassedVerification(); @NonNull AndroidVersion getAndroidVersion(); @Nullable String getDensity(); @NonNull InstantRunPatchingPolicy getPatchingPolicy(); boolean useSeparateApkForResources(); @NonNull InstantRunBuildMode getBuildMode(); synchronized void addChangedFile(@NonNull FileType fileType, @NonNull File file); @Nullable Build getLastBuild(); long getSecretToken(); void setSecretToken(long token); @VisibleForTesting Collection<Build> getPreviousBuilds(); void loadFromXmlFile(@NonNull File persistedState); @VisibleForTesting void loadFromXml(@NonNull String persistedState); void mergeFromFile(@NonNull File tmpBuildInfoFile); void mergeFrom(@NonNull String tmpBuildInfo); synchronized void close(); String toXml(); void writeTmpBuildInfo(@NonNull File tmpBuildInfo);  }### Answer:
@Test public void testPersistenceFromCleanState() throws ParserConfigurationException { InstantRunBuildContext buildContext = new InstantRunBuildContext( idAllocator, true, new AndroidVersion(23, null), null, null, true); String persistedState = buildContext.toXml(); assertThat(persistedState).isNotEmpty(); assertThat(persistedState).contains(InstantRunBuildContext.ATTR_TIMESTAMP); }
@Test public void testFormatPresence() throws ParserConfigurationException { InstantRunBuildContext buildContext = new InstantRunBuildContext( idAllocator, true, new AndroidVersion(23, null), null, null, true); String persistedState = buildContext.toXml(); assertThat(persistedState).isNotEmpty(); assertThat(persistedState) .contains( InstantRunBuildContext.ATTR_FORMAT + "=\"" + InstantRunBuildContext.CURRENT_FORMAT + "\""); }