@@ -0,0 +1,2079 @@
+package ca.corefacility.bioinformatics.irida.web.controller.test.integration;%0A%0Aimport com.google.common.net.HttpHeaders;%0Aimport com.jayway.restassured.response.Response;%0Aimport org.junit.Test;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.http.HttpStatus;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport static com.jayway.restassured.RestAssured.get;%0Aimport static com.jayway.restassured.RestAssured.given;%0Aimport static com.jayway.restassured.path.json.JsonPath.from;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0A/**%0A * Integration tests for project samples.%0A *%0A * @author Franklin Bristow %3Cfranklin.bristow@phac-aspc.gc.ca%3E%0A */%0Apublic class ProjectSamplesIntegrationTest %7B%0A    private static final Logger logger = LoggerFactory.getLogger(ProjectSamplesIntegrationTest.class);%0A%0A    @Test%0A    public void testAddSampleToProject() %7B%0A        Map%3CString, String%3E sample = new HashMap%3C%3E();%0A        sample.put(%22sampleName%22, %22sample 1%22);%0A%0A        // load a project%0A        String projectsJson = get(%22/projects%22).asString();%0A        String projectUri = from(projectsJson).get(%22resource.resources%5B0%5D.links%5B0%5D.href%22);%0A        // get the uri for creating samples associated with the project.%0A        String projectJson = get(projectUri).asString();%0A        String samplesUri = from(projectJson).get(%22resource.links.find%7Bit.rel == 'project/samples'%7D.href%22);%0A%0A        // post that uri%0A        Response r = given().body(sample).expect().response().statusCode(HttpStatus.CREATED.value()).when().post(samplesUri);%0A%0A        // check that the locations are set appropriately.%0A        String location = r.getHeader(HttpHeaders.LOCATION);%0A        String linkLocation = r.getHeader(HttpHeaders.LINK);%0A%0A        assertNotNull(location);%0A        assertTrue(location.matches(%22%5Ehttp://localhost:8080/api/samples/%5Ba-f0-9%5C%5C-%5D+$%22));%0A%0A        assertNotNull(linkLocation);%0A        assertTrue(linkLocation.matches(%22%5E%3Chttp://localhost:8080/api/projects/%5Ba-f0-9%5C%5C-%5D+/samples/%5Ba-f0-9%5C%5C-%5D+%3E; rel=relationship$%22));%0A    %7D%0A%7D%0A

Test that samples can be added to a project without previously being persisted.