/**
 * 
 */
package com.github.podd.restlet.test;

import org.junit.Assert;
import org.junit.Test;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Status;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;

import com.github.ansell.restletutils.test.RestletTestUtils;
import com.github.podd.utils.PoddWebConstants;

/**
 * @author kutila
 * 
 */
public class ListArtifactsResourceImplTest extends AbstractResourceImplTest
{
    
    /**
     * Test authenticated access to list Artifacts in HTML
     */
    @Test
    public void testListArtifactsBasicHtml() throws Exception
    {
        // prepare: add two artifacts
        final String artifactUri1 = this.loadTestArtifact("/test/artifacts/basicProject-1-internal-object.rdf");
        final String artifactUri2 = this.loadTestArtifact("/test/artifacts/basic-2-internal-objects.rdf");
        
        final ClientResource listArtifactsClientResource =
                new ClientResource(this.getUrl(PoddWebConstants.PATH_ARTIFACT_LIST));
        
        final Representation results =
                RestletTestUtils.doTestAuthenticatedRequest(listArtifactsClientResource, Method.GET, null,
                        MediaType.TEXT_HTML, Status.SUCCESS_OK, this.testWithAdminPrivileges);
        
        final String body = results.getText();
        
        // verify:
        System.out.println(body);
        Assert.assertTrue("Page does not identify Administrator", body.contains("Administrator"));
        Assert.assertFalse("Page contained a 404 error", body.contains("ERROR: 404"));
        
        Assert.assertTrue("Missing heading on page - Project Listing", body.contains("Projects Listing"));
        Assert.assertTrue("Missng artifact 1 URI on page", body.contains(artifactUri1));
        Assert.assertTrue("Missng artifact 2 URI on page", body.contains(artifactUri2));
        
        this.assertFreemarker(body);
    }
    
}

@@ -1074,32 +1074,323 @@
 IST));%0A        %0A
+        listArtifactsClientResource.addQueryParameter(PoddWebConstants.KEY_PUBLISHED, %22true%22);%0A        listArtifactsClientResource.addQueryParameter(PoddWebConstants.KEY_UNPUBLISHED, %22true%22);%0A        %0A        // Representation results = listArtifactsClientResource.get(MediaType.TEXT_HTML);%0A
         final Re
@@ -1412,16 +1412,16 @@
 sults =%0A
-
         
@@ -1725,16 +1725,29 @@
 println(
+%22results:%22 + 
 body);%0A 
@@ -1993,23 +1993,25 @@
  page - 
-Proje
+Artifa
 ct
+s
  Listing
@@ -2028,21 +2028,22 @@
 ntains(%22
-Proje
+Artifa
 cts List

add query parameters to list artifacts test