<commit_before>package nl.fontys.sofa.limo.orientdb.dao;

import java.util.List;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import nl.fontys.sofa.limo.api.dao.IconDAO;
import nl.fontys.sofa.limo.domain.Icon;
import nl.fontys.sofa.limo.domain.category.TimeCategory;
import nl.fontys.sofa.limo.orientdb.mock.MockOrientDBAccess;
import nl.fontys.sofa.limo.orientdb.mock.OrientDBDAOFactoryMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.netbeans.junit.NbTestCase;

public class OrientDBIconDAOTest extends NbTestCase {

    private IconDAO iconDAO;

    public OrientDBIconDAOTest(String testCase) {
        super(testCase);
    }

    @Before
    @Override
    public void setUp() {
        OrientDBDAOFactoryMock orientDBDAOFactory = new OrientDBDAOFactoryMock();
        iconDAO = orientDBDAOFactory.getIconDAO();
    }

    @After
    @Override
    public void tearDown() {
        iconDAO = null;
        MockOrientDBAccess.getInstance().closeConnection();
    }

    /**
     * Test of findAll method, of class OrientDBIconDAO.
     */
    @Test
    public void testFindAll() {
        List<Icon> icons = iconDAO.findAll();
        assertTrue(icons.isEmpty());
    }

    /**
     * Test of findById method, of class OrientDBIconDAO.
     */
    @Test
    public void testFindById() {
        Icon icon = iconDAO.findById("");
        assertNull(icon);
        icon = iconDAO.findById("38129803980");
        assertNull(icon);
    }

    /**
     * Test of insert method, of class OrientDBIconDAO.
     */
    @Test
    public void testInsert() {
        Icon icon = new Icon();
        iconDAO.insert(icon);
        List<Icon> icons = iconDAO.findAll();
        assertEquals(1, icons.size());
        Icon foundIcon = iconDAO.findById(icons.get(0).getId());
        assertEquals(icon.getId(), foundIcon.getId());
        Assert.assertArrayEquals(icon.getIconBytes(), foundIcon.getIconBytes());
    }

    /**
     * Test of update method, of class OrientDBIconDAO.
     */
    @Test
    public void testUpdate() {
        byte[] newIconBytes = new byte[]{1, 2, 3};
        Icon icon = new Icon();
        boolean updateSuccess = iconDAO.update(icon);
        assertFalse(updateSuccess);
        iconDAO.insert(icon);
        icon = iconDAO.findById(icon.getId());
        icon.setIcon(newIconBytes);
        updateSuccess = iconDAO.update(icon);
        assertTrue(updateSuccess);
        icon = iconDAO.findById(icon.getId());
        Assert.assertArrayEquals(newIconBytes, icon.getIconBytes());
    }

    /**
     * Test of delete method, of class OrientDBIconDAO.
     */
    @Test<commit_msg>- Changed IconDAO tests to fit renamed "Icon" methods<commit_after>package nl.fontys.sofa.limo.orientdb.dao;

import java.util.List;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import nl.fontys.sofa.limo.api.dao.IconDAO;
import nl.fontys.sofa.limo.domain.Icon;
import nl.fontys.sofa.limo.domain.category.TimeCategory;
import nl.fontys.sofa.limo.orientdb.mock.MockOrientDBAccess;
import nl.fontys.sofa.limo.orientdb.mock.OrientDBDAOFactoryMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.netbeans.junit.NbTestCase;

public class OrientDBIconDAOTest extends NbTestCase {

    private IconDAO iconDAO;

    public OrientDBIconDAOTest(String testCase) {
        super(testCase);
    }

    @Before
    @Override
    public void setUp() {
        OrientDBDAOFactoryMock orientDBDAOFactory = new OrientDBDAOFactoryMock();
        iconDAO = orientDBDAOFactory.getIconDAO();
    }

    @After
    @Override
    public void tearDown() {
        iconDAO = null;
        MockOrientDBAccess.getInstance().closeConnection();
    }

    /**
     * Test of findAll method, of class OrientDBIconDAO.
     */
    @Test
    public void testFindAll() {
        List<Icon> icons = iconDAO.findAll();
        assertTrue(icons.isEmpty());
    }

    /**
     * Test of findById method, of class OrientDBIconDAO.
     */
    @Test
    public void testFindById() {
        Icon icon = iconDAO.findById("");
        assertNull(icon);
        icon = iconDAO.findById("38129803980");
        assertNull(icon);
    }

    /**
     * Test of insert method, of class OrientDBIconDAO.
     */
    @Test
    public void testInsert() {
        Icon icon = new Icon();
        iconDAO.insert(icon);
        List<Icon> icons = iconDAO.findAll();
        assertEquals(1, icons.size());
        Icon foundIcon = iconDAO.findById(icons.get(0).getId());
        assertEquals(icon.getId(), foundIcon.getId());
        Assert.assertArrayEquals(icon.getIconByteArray(), foundIcon.getIconByteArray());
    }

    /**
     * Test of update method, of class OrientDBIconDAO.
     */
    @Test
    public void testUpdate() {
        byte[] newIconBytes = new byte[]{1, 2, 3};
        Icon icon = new Icon();
        boolean updateSuccess = iconDAO.update(icon);
        assertFalse(updateSuccess);
        iconDAO.insert(icon);
        icon = iconDAO.findById(icon.getId());
        icon.setIconByteArray(newIconBytes);
        updateSuccess = iconDAO.update(icon);
        assertTrue(updateSuccess);
        icon = iconDAO.findById(icon.getId());
        Assert.assertArrayEquals(newIconBytes, icon.getIconByteArray());
    }

    /**
     * Test of delete method, of class OrientDBIconDAO.
     */
    @Test
{'fraction_non_alphanumeric': 0.11516213847502191, 'fraction_numerical': 0.005609114811568799, 'mean_word_length': 2.8975409836065573, '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': '5400498', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1809, 'n_words': 351}