<commit_before>package com.ebuddy.cassandra.dao;

import static org.testng.Assert.assertEquals;

import java.util.Arrays;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.ebuddy.cassandra.StructureDao;
import com.ebuddy.cassandra.TypeReference;

import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.Serializer;
import me.prettyprint.hector.api.ddl.ComparatorType;
import me.prettyprint.hector.api.factory.HFactory;

/**
 * System tests for ThriftStructureDao.
 * Requires local Cassandra 1.2.x+ to be running with a default cluster ("Test Cluster")
 *
 * @author <NAME> <a href="mailto:<EMAIL>"><EMAIL></a>
 */
public class ThriftStructureDaoSystemTest {

    private static final String TEST_CLUSTER = "Test Cluster";
    private static final String LOCALHOST_IP = "localhost";
    private static final String TEST_KEYSPACE = "ThriftStructureDaoSystemTest";
    private final String columnFamily = "testpojo";

    private Cluster cluster;
    private ColumnFamilyOperations<String,String,Object> operations;
    private StructureDao<String> dao;

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        cluster = HFactory.getOrCreateCluster(TEST_CLUSTER, LOCALHOST_IP);
        Keyspace keyspace = HFactory.createKeyspace(TEST_KEYSPACE, cluster);
        Serializer<String> keySerializer = StringSerializer.get();
        Serializer<String> columnNameSerializer = StringSerializer.get();
        Serializer<Object> valueSerializer = StructureSerializer.get();
        operations = new ColumnFamilyTemplate<String,String,Object>(keyspace,
                                                                    keySerializer,
                                                                    columnNameSerializer,
                                                                    valueSerializer);

        dao = new ThriftStructureDao<String>(operations);
        createSchema();
    }

    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception {
        cluster.dropKeyspace(TEST_KEYSPACE, true);
    }

    @Test(groups = {"unit"})
    public void shouldReadAndWriteTestPojo() throws Exception {
        TestPojo testObject = new TestPojo("v1", 42L, true, Arrays.asList("e1", "e2"));
        String rowKey = "pojo0";
        String pathString = "a/b/c";
        TypeReference<TestPojo> typeReference = new TypeReference<TestPojo>() { };

        dao.writeToPath(columnFamily, rowKey, pathString, testObject);
        TestPojo result = dao.readFromPath(columnFamily, rowKey, pathString, typeReference);

        assertEquals(result, testObject);
    }

    private void createSchema() {
        cluster.addKeyspace(HFactory.createKeyspaceDefinition(TEST_KEYSPACE), true);
        cluster.addColumnFamily(HFactory.createColumnFamilyDefinition(TEST_KEYSPACE,
                                                                      columnFamily,
                                                                      ComparatorType.UTF8TYPE));
    }
}
<commit_msg>change test group in system test to be "system" instead of "unit"<commit_after>package com.ebuddy.cassandra.dao;

import static org.testng.Assert.assertEquals;

import java.util.Arrays;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.ebuddy.cassandra.StructureDao;
import com.ebuddy.cassandra.TypeReference;

import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.Serializer;
import me.prettyprint.hector.api.ddl.ComparatorType;
import me.prettyprint.hector.api.factory.HFactory;

/**
 * System tests for ThriftStructureDao.
 * Requires local Cassandra 1.2.x+ to be running with a default cluster ("Test Cluster")
 *
 * @author <NAME> <a href="mailto:<EMAIL>"><EMAIL></a>
 */
public class ThriftStructureDaoSystemTest {

    private static final String TEST_CLUSTER = "Test Cluster";
    private static final String LOCALHOST_IP = "localhost";
    private static final String TEST_KEYSPACE = "ThriftStructureDaoSystemTest";
    private final String columnFamily = "testpojo";

    private Cluster cluster;
    private ColumnFamilyOperations<String,String,Object> operations;
    private StructureDao<String> dao;

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        cluster = HFactory.getOrCreateCluster(TEST_CLUSTER, LOCALHOST_IP);
        Keyspace keyspace = HFactory.createKeyspace(TEST_KEYSPACE, cluster);
        Serializer<String> keySerializer = StringSerializer.get();
        Serializer<String> columnNameSerializer = StringSerializer.get();
        Serializer<Object> valueSerializer = StructureSerializer.get();
        operations = new ColumnFamilyTemplate<String,String,Object>(keyspace,
                                                                    keySerializer,
                                                                    columnNameSerializer,
                                                                    valueSerializer);

        dao = new ThriftStructureDao<String>(operations);
        createSchema();
    }

    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception {
        cluster.dropKeyspace(TEST_KEYSPACE, true);
    }

    @Test(groups = {"system"})
    public void shouldReadAndWriteTestPojo() throws Exception {
        TestPojo testObject = new TestPojo("v1", 42L, true, Arrays.asList("e1", "e2"));
        String rowKey = "pojo0";
        String pathString = "a/b/c";
        TypeReference<TestPojo> typeReference = new TypeReference<TestPojo>() { };

        dao.writeToPath(columnFamily, rowKey, pathString, testObject);
        TestPojo result = dao.readFromPath(columnFamily, rowKey, pathString, typeReference);

        assertEquals(result, testObject);
    }

    private void createSchema() {
        cluster.addKeyspace(HFactory.createKeyspaceDefinition(TEST_KEYSPACE), true);
        cluster.addColumnFamily(HFactory.createColumnFamilyDefinition(TEST_KEYSPACE,
                                                                      columnFamily,
                                                                      ComparatorType.UTF8TYPE));
    }
}

{'fraction_non_alphanumeric': 0.08973570989551322, 'fraction_numerical': 0.0027658266748617085, 'mean_word_length': 2.753748558246828, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6275474', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1671, 'n_words': 357}