@Test public void testUpdateWithoutConditionalUrl() throws Exception { Patient patient = new Patient(); patient.addIdentifier().setValue("002"); HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/2"); httpPost.setEntity( new StringEntity( ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); HttpResponse status = ourClient.execute(httpPost); String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent()); ourLog.info("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); assertEquals( "http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("location").getValue()); assertEquals( "http://localhost:" + ourPort + "/Patient/001/_history/002", status.getFirstHeader("content-location").getValue()); assertEquals("Patient/2", new IdType(ourLastId).toUnqualified().getValue()); assertEquals("Patient/2", ourLastIdParam.toUnqualified().getValue()); assertNull(ourLastConditionalUrl); }
@Update() public MethodOutcome updatePatient( @ResourceParam Patient thePatient, @ConditionalUrlParam String theConditional, @IdParam IdDt theIdParam) { ourLastConditionalUrl = theConditional; ourLastId = thePatient.getId(); ourLastIdParam = theIdParam; return new MethodOutcome(new IdDt("Patient/001/_history/002")); }
@Test public void testSearchStillWorks() throws Exception { Patient patient = new Patient(); patient.addIdentifier().setValue("002"); HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_pretty=true"); HttpResponse status = ourClient.execute(httpGet); String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent()); ourLog.info("Response was:\n{}", responseContent); assertTrue(ourLastRequestWasSearch); assertNull(ourLastId); assertNull(ourLastIdParam); assertNull(ourLastConditionalUrl); }