XmlParserTest.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:FHIR-Server 作者:
@SuppressWarnings("deprecation")
@Test
public void testEncodeBundleOldIdForm() throws InterruptedException {
    Bundle b = new Bundle();
    b.getCategories().addTag("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/message", "Message");

    InstantDt pub = InstantDt.withCurrentTime();
    Thread.sleep(2);

    Patient p1 = new Patient();
    p1.addName().addFamily("Family1");
    BundleEntry entry = b.addEntry();
    entry.getId().setValue("1");
    entry.setResource(p1);
    entry.getSummary().setValueAsString("this is the summary");

    Patient p2 = new Patient();
    p2.addName().addFamily("Family2");
    entry = b.addEntry();
    entry.getId().setValue("2");
    entry.setLinkAlternate(new StringDt("http://foo/bar"));
    entry.setLinkSearch(new StringDt("http://foo/bar/search"));
    entry.setResource(p2);

    BundleEntry deletedEntry = b.addEntry();
    deletedEntry.setId(new IdDt("Patient/3"));
    deletedEntry.setDeleted(InstantDt.withCurrentTime());

    String bundleString = ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(b);
    ourLog.info(bundleString);

    List<String> strings = new ArrayList<String>();
    strings.add("<category term=\"http://hl7.org/fhir/tag/message\" label=\"Message\" scheme=\"http://hl7.org/fhir/tag\"/>");
    strings.addAll(Arrays.asList("<entry>", "<id>1</id>", "</Patient>", "<summary type=\"xhtml\">", "<div", "</entry>"));
    strings.addAll(Arrays.asList("<entry>", "<id>2</id>", "<link rel=\"alternate\" href=\"http://foo/bar\"/>", "<link rel=\"search\" href=\"http://foo/bar/search\"/>", "</entry>"));
    strings.addAll(Arrays.asList("<at:deleted-entry", "ref=\"Patient/3", "/>"));
    assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));
    assertThat(bundleString, not(containsString("at:by")));

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号