<commit_before>package com.kryptnostic.client.tests;

import javax.inject.Inject;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.kryptnostic.api.v1.client.KryptnosticContext;
import com.kryptnostic.api.v1.exceptions.types.BadRequestException;
import com.kryptnostic.api.v1.exceptions.types.ResourceNotFoundException;

/**
 * Kryptnostic client tests. Primarily testing the functionality of
 * KryptnosticConnection.
 * 
 * @author <NAME>
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=AnnotationConfigContextLoader.class,classes=TestConfiguration.class)
public class ClientTests {
    @Inject
    private KryptnosticContext kryptnosticContext;

    @Test
    public void uploadDocumentTest() {
        String document = "lo and behold.";
        String id = null;
        try {
            id = kryptnosticContext.uploadDocument(document);
        } catch (BadRequestException e) {
            e.printStackTrace();
        }
        String retrieved = null;
        try {
            retrieved = kryptnosticContext.getDocument(id);
        } catch (ResourceNotFoundException e) {
            e.printStackTrace();
        }
        Assert.assertFalse(retrieved == null);
        Assert.assertEquals(retrieved, document);
    }

}<commit_msg>Add unit test for KryptnosticContext.updateDocument<commit_after>package com.kryptnostic.client.tests;

import javax.inject.Inject;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.kryptnostic.api.v1.client.KryptnosticContext;
import com.kryptnostic.api.v1.exceptions.types.BadRequestException;
import com.kryptnostic.api.v1.exceptions.types.ResourceNotFoundException;

/**
 * Kryptnostic client tests. Primarily testing the functionality of KryptnosticConnection.
 * 
 * @author <NAME>
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = TestConfiguration.class)
public class ClientTests {
    @Inject
    private KryptnosticContext kryptnosticContext;

    @Test
    public void uploadDocumentGetDocumentTest() {
        String document = "lo and behold.";
        String id = null;
        try {
            id = kryptnosticContext.uploadDocument(document);
        } catch (BadRequestException e) {
            e.printStackTrace();
        }
        String retrieved = null;
        try {
            retrieved = kryptnosticContext.getDocument(id);
        } catch (ResourceNotFoundException e) {
            e.printStackTrace();
        }
        Assert.assertFalse(retrieved == null);
        Assert.assertEquals(retrieved, document);
    }

    @Test
    public void updateDocumentTest() {
        String document = "what is best in life? the wind in your hair. falcons at your wrist.";
        String id = null;
        try {
            id = kryptnosticContext.uploadDocument(document);
        } catch (BadRequestException e) {
            e.printStackTrace();
        }
        String newDocument = "what is best in life? To crush your enemies, see them driven before you, and to hear the lamentation of the loved ones.";
        try {
            kryptnosticContext.updateDocument(id, newDocument);
        } catch (ResourceNotFoundException e1) {
            e1.printStackTrace();
        }
        
        String retrieved = null;
        try {
            retrieved = kryptnosticContext.getDocument(id);
        } catch (ResourceNotFoundException e) {
            e.printStackTrace();
        }
        Assert.assertFalse(retrieved == null);
        Assert.assertEquals(retrieved, newDocument);
    }
}
{'fraction_non_alphanumeric': 0.08974987739087788, 'fraction_numerical': 0.0034330554193231977, 'mean_word_length': 3.1622448979591837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4738302', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1088, 'n_words': 233}