<commit_before>package org.sfm.datastax;

import com.datastax.driver.core.*;
import org.junit.Test;
import org.sfm.beans.DbObject;
import org.sfm.map.Mapper;

import java.util.Date;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;


public class SettableDataMapperTest extends AbstractDatastaxTest {

    @Test
    public void testInsertDbObjects() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {

                PreparedStatement preparedStatement = session.prepare("insert into " +
                        "dbobjects(id, name, email, creation_time, type_ordinal, type_name) " +
                        "values(?, ?, ?, ?, ?, ?)");
                DbObject dbObject = DbObject.newInstance();

                DatastaxBinder<DbObject> datastaxBinder = DatastaxMapperFactory.newInstance().mapFrom(DbObject.class);

                session.execute(datastaxBinder.mapTo(dbObject, preparedStatement));

                DatastaxMapper<DbObject> dbObjectDatastaxMapper = DatastaxMapperFactory.newInstance().mapTo(DbObject.class);
                DbObject actual = dbObjectDatastaxMapper.iterator(session.execute(session.prepare("select * from dbobjects where id = ?").bind(dbObject.getId()))).next();
                assertEquals(dbObject, actual);

                session.execute(session.prepare("delete from dbobjects where id = ?").bind(dbObject.getId()));
            }
        });
    }

    @Override
    protected void tearDown(Session session) {
        session.execute("DELETE FROM dbobjects where id = 2666");
    }
}<commit_msg>#228 clean resources<commit_after>package org.sfm.datastax;

import com.datastax.driver.core.*;
import org.junit.Test;
import org.sfm.beans.DbObject;
import org.sfm.map.Mapper;

import java.util.Date;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;


public class SettableDataMapperTest extends AbstractDatastaxTest {

    DbObject dbObject = DbObject.newInstance();

    @Test
    public void testInsertDbObjects() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {

                PreparedStatement preparedStatement = session.prepare("insert into " +
                        "dbobjects(id, name, email, creation_time, type_ordinal, type_name) " +
                        "values(?, ?, ?, ?, ?, ?)");

                DatastaxBinder<DbObject> datastaxBinder = DatastaxMapperFactory.newInstance().mapFrom(DbObject.class);

                session.execute(datastaxBinder.mapTo(dbObject, preparedStatement));

                DatastaxMapper<DbObject> dbObjectDatastaxMapper = DatastaxMapperFactory.newInstance().mapTo(DbObject.class);
                BoundStatement boundStatement = session.prepare("select * from dbobjects where id = ?").bind(dbObject.getId());
                ResultSet execute = session.execute(boundStatement);
                DbObject actual = dbObjectDatastaxMapper.iterator(execute).next();
                assertEquals(dbObject, actual);

            }
        });
    }

    @Override
    protected void tearDown(Session session) {
        session.execute(session.prepare("delete from dbobjects where id = ?").bind(dbObject.getId()));
    }
}
{'fraction_non_alphanumeric': 0.10541901095647024, 'fraction_numerical': 0.00207284572105419, 'mean_word_length': 2.9006928406466512, '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': '2894193', 'n_tokens_mistral': 934, 'n_tokens_neox': 885, 'n_words': 176}