<commit_before>/*
 * Copyright (c) 2013-2015 Cinchapi Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cinchapi.concourse;

import java.util.Map;
import java.util.Set;

import org.cinchapi.concourse.util.Convert;
import org.cinchapi.concourse.util.TestData;
import org.junit.Assert;
import org.junit.Test;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

/**
 * Integration tests to verify the resolvable link functionality.
 * 
 * @author <NAME>
 */
public class ResolvableLinkTest extends ConcourseIntegrationTest {
    
    @Test
    public void testInsertRemoteResolvableLink(){
        String key = "age";
        int value = 10;
        int count = TestData.getScaleCount();
        for(int i = 1; i <= value + count; ++i){
            client.add(key, i);
        }
        JsonObject json = new JsonObject();
        json.addProperty("friends", Convert.stringToResolvableLinkInstruction("age > "+value));
        client.insert(json.toString(), 1);
        Set<Object> friends = client.select("friends", 1);
        Assert.assertEquals(count, friends.size());
    }
    
    @Test
    public void testInsertLocalResolvableLink(){
        JsonObject json1 = new JsonObject();
        JsonObject json2 = new JsonObject();
        JsonObject json3 = new JsonObject();
        JsonObject json4 = new JsonObject();
        json1.addProperty("foo", 10);
        json1.addProperty("name", "Jeff");
        json1.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json2.addProperty("foo", 20);
        json2.addProperty("name", "Jeff");
        json2.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json3.addProperty("foo", 30);
        json3.addProperty("name", "John");
        json3.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json4.addProperty("foo", 40);
        json4.addProperty("name", "Jeff");
        json4.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        JsonArray array = new JsonArray();
        array.add(json1);
        array.add(json2);
        array.add(json3);
        array.add(json4);
        String json = array.toString();
        client.insert(json);
        Map<Long, Set<Object>> data = client.select("similar_to", "name = Jeff");
        for(Set<Object> set : data.values()){
            Assert.assertEquals(2, set.size());
        }
        Set<Long> records = client.find("name = John");
        for(long record : records){
            Assert.assertTrue(client.find("similar_to lnk2 "+record).isEmpty());
        }
    }

}
<commit_msg>add more unit tests<commit_after>/*
 * Copyright (c) 2013-2015 Cinchapi Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cinchapi.concourse;

import java.util.Map;
import java.util.Set;

import org.cinchapi.concourse.util.Convert;
import org.cinchapi.concourse.util.TestData;
import org.junit.Assert;
import org.junit.Test;

import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

/**
 * Integration tests to verify the resolvable link functionality.
 * 
 * @author <NAME>
 */
public class ResolvableLinkTest extends ConcourseIntegrationTest {
    
    @Test
    public void testInsertRemoteResolvableLink(){
        String key = "age";
        int value = 10;
        int count = TestData.getScaleCount();
        for(int i = 1; i <= value + count; ++i){
            client.add(key, i);
        }
        JsonObject json = new JsonObject();
        json.addProperty("friends", Convert.stringToResolvableLinkInstruction("age > "+value));
        client.insert(json.toString(), 1);
        Set<Object> friends = client.select("friends", 1);
        Assert.assertEquals(count, friends.size());
    }
    
    @Test
    public void testInsertLocalResolvableLink(){
        JsonObject json1 = new JsonObject();
        JsonObject json2 = new JsonObject();
        JsonObject json3 = new JsonObject();
        JsonObject json4 = new JsonObject();
        json1.addProperty("foo", 10);
        json1.addProperty("name", "Jeff");
        json1.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json2.addProperty("foo", 20);
        json2.addProperty("name", "Jeff");
        json2.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json3.addProperty("foo", 30);
        json3.addProperty("name", "John");
        json3.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json4.addProperty("foo", 40);
        json4.addProperty("name", "Jeff");
        json4.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        JsonArray array = new JsonArray();
        array.add(json1);
        array.add(json2);
        array.add(json3);
        array.add(json4);
        String json = array.toString();
        client.insert(json);
        Map<Long, Set<Object>> data = client.select("similar_to", "name = Jeff");
        for(Set<Object> set : data.values()){
            Assert.assertEquals(2, set.size());
        }
        Set<Long> records = client.find("name = John");
        for(long record : records){
            Assert.assertTrue(client.find("similar_to lnk2 "+record).isEmpty());
        }
    }
    
    @Test
    public void testInsertLocalAndRemoteResolvableLink(){
        client.add("foo", 1, 1);
        client.add("name", "Jeff", 1);
        client.add("foo", 2, 2);
        client.add("name", "Jeffery", 2);
        JsonObject json1 = new JsonObject();
        JsonObject json2 = new JsonObject();
        JsonObject json3 = new JsonObject();
        JsonObject json4 = new JsonObject();
        json1.addProperty("foo", 10);
        json1.addProperty("name", "Jeff");
        json1.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json2.addProperty("foo", 20);
        json2.addProperty("name", "Jeff");
        json2.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json3.addProperty("foo", 30);
        json3.addProperty("name", "John");
        json3.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        json4.addProperty("foo", 40);
        json4.addProperty("name", "Jeff");
        json4.addProperty("similar_to", "@foo < 50 and name = Jeff@");
        JsonArray array = new JsonArray();
        array.add(json1);
        array.add(json2);
        array.add(json3);
        array.add(json4);
        String json = array.toString();
        client.insert(json);
        Map<Long, Set<Object>> data = client.select("similar_to", "name = Jeff and foo != 1");
        for(Set<Object> set : data.values()){
            Assert.assertEquals(3, set.size());
        }
        Set<Long> records = client.find("name != Jeff");
        for(long record : records){
            Assert.assertTrue(client.find("similar_to lnk2 "+record).isEmpty());
        }
    }
    
    @Test
    public void testInsertRemoteResolvableLinkInExistingRecord(){
        long record1 = client.add("company", "Cinchapi");
        long record2 = client.add("company", "Cinchapi");
        long record3 = client.add("company", "Cinchapi");
        JsonObject json = new JsonObject();
        json.addProperty("co_workers", Convert.stringToResolvableLinkInstruction("company = Cinchapi"));
        client.insert(json.toString(), Lists.newArrayList(record1, record2, record3));
        Map<Long, Set<Object>> data = client.select("co_workers", Lists.newArrayList(record1, record2, record3));
        for(Set<Object> set : data.values()){
            Assert.assertEquals(2, set.size());
        }
    }

}

{'fraction_non_alphanumeric': 0.13741799437675725, 'fraction_numerical': 0.019329896907216496, 'mean_word_length': 2.8506991429860173, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2148419', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2449, 'n_words': 646}