1 package org.kuali.ole.docstore.common.document;
2
3 import org.junit.Assert;
4 import org.junit.Test;
5 import org.kuali.ole.docstore.common.document.content.enums.DocCategory;
6 import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
7 import org.kuali.ole.docstore.common.document.content.enums.DocType;
8 import org.kuali.ole.docstore.common.document.content.instance.CallNumber;
9 import org.kuali.ole.docstore.common.document.content.instance.OleHoldings;
10 import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme;
11 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
12 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
13
14
15
16
17
18
19
20
21 public class HoldingsTree_UT {
22
23 @Test
24 public void serializeAndDedeserialize() {
25 HoldingsTree holdingsTree = getHoldingsTreeRecord();
26 String serializeXml = holdingsTree.serialize(holdingsTree);
27 System.out.println(serializeXml);
28 Assert.assertNotNull(serializeXml);
29
30 HoldingsTree holdingsObj = new HoldingsTree();
31 holdingsObj=(HoldingsTree) holdingsTree.deserialize(serializeXml);
32 Assert.assertSame(holdingsObj, holdingsObj);
33
34 }
35
36
37
38 private HoldingsTree getHoldingsTreeRecord() {
39 HoldingsTree holdingsTree = new HoldingsTree();
40 holdingsTree.setHoldings(getHoldingsRecord());
41 holdingsTree.getItems().add(getItemRecord());
42 return holdingsTree;
43 }
44
45 private Bib getBibRecord() {
46 Bib bib = new Bib();
47 bib.setCategory(DocCategory.WORK.getCode());
48 bib.setType(DocType.BIB.getCode());
49 bib.setFormat(DocFormat.MARC.getCode());
50 bib.setId("wbm-10000001");
51 return bib;
52 }
53
54 private Item getItemRecord() {
55 Item item = new ItemOleml();
56 item.setCategory("work");
57 item.setType("item");
58 item.setFormat("oleml");
59 org.kuali.ole.docstore.common.document.content.instance.Item item1 = new org.kuali.ole.docstore.common.document.content.instance.Item();
60 item1.setVolumeNumber("123");
61 item1.setChronology("12344");
62 item1.setEnumeration("en");
63 item1.setBarcodeARSL("bararsl");
64 item.setContent(new ItemOlemlRecordProcessor().toXML(item1));
65 return item;
66 }
67
68 private Holdings getHoldingsRecord() {
69 Holdings holdings = new PHoldings();
70 holdings.setCategory(DocCategory.WORK.getCode());
71 holdings.setType(DocType.HOLDINGS.getCode());
72 holdings.setFormat(DocFormat.OLEML.getCode());
73
74 OleHoldings oleHoldings = new OleHoldings();
75 ShelvingScheme shelvingScheme = new ShelvingScheme();
76 shelvingScheme.setCodeValue("LCC");
77 CallNumber callNumber = new CallNumber();
78 callNumber.setNumber("1234");
79 callNumber.setShelvingScheme(shelvingScheme);
80 oleHoldings.setCallNumber(callNumber);
81 holdings.setContent(new HoldingOlemlRecordProcessor().toXML(oleHoldings));
82 holdings.setBib(getBibRecord());
83 return holdings;
84 }
85
86 }