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 Nick Hewitt
 *
 */
@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);
    }

}

@@ -627,19 +627,16 @@
 ality of
-%0A *
  Kryptno
@@ -651,16 +651,16 @@
 ection.%0A
+
  * %0A * @
@@ -753,17 +753,19 @@
 n(loader
-=
+ = 
 Annotati
@@ -796,16 +796,19 @@
 ass,
+ 
 classes
-=
+ = 
 Test
@@ -959,16 +959,27 @@
 Document
+GetDocument
 Test() %7B
@@ -1512,10 +1512,979 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void updateDocumentTest() %7B%0A        String document = %22what is best in life? the wind in your hair. falcons at your wrist.%22;%0A        String id = null;%0A        try %7B%0A            id = kryptnosticContext.uploadDocument(document);%0A        %7D catch (BadRequestException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        String newDocument = %22what is best in life? To crush your enemies, see them driven before you, and to hear the lamentation of the loved ones.%22;%0A        try %7B%0A            kryptnosticContext.updateDocument(id, newDocument);%0A        %7D catch (ResourceNotFoundException e1) %7B%0A            e1.printStackTrace();%0A        %7D%0A        %0A        String retrieved = null;%0A        try %7B%0A            retrieved = kryptnosticContext.getDocument(id);%0A        %7D catch (ResourceNotFoundException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        Assert.assertFalse(retrieved == null);%0A        Assert.assertEquals(retrieved, newDocument);%0A    %7D%0A
 %7D%0A

Add unit test for KryptnosticContext.updateDocument