• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EncodingEnum类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ca.uhn.fhir.rest.server.EncodingEnum的典型用法代码示例。如果您正苦于以下问题:Java EncodingEnum类的具体用法?Java EncodingEnum怎么用?Java EncodingEnum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EncodingEnum类属于ca.uhn.fhir.rest.server包,在下文中一共展示了EncodingEnum类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invokeClient

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Override
public BaseOperationOutcome invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException,
		BaseServerResponseException {
	EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
	if (respType == null) {
		return null;
	}
	IParser parser = respType.newParser(myContext);
	BaseOperationOutcome retVal;
	try {
		// TODO: handle if something else than OO comes back
		retVal = (BaseOperationOutcome) parser.parseResource(theResponseReader);
	} catch (DataFormatException e) {
		ourLog.warn("Failed to parse OperationOutcome response", e);
		return null;
	}
	MethodUtil.parseClientRequestResourceHeaders(null, theHeaders, retVal);

	return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:GenericClient.java


示例2: createAppropriateParserForParsingServerRequest

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
protected IParser createAppropriateParserForParsingServerRequest(Request theRequest) {
	String contentTypeHeader = theRequest.getServletRequest().getHeader("content-type");
	EncodingEnum encoding;
	if (isBlank(contentTypeHeader)) {
		encoding = EncodingEnum.XML;
	} else {
		int semicolon = contentTypeHeader.indexOf(';');
		if (semicolon != -1) {
			contentTypeHeader = contentTypeHeader.substring(0, semicolon);
		}
		encoding = EncodingEnum.forContentType(contentTypeHeader);
	}

	if (encoding == null) {
		throw new InvalidRequestException("Request contins non-FHIR conent-type header value: " + contentTypeHeader);
	}

	IParser parser = encoding.newParser(getContext());
	return parser;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:BaseMethodBinding.java


示例3: asHttpRequest

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Override
public HttpRequestBase asHttpRequest(String theUrlBase, Map<String, List<String>> theExtraParams, EncodingEnum theEncoding) {
	StringBuilder b = new StringBuilder();
	b.append(theUrlBase);
	if (!theUrlBase.endsWith("/")) {
		b.append('/');
	}
	b.append(myUrlPath);

	appendExtraParamsWithQuestionMark(myParams, b, b.indexOf("?") == -1);
	appendExtraParamsWithQuestionMark(theExtraParams, b, b.indexOf("?") == -1);

	HttpDelete retVal = new HttpDelete(b.toString());
	super.addHeadersToRequest(retVal);
	return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:17,代码来源:HttpDeleteClientInvocation.java


示例4: testUpdate

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Test
public void testUpdate() throws Exception {

	Patient patient = new Patient();
	patient.addIdentifier("urn:foo", "123");

	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
	when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
	when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
	when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
	when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));

	ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
	MethodOutcome response = client.updatePatient(new IdDt("100"), patient);

	assertEquals(HttpPut.class, capt.getValue().getClass());
	HttpPut post = (HttpPut) capt.getValue();
	assertThat(post.getURI().toASCIIString(), StringEndsWith.endsWith("/Patient/100"));
	assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient"));
	assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue());
	assertEquals("200", response.getId().getVersionIdPart());
	assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:ClientTest.java


示例5: testCreateWithUtf8Characters

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
/**
 * Test for issue #60
 */
@Test
public void testCreateWithUtf8Characters() throws Exception {
	String name = "測試醫院";
	Organization org = new Organization();
	org.setName(name);
	org.addIdentifier("urn:system", "testCreateWithUtf8Characters_01");

	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), 201, "OK"));
	when(myHttpResponse.getAllHeaders()).thenReturn(new Header[] { new BasicHeader(Constants.HEADER_LOCATION, "/Patient/44/_history/22") });
	when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	int count = 0;
	client.create().resource(org).prettyPrint().encodedXml().execute();
	assertEquals(1, capt.getAllValues().get(count).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
	assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(count).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
	assertThat(extractBody(capt, count), containsString("<name value=\"測試醫院\"/>"));
	count++;

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:28,代码来源:GenericClientTest.java


示例6: testSetDefaultEncoding

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Test
	public void testSetDefaultEncoding() throws Exception {

		String msg = ourCtx.newJsonParser().encodeResourceToString(new Patient());

		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()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
//		Header[] headers = new Header[] { new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT"),
//				new BasicHeader(Constants.HEADER_CONTENT_LOCATION, "http://foo.com/Patient/123/_history/2333"),
//				new BasicHeader(Constants.HEADER_CATEGORY, "http://foo/tagdefinition.html; scheme=\"http://hl7.org/fhir/tag\"; label=\"Some tag\"") };
//		when(myHttpResponse.getAllHeaders()).thenReturn(headers);

		IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

		(client).setEncoding(EncodingEnum.JSON);
		int count = 0;
		
		client.read(Patient.class, new IdDt("Patient/1234"));
		assertEquals("http://example.com/fhir/Patient/1234?_format=json", capt.getAllValues().get(count).getURI().toString());
		count++;

	}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:26,代码来源:GenericClientTest.java


示例7: testSearchWithClientEncodingAndPrettyPrintConfig

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void testSearchWithClientEncodingAndPrettyPrintConfig() throws Exception {

	String msg = getPatientFeedWithOneResult();

	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_XML + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

	GenericClient client = (GenericClient) ourCtx.newRestfulGenericClient("http://example.com/fhir");
	client.setPrettyPrint(true);
	client.setEncoding(EncodingEnum.JSON);

	//@formatter:off
	Bundle response = client.search()
			.forResource(Patient.class)
			.execute();
	//@formatter:on

	assertEquals("http://example.com/fhir/Patient?_format=json&_pretty=true", capt.getValue().getURI().toString());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:26,代码来源:GenericClientTest.java


示例8: testTransaction

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Test
public void testTransaction() throws Exception {
	String bundleStr = IOUtils.toString(getClass().getResourceAsStream("/bundle.json"));
	Bundle bundle = ourCtx.newJsonParser().parseBundle(bundleStr);

	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()).thenReturn(new ReaderInputStream(new StringReader(bundleStr), Charset.forName("UTF-8")));

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	//@formatter:off
	Bundle response = client.transaction()
			.withBundle(bundle)
			.execute();
	//@formatter:on

	assertEquals("http://example.com/fhir", capt.getValue().getURI().toString());
	assertEquals(bundle.getEntries().get(0).getId(), response.getEntries().get(0).getId());
	assertEquals(EncodingEnum.XML.getBundleContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:GenericClientTest.java


示例9: load

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
private void load() {
    new AsyncTask<Void, Void, ca.uhn.fhir.model.api.Bundle>(
    ) {
        @Override
        protected ca.uhn.fhir.model.api.Bundle doInBackground(Void... params) {
            try {
                //This should be put somewhere in the app, where the context is saved, instead of
                //Retrieving it each time.
                FhirContext fc = FhirContext.forDstu2();
                //Skip retrieval of conformance statement...
                fc.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
                IGenericClient gc = fc.newRestfulGenericClient("http://spark-dstu2.furore.com/fhir"); //$NON-NLS-1$
                // Comment this line to use XML instead of JSON
                gc.setEncoding(EncodingEnum.JSON);
                return gc.search().forResource(Patient.class).execute();
            } catch (Throwable e) {
                Log.e("Err", "Err, handle this better", e);
            }
            return null;


        }

        @Override
        protected void onPostExecute(ca.uhn.fhir.model.api.Bundle o) {
            super.onPostExecute(o);
            List<Patient> list = o != null ? o.getResources(Patient.class) : Collections.<Patient>emptyList();
            mAdapter.setData(list);
        }
    }.execute();

}
 
开发者ID:botunge,项目名称:HapiFhirAndroidSample,代码行数:33,代码来源:PatientListActivity.java


示例10: parseNarrative

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
private String parseNarrative(HomeRequest theRequest, EncodingEnum theCtEnum, String theResultBody) {
	try {
		IResource resource = theCtEnum.newParser(getContext(theRequest)).parseResource(theResultBody);
		String retVal = resource.getText().getDiv().getValueAsString();
		return StringUtils.defaultString(retVal);
	} catch (Exception e) {
		ourLog.error("Failed to parse resource", e);
		return "";
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:11,代码来源:Controller.java


示例11: parseResourceBody

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
protected IResource parseResourceBody(String theResourceBody) {
	EncodingEnum encoding = determineRawEncoding(theResourceBody);
	if (encoding == null) {
		throw new InvalidRequestException("FHIR client can't determine resource encoding");
	}
	return encoding.newParser(myContext).parseResource(theResourceBody);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:8,代码来源:GenericClient.java


示例12: determineRawEncoding

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
/**
 * Returns null if encoding can't be determined
 */
private static EncodingEnum determineRawEncoding(String theResourceBody) {
	EncodingEnum encoding = null;
	for (int i = 0; i < theResourceBody.length() && encoding == null; i++) {
		switch (theResourceBody.charAt(i)) {
		case '<':
			encoding = EncodingEnum.XML;
			break;
		case '{':
			encoding = EncodingEnum.JSON;
			break;
		}
	}
	return encoding;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:GenericClient.java


示例13: createExtraParams

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
protected Map<String, List<String>> createExtraParams() {
	HashMap<String, List<String>> retVal = new LinkedHashMap<String, List<String>>();

	if (getEncoding() == EncodingEnum.XML) {
		retVal.put(Constants.PARAM_FORMAT, Collections.singletonList("xml"));
	} else if (getEncoding() == EncodingEnum.JSON) {
		retVal.put(Constants.PARAM_FORMAT, Collections.singletonList("json"));
	}

	if (isPrettyPrint()) {
		retVal.put(Constants.PARAM_PRETTY, Collections.singletonList(Constants.PARAM_PRETTY_VALUE_TRUE));
	}

	return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:16,代码来源:BaseClient.java


示例14: asHttpRequest

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Override
public HttpGet asHttpRequest(String theUrlBase, Map<String, List<String>> theExtraParams, EncodingEnum theEncoding) {
	StringBuilder b = new StringBuilder();
	
	if (!myUrlPath.contains("://")) {
           b.append(theUrlBase);
           if (!theUrlBase.endsWith("/")) {
               b.append('/');
           }
       }
       b.append(myUrlPath);
	
	boolean first = b.indexOf("?") == -1;
	for (Entry<String, List<String>> next : myParameters.entrySet()) {
		if (next.getValue() == null || next.getValue().isEmpty()) {
			continue;
		}
		String nextKey = next.getKey();
		for (String nextValue : next.getValue()) {
			first = addQueryParameter(b, first, nextKey, nextValue);
		}
	}

	appendExtraParamsWithQuestionMark(theExtraParams, b, first);

	HttpGet retVal = new HttpGet(b.toString());
	super.addHeadersToRequest(retVal);

	return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:31,代码来源:HttpGetClientInvocation.java


示例15: invokeServer

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Override
public void invokeServer(RestfulServer theServer, Request theRequest) throws BaseServerResponseException, IOException {
	Object[] params = createParametersForServerRequest(theRequest, null);

	if (myIdParamIndex != null) {
		params[myIdParamIndex] = theRequest.getId();
	}
	if (myVersionIdParamIndex != null) {
		params[myVersionIdParamIndex] = theRequest.getId();
	}

	TagList resp = (TagList) invokeServerMethod(params);

	for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
		IServerInterceptor next = theServer.getInterceptors().get(i);
		boolean continueProcessing = next.outgoingResponse(theRequest, resp, theRequest.getServletRequest(), theRequest.getServletResponse());
		if (!continueProcessing) {
			return;
		}
	}
	
	EncodingEnum responseEncoding = RestfulServerUtils.determineResponseEncodingWithDefault(theServer, theRequest.getServletRequest());

	HttpServletResponse response = theRequest.getServletResponse();
	response.setContentType(responseEncoding.getResourceContentType());
	response.setStatus(Constants.STATUS_HTTP_200_OK);
	response.setCharacterEncoding(Constants.CHARSETNAME_UTF_8);

	theServer.addHeadersToResponse(response);

	IParser parser = responseEncoding.newParser(getContext());
	parser.setPrettyPrint(RestfulServerUtils.prettyPrintResponse(theServer, theRequest));
	PrintWriter writer = response.getWriter();
	try {
		parser.encodeTagListToWriter(resp, writer);
	} finally {
		writer.close();
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:40,代码来源:GetTagsMethodBinding.java


示例16: createAppropriateParserForParsingResponse

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
protected IParser createAppropriateParserForParsingResponse(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode) {
	EncodingEnum encoding = EncodingEnum.forContentType(theResponseMimeType);
	if (encoding == null) {
		NonFhirResponseException ex = NonFhirResponseException.newInstance(theResponseStatusCode, theResponseMimeType, theResponseReader);
		populateException(ex, theResponseReader);
		throw ex;
	}

	IParser parser = encoding.newParser(getContext());
	return parser;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:12,代码来源:BaseMethodBinding.java


示例17: parseRequestObject

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Override
protected Object parseRequestObject(Request theRequest) throws IOException {
	EncodingEnum encoding = RestfulServerUtils.determineRequestEncoding(theRequest);
	IParser parser = encoding.newParser(getContext());
	BufferedReader requestReader = theRequest.getServletRequest().getReader();

	if (theRequest.getRequestType() == RequestTypeEnum.GET) {
		return null;
	}

	Class<? extends IBaseResource> wantedResourceType = getContext().getResourceDefinition("Parameters").getImplementingClass();
	return parser.parseResource(wantedResourceType, requestReader);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:14,代码来源:OperationMethodBinding.java


示例18: detectEncoding

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
public static EncodingEnum detectEncoding(String theBody) {
	for (int i = 0; i < theBody.length(); i++) {
		switch (theBody.charAt(i)) {
			case '<':
				return EncodingEnum.XML;
			case '{':
				return EncodingEnum.JSON;
		}
	}
	return EncodingEnum.XML;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:12,代码来源:MethodUtil.java


示例19: testCreate

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {

	Patient patient = new Patient();
	patient.addIdentifier("urn:foo", "123");

	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
	when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
	when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
	when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
	when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));

	ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
	CapturingInterceptor interceptor = new CapturingInterceptor();
	client.registerInterceptor(interceptor);

	MethodOutcome response = client.createPatient(patient);

	assertEquals(interceptor.getLastRequest().getURI().toASCIIString(), "http://foo/Patient");

	assertEquals(HttpPost.class, capt.getValue().getClass());
	HttpPost post = (HttpPost) capt.getValue();
	assertThat(IOUtils.toString(post.getEntity().getContent()), StringContains.containsString("<Patient"));
	assertEquals("http://example.com/fhir/Patient/100/_history/200", response.getId().getValue());
	assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(0).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
	assertEquals("200", response.getId().getVersionIdPart());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:29,代码来源:ClientTest.java


示例20: testSearchWithFormatAndPrettyPrint

import ca.uhn.fhir.rest.server.EncodingEnum; //导入依赖的package包/类
@Test
public void testSearchWithFormatAndPrettyPrint() throws Exception {

	String msg = getPatientFeedWithOneResult();

	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
	when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
	when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
	when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

	// TODO: document this

	ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
	client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
	assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getAllValues().get(0).getURI().toString());

	when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
	client.setEncoding(EncodingEnum.JSON); // this needs to be actually
											// implemented
	client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
	assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02&_format=json", capt.getAllValues().get(1).getURI().toString());

	when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
	client.setPrettyPrint(true);
	client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
	assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02&_format=json&_pretty=true", capt.getAllValues().get(2).getURI().toString());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:30,代码来源:ClientTest.java



注:本文中的ca.uhn.fhir.rest.server.EncodingEnum类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AttSignature类代码示例发布时间:2022-05-22
下一篇:
Java VKApiUsers类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap