<commit_before>package org.flymine.util;

import junit.framework.TestCase;

import org.flymine.model.testmodel.*;

public class ModelUtilTest extends TestCase
{
    public ModelUtilTest(String arg) {
        super(arg);
    }

    public void testGetFieldTypeCollection() {
        assertEquals(ModelUtil.COLLECTION, ModelUtil.getFieldType(Company.class, "departments"));
    }

    public void testGetFieldTypeAttribute() {
        assertEquals(ModelUtil.ATTRIBUTE, ModelUtil.getFieldType(Company.class, "name"));
    }

    public void testGetFieldTypeReference() {
        assertEquals(ModelUtil.REFERENCE, ModelUtil.getFieldType(Company.class, "address"));
    }
}
<commit_msg>Added tests for checkKey() method<commit_after>package org.flymine.util;

import junit.framework.TestCase;

import org.flymine.model.testmodel.*;

public class ModelUtilTest extends TestCase
{
    public ModelUtilTest(String arg) {
        super(arg);
    }

    public void testGetFieldTypeCollection() {
        assertEquals(ModelUtil.COLLECTION, ModelUtil.getFieldType(Company.class, "departments"));
    }

    public void testGetFieldTypeAttribute() {
        assertEquals(ModelUtil.ATTRIBUTE, ModelUtil.getFieldType(Company.class, "name"));
    }

    public void testGetFieldTypeReference() {
        assertEquals(ModelUtil.REFERENCE, ModelUtil.getFieldType(Company.class, "address"));
    }


    public void testCheckKeyValidObject() throws Exception {
        Address address = new Address();
        address.setAddress("Employee Street, BVille");

        CEO employee = new CEO();
        employee.setName("EmployeeB1");
        employee.setFullTime(true);
        employee.setAddress(address);
        employee.setAge(40);
        employee.setTitle("Mr.");
        employee.setSalary(45000);

        assertTrue(ModelUtil.checkKey(employee));
    }

    public void testCheckKeyInvalidObjectNoReference() throws Exception {

        CEO employee = new CEO();
        employee.setName("EmployeeB1");
        employee.setFullTime(true);
        employee.setAge(40);
        employee.setTitle("Mr.");
        employee.setSalary(45000);

        assertFalse(ModelUtil.checkKey(employee));
    }

    public void testCheckKeyInvalidObjectNoAttribute() throws Exception {
        Address address = new Address();
        address.setAddress("Employee Street, BVille");

        CEO employee = new CEO();
        employee.setFullTime(true);
        employee.setAddress(address);
        employee.setAge(40);
        employee.setTitle("Mr.");
        employee.setSalary(45000);

        assertFalse(ModelUtil.checkKey(employee));
                    }

    public void testCheckKeyNullObject() throws Exception {
        try {
            ModelUtil.checkKey(null);
            fail ("Expected: NullPointerException");
        } catch (NullPointerException e) {
        }
    }


}

{'fraction_non_alphanumeric': 0.10711793440334962, 'fraction_numerical': 0.008025122121423587, 'mean_word_length': 3.1133428981348636, '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': '5523789', 'n_tokens_mistral': 802, 'n_tokens_neox': 762, 'n_words': 143}