<commit_before>package org.ccci.gto.android.common.db

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.ccci.gto.android.common.db.Contract.RootTable
import org.ccci.gto.android.common.db.model.Root
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [28])
class ExpressionTest {
    private lateinit var dao: AbstractDao

    @Before
    @Throws(Exception::class)
    fun setup() {
        dao = mock()
        whenever(dao.tableName(eq(Root::class.java))).thenReturn(RootTable.TABLE_NAME)
    }

    @Test
    fun testEqualsSql() {
        val equalsExpression: Expression = RootTable.FIELD_TEST.eq("1")
        assertThat(equalsExpression.buildSql(dao).first, equalTo("(root.test == ?)"))
    }

    @Test
    fun testNotEqualsSql() {
        val notEqualsExpression: Expression = RootTable.FIELD_TEST.ne("1")
        assertThat(notEqualsExpression.buildSql(dao).first, equalTo("(root.test != ?)"))
    }

    @Test
    fun testCount() {
        val countExpression: Expression = RootTable.FIELD_TEST.count()
        assertThat(countExpression.buildSql(dao).first, equalTo("COUNT (root.test)"))
    }

    @Test
    fun testCountInHaving() {
        val countExpression: Expression = RootTable.FIELD_TEST.count().eq(1)
        assertThat(countExpression.buildSql(dao).first, equalTo("(COUNT (root.test) == 1)"))
    }
}
<commit_msg>don't rely on testCommon for ExpressionTest<commit_after>package org.ccci.gto.android.common.db

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import org.ccci.gto.android.common.db.model.Model1
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.Config

private const val TABLE_NAME = "root"
private const val FIELD_NAME = "test"
private val FIELD = Table.forClass(Model1::class.java).field("test")

@RunWith(AndroidJUnit4::class)
@Config(sdk = [28])
class ExpressionTest {
    private lateinit var dao: AbstractDao

    @Before
    fun setup() {
        dao = mock()
        whenever(dao.tableName(eq(Model1::class.java))).thenReturn(TABLE_NAME)
    }

    @Test
    fun testEqualsSql() {
        assertEquals("($TABLE_NAME.$FIELD_NAME == ?)", FIELD.eq("1").buildSql(dao).first)
    }

    @Test
    fun testNotEqualsSql() {
        assertEquals("($TABLE_NAME.$FIELD_NAME != ?)", FIELD.ne("1").buildSql(dao).first)
    }

    @Test
    fun testCount() {
        assertEquals("COUNT ($TABLE_NAME.$FIELD_NAME)", FIELD.count().buildSql(dao).first)
    }

    @Test
    fun testCountInHaving() {
        assertEquals("(COUNT ($TABLE_NAME.$FIELD_NAME) == 1)", FIELD.count().eq(1).buildSql(dao).first)
    }
}

{'fraction_non_alphanumeric': 0.13266623628147192, 'fraction_numerical': 0.008069722401549387, 'mean_word_length': 4.006462035541196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '142244', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1020, 'n_words': 162}