<commit_before>package com.tjeannin.provigen.test.basis;

import java.util.Arrays;
import java.util.List;

import android.database.Cursor;
import android.net.Uri;
import android.test.mock.MockContentResolver;

import com.tjeannin.provigen.InvalidContractException;
import com.tjeannin.provigen.test.ExtendedProviderTestCase;
import com.tjeannin.provigen.test.basis.SimpleContentProvider.ContractOne;
import com.tjeannin.provigen.test.basis.SimpleContentProvider.ContractTwo;

public class SimpleContentProviderTest extends ExtendedProviderTestCase<SimpleContentProvider> {

	private MockContentResolver contentResolver;

	public SimpleContentProviderTest() {
		super(SimpleContentProvider.class, "com.test.simple");
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		contentResolver = getMockContentResolver();
	}

	public void testProviderIsEmpty() {

		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null,
				"", null, "");
		assertEquals(0, cursor.getCount());
		cursor.close();
	}

	public void testInsert() {
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null, "", null, "");
		assertEquals(1, cursor.getCount());
		cursor.close();
	}

	public void testAutoIncrement() {

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		contentResolver.delete(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(3)), "", null);

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		assertEquals(1, getRowCount(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(4))));
		assertEquals(0, getRowCount(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(3))));
	}

	public void testUpgradeFromContractOneToTwo() throws InvalidContractException {

		getProvider().setContractClasses(new Class[] { ContractOne.class });

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		// Check database fits ContractOne.
		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null, "", null, "");
		assertEquals(2, cursor.getColumnCount());
		List<String> columnNameList = Arrays.asList(cursor.getColumnNames());
		assertTrue(columnNameList.contains(ContractOne._ID));
		assertTrue(columnNameList.contains(ContractOne.MY_INT));
		assertFalse(columnNameList.contains(ContractTwo.MY_REAL));
		assertFalse(columnNameList.contains(ContractTwo.MY_STRING));
		cursor.close();

		getProvider().setContractClasses(new Class[] { ContractTwo.class });

		// Check database fits ContractTwo.
		cursor = contentResolver.query(ContractOne.CONTENT_URI, null, "", null, "");
		assertEquals(2, cursor.getColumnCount());
		columnNameList = Arrays.asList(cursor.getColumnNames());
		assertTrue(columnNameList.contains(ContractOne._ID));
		assertTrue(columnNameList.contains(ContractOne.MY_INT));
		assertFalse(columnNameList.contains(ContractTwo.MY_REAL));
		assertFalse(columnNameList.contains(ContractTwo.MY_STRING));
		cursor.close();
	}

	public void testGetMimeType() {
		String mimeType = getProvider().getType(ContractOne.CONTENT_URI);
		assertEquals("vnd.android.cursor.dir/vdn.table_name_simple", mimeType);
	}
}<commit_msg>Fixed contract validation test case.<commit_after>package com.tjeannin.provigen.test.basis;

import java.util.Arrays;
import java.util.List;

import android.database.Cursor;
import android.net.Uri;
import android.test.mock.MockContentResolver;

import com.tjeannin.provigen.InvalidContractException;
import com.tjeannin.provigen.test.ExtendedProviderTestCase;
import com.tjeannin.provigen.test.basis.SimpleContentProvider.ContractOne;
import com.tjeannin.provigen.test.basis.SimpleContentProvider.ContractTwo;

public class SimpleContentProviderTest extends ExtendedProviderTestCase<SimpleContentProvider> {

	private MockContentResolver contentResolver;

	public SimpleContentProviderTest() {
		super(SimpleContentProvider.class, "com.test.simple");
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		contentResolver = getMockContentResolver();
	}

	public void testProviderIsEmpty() {

		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null,
				"", null, "");
		assertEquals(0, cursor.getCount());
		cursor.close();
	}

	public void testInsert() {
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null, "", null, "");
		assertEquals(1, cursor.getCount());
		cursor.close();
	}

	public void testAutoIncrement() {

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));
		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		contentResolver.delete(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(3)), "", null);

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		assertEquals(1, getRowCount(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(4))));
		assertEquals(0, getRowCount(Uri.withAppendedPath(ContractOne.CONTENT_URI, String.valueOf(3))));
	}

	public void testUpgradeFromContractOneToTwo() throws InvalidContractException {

		getProvider().setContractClasses(new Class[] { ContractOne.class });

		contentResolver.insert(ContractOne.CONTENT_URI, getContentValues(ContractOne.class));

		// Check database fits ContractOne.
		Cursor cursor = contentResolver.query(ContractOne.CONTENT_URI, null, "", null, "");
		assertEquals(2, cursor.getColumnCount());
		List<String> columnNameList = Arrays.asList(cursor.getColumnNames());
		assertTrue(columnNameList.contains(ContractOne._ID));
		assertTrue(columnNameList.contains(ContractOne.MY_INT));
		assertFalse(columnNameList.contains(ContractTwo.MY_REAL));
		assertFalse(columnNameList.contains(ContractTwo.MY_STRING));
		cursor.close();

		getProvider().setContractClasses(new Class[] { ContractTwo.class });

		// Check database fits ContractTwo.
		cursor = contentResolver.query(ContractTwo.CONTENT_URI, null, "", null, "");
		assertEquals(4, cursor.getColumnCount());
		columnNameList = Arrays.asList(cursor.getColumnNames());
		assertTrue(columnNameList.contains(ContractTwo._ID));
		assertTrue(columnNameList.contains(ContractTwo.MY_INT));
		assertTrue(columnNameList.contains(ContractTwo.MY_REAL));
		assertTrue(columnNameList.contains(ContractTwo.MY_STRING));
		cursor.close();
	}

	public void testGetMimeType() {
		String mimeType = getProvider().getType(ContractOne.CONTENT_URI);
		assertEquals("vnd.android.cursor.dir/vdn.table_name_simple", mimeType);
	}
}
{'fraction_non_alphanumeric': 0.119988504095416, 'fraction_numerical': 0.0025865785313981893, 'mean_word_length': 7.2075471698113205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110304', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2019, 'n_words': 288}