Start working on operations in client
This commit is contained in:
parent
dae2a810d6
commit
45f30deee2
|
@ -68,6 +68,7 @@ import ca.uhn.fhir.rest.gclient.IDeleteWithQueryTyped;
|
|||
import ca.uhn.fhir.rest.gclient.IGetPage;
|
||||
import ca.uhn.fhir.rest.gclient.IGetPageTyped;
|
||||
import ca.uhn.fhir.rest.gclient.IGetTags;
|
||||
import ca.uhn.fhir.rest.gclient.IOperation;
|
||||
import ca.uhn.fhir.rest.gclient.IParam;
|
||||
import ca.uhn.fhir.rest.gclient.IQuery;
|
||||
import ca.uhn.fhir.rest.gclient.IRead;
|
||||
|
@ -1440,4 +1441,10 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOperation operation() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import ca.uhn.fhir.rest.gclient.ICreate;
|
|||
import ca.uhn.fhir.rest.gclient.IDelete;
|
||||
import ca.uhn.fhir.rest.gclient.IGetPage;
|
||||
import ca.uhn.fhir.rest.gclient.IGetTags;
|
||||
import ca.uhn.fhir.rest.gclient.IOperation;
|
||||
import ca.uhn.fhir.rest.gclient.IRead;
|
||||
import ca.uhn.fhir.rest.gclient.ITransaction;
|
||||
import ca.uhn.fhir.rest.gclient.IUntypedQuery;
|
||||
|
@ -342,4 +343,9 @@ public interface IGenericClient {
|
|||
*/
|
||||
<T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId);
|
||||
|
||||
/**
|
||||
* Implementation of the FHIR "extended operations" action
|
||||
*/
|
||||
IOperation operation();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package ca.uhn.fhir.rest.gclient;
|
||||
|
||||
public interface IOperation {
|
||||
|
||||
}
|
|
@ -13,10 +13,13 @@ public class CustomThymeleafNarrativeGeneratorTest {
|
|||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorTest.class);
|
||||
|
||||
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||
|
||||
@Test
|
||||
public void testGenerator() {
|
||||
|
||||
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
|
||||
gen.setFhirContext(ourCtx);
|
||||
|
||||
Practitioner p = new Practitioner();
|
||||
p.addIdentifier("sys", "val1");
|
||||
|
|
|
@ -9,3 +9,4 @@
|
|||
/target/
|
||||
/target/
|
||||
/target/
|
||||
/target/
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.*;
|
|||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
|
@ -31,9 +32,11 @@ import org.mockito.stubbing.Answer;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
|
||||
|
@ -79,6 +82,32 @@ public class GenericClientTestDstu2 {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameters() throws Exception {
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setValue(new StringDt("STRINGVALIN1"));
|
||||
inParams.addParameter().setValue(new StringDt("STRINGVALIN2"));
|
||||
String reqString = ourCtx.newXmlParser().encodeResourceToString(inParams);
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
outParams.addParameter().setValue(new StringDt("STRINGVALOUT1"));
|
||||
outParams.addParameter().setValue(new StringDt("STRINGVALOUT2"));
|
||||
final String respString = ourCtx.newXmlParser().encodeResourceToString(outParams);
|
||||
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_JSON + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<ReaderInputStream>() {
|
||||
@Override
|
||||
public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8")); }});
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
||||
// client.operation().onServer().withParameters(inParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
|
||||
|
@ -125,11 +154,11 @@ public class GenericClientTestDstu2 {
|
|||
|
||||
p1 = (Patient) response.get(0);
|
||||
assertEquals(new IdDt("Patient/1/_history/1"), p1.getId().toUnqualified());
|
||||
// assertEquals("PATIENT1", p1.getName().get(0).getFamily().get(0).getValue());
|
||||
// assertEquals("PATIENT1", p1.getName().get(0).getFamily().get(0).getValue());
|
||||
|
||||
p2 = (Patient) response.get(1);
|
||||
assertEquals(new IdDt("Patient/2/_history/2"), p2.getId().toUnqualified());
|
||||
// assertEquals("PATIENT2", p2.getName().get(0).getFamily().get(0).getValue());
|
||||
// assertEquals("PATIENT2", p2.getName().get(0).getFamily().get(0).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -2,3 +2,4 @@ target/
|
|||
/target
|
||||
*.log
|
||||
*.log*
|
||||
/target/
|
||||
|
|
Loading…
Reference in New Issue