<commit_before>package org.sfm.datastax;

import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.annotations.Table;
import org.junit.Test;
import org.sfm.beans.DbObject;
import org.sfm.datastax.beans.DbObjectWithAlias;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

public class DatastaxCrudTest extends AbstractDatastaxTest {

    @Test
    public void testCrud() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {
                DatastaxCrud<DbObject, Long> crud =
                        DatastaxMapperFactory.newInstance().crud(DbObject.class, Long.class).to(session, "dbobjects");
                testCrudDbObject(crud, DbObject.newInstance());
            }
        });
    }

    private <T extends DbObject> void testCrudDbObject(DatastaxCrud<T, Long> crud, T object) {

        assertNull(crud.read(object.getId()));

        crud.save(object);

        assertEquals(object, crud.read(object.getId()));

        object.setEmail("updated");

        crud.save(object);

        assertEquals(object, crud.read(object.getId()));

        crud.delete(object.getId());

        assertNull(crud.read(object.getId()));
    }

    @Test
    public void testCreateTTL() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {
                DatastaxCrud<DbObject, Long> crud =
                        DatastaxMapperFactory.newInstance().crud(DbObject.class, Long.class).to(session, "dbobjects");

                DbObject object = DbObject.newInstance();
                crud.saveWithTtl(object, 1);

                assertEquals(object, crud.read(object.getId()));
                Thread.sleep(2000);
                assertNull(crud.read(object.getId()));

                DbObject object2 = DbObject.newInstance();
                crud.save(object2, 1, System.currentTimeMillis());

                assertEquals(object2, crud.read(object2.getId()));
                Thread.sleep(2000);<commit_msg> change ttl test<commit_after>package org.sfm.datastax;

import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.annotations.Table;
import org.junit.Test;
import org.sfm.beans.DbObject;
import org.sfm.datastax.beans.DbObjectWithAlias;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

public class DatastaxCrudTest extends AbstractDatastaxTest {

    @Test
    public void testCrud() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {
                DatastaxCrud<DbObject, Long> crud =
                        DatastaxMapperFactory.newInstance().crud(DbObject.class, Long.class).to(session, "dbobjects");
                testCrudDbObject(crud, DbObject.newInstance());
            }
        });
    }

    private <T extends DbObject> void testCrudDbObject(DatastaxCrud<T, Long> crud, T object) {

        assertNull(crud.read(object.getId()));

        crud.save(object);

        assertEquals(object, crud.read(object.getId()));

        object.setEmail("updated");

        crud.save(object);

        assertEquals(object, crud.read(object.getId()));

        crud.delete(object.getId());

        assertNull(crud.read(object.getId()));
    }

    @Test
    public void testCreateTTL() throws Exception {
        testInSession(new Callback() {
            @Override
            public void call(Session session) throws Exception {
                DatastaxCrud<DbObject, Long> crud =
                        DatastaxMapperFactory.newInstance().crud(DbObject.class, Long.class).to(session, "dbobjects");

                DbObject object = DbObject.newInstance();
                crud.saveWithTtl(object, 1);
                Thread.sleep(100);

                assertEquals(object, crud.read(object.getId()));
                Thread.sleep(2000);
                assertNull(crud.read(object.getId()));

                DbObject object2 = DbObject.newInstance();
                crud.save(object2, 1, System.currentTimeMillis());
                Thread.sleep(100);

                assertEquals(object2, crud.read(object2.getId()));
                Thread.sleep(2000);
{'fraction_non_alphanumeric': 0.11297915265635508, 'fraction_numerical': 0.0076216095045953825, 'mean_word_length': 2.469673405909798, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3872186', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1229, 'n_words': 220}