### Question:
PreviewProgram extends BasePreviewProgram { @Override public ContentValues toContentValues() { return toContentValues(false); } private  PreviewProgram(Builder builder); long getChannelId(); int getWeight(); @Override boolean equals(Object other); boolean hasAnyUpdatedValues(PreviewProgram update); @Override String toString(); @Override ContentValues toContentValues(); @RestrictTo(LIBRARY_GROUP) @Override ContentValues toContentValues(boolean includeProtectedFields); static PreviewProgram fromCursor(Cursor cursor); @RestrictTo(LIBRARY_GROUP)
    static final String[] PROJECTION; }### Answer:
@Test public void testPreviewProgramWithSystemContentProvider() { if (!Utils.hasTvInputFramework(InstrumentationRegistry.getContext())) { return; } Channel channel = new Channel.Builder() .setInputId("TestInputService") .setType(TvContractCompat.Channels.TYPE_PREVIEW) .build(); ContentResolver resolver = InstrumentationRegistry.getContext().getContentResolver(); Uri channelUri = resolver.insert(Channels.CONTENT_URI, channel.toContentValues()); assertNotNull(channelUri); PreviewProgram fullyPopulatedProgram = createFullyPopulatedPreviewProgram( ContentUris.parseId(channelUri)); Uri previewProgramUri = resolver.insert(PreviewPrograms.CONTENT_URI, fullyPopulatedProgram.toContentValues()); PreviewProgram programFromSystemDb = loadPreviewProgramFromContentProvider(resolver, previewProgramUri); compareProgram(fullyPopulatedProgram, programFromSystemDb, false); }
@Test public void testPreviewProgramUpdateWithContentProvider() { if (!Utils.hasTvInputFramework(InstrumentationRegistry.getContext())) { return; } Channel channel = new Channel.Builder() .setInputId("TestInputService") .setType(TvContractCompat.Channels.TYPE_PREVIEW) .build(); ContentResolver resolver = InstrumentationRegistry.getContext().getContentResolver(); Uri channelUri = resolver.insert(Channels.CONTENT_URI, channel.toContentValues()); assertNotNull(channelUri); PreviewProgram fullyPopulatedProgram = createFullyPopulatedPreviewProgram( ContentUris.parseId(channelUri)); Uri previewProgramUri = resolver.insert(PreviewPrograms.CONTENT_URI, fullyPopulatedProgram.toContentValues()); PreviewProgram programFromSystemDb = loadPreviewProgramFromContentProvider( resolver, previewProgramUri); compareProgram(fullyPopulatedProgram, programFromSystemDb, false); PreviewProgram updatedProgram = new PreviewProgram.Builder(programFromSystemDb) .setInteractionCount(programFromSystemDb.getInteractionCount() + 1).build(); assertEquals(1, resolver.update( previewProgramUri, updatedProgram.toContentValues(), null, null)); programFromSystemDb = loadPreviewProgramFromContentProvider(resolver, previewProgramUri); compareProgram(updatedProgram, programFromSystemDb, false); updatedProgram = new PreviewProgram.Builder(updatedProgram) .setLongDescription(null).build(); assertEquals(1, resolver.update( previewProgramUri, updatedProgram.toContentValues(), null, null)); programFromSystemDb = loadPreviewProgramFromContentProvider(resolver, previewProgramUri); compareProgram(updatedProgram, programFromSystemDb, false); ContentValues values = new PreviewProgram.Builder().setInteractionCount(1).build() .toContentValues(); assertEquals(1, values.size()); assertEquals(1, resolver.update(previewProgramUri, values, null, null)); programFromSystemDb = loadPreviewProgramFromContentProvider(resolver, previewProgramUri); PreviewProgram expectedProgram = new PreviewProgram.Builder(programFromSystemDb) .setInteractionCount(1).build(); compareProgram(expectedProgram, programFromSystemDb, false); }