Failing test cleanup
This commit is contained in:
parent
82ec721c99
commit
01c7618867
|
@ -2651,6 +2651,11 @@ public class GenericClientDstu2Test {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFormatParamStyle(RequestFormatParamStyleEnum theRequestFormatParamStyle) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EncodingEnum getEncoding() {
|
public EncodingEnum getEncoding() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
|
@ -1,41 +1,45 @@
|
||||||
package ca.uhn.fhir.rest.client;
|
package ca.uhn.fhir.rest.client;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import static org.junit.Assert.fail;
|
import ca.uhn.fhir.rest.annotation.Operation;
|
||||||
import static org.mockito.Mockito.mock;
|
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||||
import static org.mockito.Mockito.when;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
|
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||||
|
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||||
|
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||||
|
import ca.uhn.fhir.rest.param.*;
|
||||||
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.io.input.ReaderInputStream;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.ProtocolVersion;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.client.methods.HttpUriRequest;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
|
import org.apache.http.message.BasicStatusLine;
|
||||||
|
import org.hl7.fhir.r4.model.IdType;
|
||||||
|
import org.hl7.fhir.r4.model.Parameters;
|
||||||
|
import org.hl7.fhir.r4.model.StringType;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
|
||||||
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.apache.commons.io.input.ReaderInputStream;
|
import static org.junit.Assert.fail;
|
||||||
import org.apache.http.HttpResponse;
|
import static org.mockito.Mockito.mock;
|
||||||
import org.apache.http.ProtocolVersion;
|
import static org.mockito.Mockito.when;
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.methods.*;
|
|
||||||
import org.apache.http.message.BasicHeader;
|
|
||||||
import org.apache.http.message.BasicStatusLine;
|
|
||||||
import org.hl7.fhir.r4.model.IdType;
|
|
||||||
import org.hl7.fhir.r4.model.Parameters;
|
|
||||||
import org.hl7.fhir.r4.model.StringType;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
|
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
|
||||||
import ca.uhn.fhir.rest.annotation.Operation;
|
|
||||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
|
||||||
import ca.uhn.fhir.rest.client.api.*;
|
|
||||||
import ca.uhn.fhir.rest.param.*;
|
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
|
||||||
|
|
||||||
public class OperationClientR4Test {
|
public class OperationClientR4Test {
|
||||||
|
|
||||||
|
@ -48,13 +52,6 @@ public class OperationClientR4Test {
|
||||||
private ArgumentCaptor<HttpUriRequest> capt;
|
private ArgumentCaptor<HttpUriRequest> capt;
|
||||||
private IGenericClient ourGenClient;
|
private IGenericClient ourGenClient;
|
||||||
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void afterClassClearContext() {
|
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
ourCtx = FhirContext.forR4();
|
ourCtx = FhirContext.forR4();
|
||||||
|
@ -75,7 +72,7 @@ public class OperationClientR4Test {
|
||||||
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(ourHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
when(ourHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||||
@Override
|
@Override
|
||||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
public InputStream answer(InvocationOnMock theInvocation) {
|
||||||
return new ReaderInputStream(new StringReader(retVal), Charset.forName("UTF-8"));
|
return new ReaderInputStream(new StringReader(retVal), Charset.forName("UTF-8"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -97,8 +94,8 @@ public class OperationClientR4Test {
|
||||||
assertEquals("FOO", response.getParameter().get(0).getName());
|
assertEquals("FOO", response.getParameter().get(0).getName());
|
||||||
|
|
||||||
HttpPost value = (HttpPost) capt.getAllValues().get(0);
|
HttpPost value = (HttpPost) capt.getAllValues().get(0);
|
||||||
String requestBody = IOUtils.toString(((HttpPost) value).getEntity().getContent(), Charsets.UTF_8);
|
String requestBody = IOUtils.toString(value.getEntity().getContent(), Charsets.UTF_8);
|
||||||
IOUtils.closeQuietly(((HttpPost) value).getEntity().getContent());
|
IOUtils.closeQuietly(value.getEntity().getContent());
|
||||||
ourLog.info(requestBody);
|
ourLog.info(requestBody);
|
||||||
Parameters request = ourCtx.newXmlParser().parseResource(Parameters.class, requestBody);
|
Parameters request = ourCtx.newXmlParser().parseResource(Parameters.class, requestBody);
|
||||||
assertEquals("http://foo/$nonrepeating", value.getURI().toASCIIString());
|
assertEquals("http://foo/$nonrepeating", value.getURI().toASCIIString());
|
||||||
|
@ -110,7 +107,7 @@ public class OperationClientR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonRepeatingGenericUsingUrl() throws Exception {
|
public void testNonRepeatingGenericUsingUrl() {
|
||||||
ourGenClient
|
ourGenClient
|
||||||
.operation()
|
.operation()
|
||||||
.onServer()
|
.onServer()
|
||||||
|
@ -126,9 +123,8 @@ public class OperationClientR4Test {
|
||||||
assertEquals("http://foo/$nonrepeating?valstr=str&valtok=sys2%7Cval2", value.getURI().toASCIIString());
|
assertEquals("http://foo/$nonrepeating?valstr=str&valtok=sys2%7Cval2", value.getURI().toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOperationOnInstanceWithIncompleteInstanceId() throws Exception {
|
public void testOperationOnInstanceWithIncompleteInstanceId() {
|
||||||
try {
|
try {
|
||||||
ourGenClient
|
ourGenClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -148,8 +144,8 @@ public class OperationClientR4Test {
|
||||||
assertEquals("FOO", response.getParameter().get(0).getName());
|
assertEquals("FOO", response.getParameter().get(0).getName());
|
||||||
|
|
||||||
HttpPost value = (HttpPost) capt.getAllValues().get(0);
|
HttpPost value = (HttpPost) capt.getAllValues().get(0);
|
||||||
String requestBody = IOUtils.toString(((HttpPost) value).getEntity().getContent(), Charsets.UTF_8);
|
String requestBody = IOUtils.toString(value.getEntity().getContent(), Charsets.UTF_8);
|
||||||
IOUtils.closeQuietly(((HttpPost) value).getEntity().getContent());
|
IOUtils.closeQuietly(value.getEntity().getContent());
|
||||||
ourLog.info(requestBody);
|
ourLog.info(requestBody);
|
||||||
Parameters request = ourCtx.newXmlParser().parseResource(Parameters.class, requestBody);
|
Parameters request = ourCtx.newXmlParser().parseResource(Parameters.class, requestBody);
|
||||||
assertEquals("http://foo/$nonrepeating", value.getURI().toASCIIString());
|
assertEquals("http://foo/$nonrepeating", value.getURI().toASCIIString());
|
||||||
|
@ -160,11 +156,10 @@ public class OperationClientR4Test {
|
||||||
assertEquals("sys|val", ((StringType) request.getParameter().get(1).getValue()).getValue());
|
assertEquals("sys|val", ((StringType) request.getParameter().get(1).getValue()).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface IOpClient extends IBasicClient {
|
public interface IOpClient extends IBasicClient {
|
||||||
|
|
||||||
@Operation(name = "$andlist", idempotent = true)
|
@Operation(name = "$andlist", idempotent = true)
|
||||||
public Parameters andlist(
|
Parameters andlist(
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@OperationParam(name = "valstr", max = 10) StringAndListParam theValStr,
|
@OperationParam(name = "valstr", max = 10) StringAndListParam theValStr,
|
||||||
@OperationParam(name = "valtok", max = 10) TokenAndListParam theValTok
|
@OperationParam(name = "valtok", max = 10) TokenAndListParam theValTok
|
||||||
|
@ -172,7 +167,7 @@ public class OperationClientR4Test {
|
||||||
);
|
);
|
||||||
|
|
||||||
@Operation(name = "$andlist-withnomax", idempotent = true)
|
@Operation(name = "$andlist-withnomax", idempotent = true)
|
||||||
public Parameters andlistWithNoMax(
|
Parameters andlistWithNoMax(
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@OperationParam(name = "valstr") StringAndListParam theValStr,
|
@OperationParam(name = "valstr") StringAndListParam theValStr,
|
||||||
@OperationParam(name = "valtok") TokenAndListParam theValTok
|
@OperationParam(name = "valtok") TokenAndListParam theValTok
|
||||||
|
@ -180,7 +175,7 @@ public class OperationClientR4Test {
|
||||||
);
|
);
|
||||||
|
|
||||||
@Operation(name = "$nonrepeating", idempotent = true)
|
@Operation(name = "$nonrepeating", idempotent = true)
|
||||||
public Parameters nonrepeating(
|
Parameters nonrepeating(
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@OperationParam(name = "valstr") StringParam theValStr,
|
@OperationParam(name = "valstr") StringParam theValStr,
|
||||||
@OperationParam(name = "valtok") TokenParam theValTok
|
@OperationParam(name = "valtok") TokenParam theValTok
|
||||||
|
@ -188,7 +183,7 @@ public class OperationClientR4Test {
|
||||||
);
|
);
|
||||||
|
|
||||||
@Operation(name = "$orlist", idempotent = true)
|
@Operation(name = "$orlist", idempotent = true)
|
||||||
public Parameters orlist(
|
Parameters orlist(
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@OperationParam(name = "valstr", max = 10) List<StringOrListParam> theValStr,
|
@OperationParam(name = "valstr", max = 10) List<StringOrListParam> theValStr,
|
||||||
@OperationParam(name = "valtok", max = 10) List<TokenOrListParam> theValTok
|
@OperationParam(name = "valtok", max = 10) List<TokenOrListParam> theValTok
|
||||||
|
@ -196,7 +191,7 @@ public class OperationClientR4Test {
|
||||||
);
|
);
|
||||||
|
|
||||||
@Operation(name = "$orlist-withnomax", idempotent = true)
|
@Operation(name = "$orlist-withnomax", idempotent = true)
|
||||||
public Parameters orlistWithNoMax(
|
Parameters orlistWithNoMax(
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@OperationParam(name = "valstr") List<StringOrListParam> theValStr,
|
@OperationParam(name = "valstr") List<StringOrListParam> theValStr,
|
||||||
@OperationParam(name = "valtok") List<TokenOrListParam> theValTok
|
@OperationParam(name = "valtok") List<TokenOrListParam> theValTok
|
||||||
|
@ -204,4 +199,9 @@ public class OperationClientR4Test {
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClassClearContext() {
|
||||||
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue