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
22 public class PHoldings_UT {
23
24
25 @Test
26 public void serializeAndDedeserialize() {
27 Holdings holdings = getHoldingsRecord();
28 String serializeXml = holdings.serialize(holdings);
29 Assert.assertNotNull(serializeXml);
30
31 Holdings holdingsObj = new PHoldings();
32 holdingsObj=(Holdings) holdings.deserialize(serializeXml);
33 Assert.assertSame(holdingsObj, holdingsObj);
34 }
35
36
37
38 private Item getItemRecord() {
39 Item item = new ItemOleml();
40 item.setCategory("work");
41 item.setType("item");
42 item.setFormat("oleml");
43 org.kuali.ole.docstore.common.document.content.instance.Item item1 = new org.kuali.ole.docstore.common.document.content.instance.Item();
44 item1.setVolumeNumber("123");
45 item1.setChronology("12344");
46 item1.setEnumeration("en");
47 item1.setBarcodeARSL("bararsl");
48 item.setContent(new ItemOlemlRecordProcessor().toXML(item1));
49 return item;
50 }
51
52 private Holdings getHoldingsRecord() {
53 Holdings holdings = new PHoldings();
54 holdings.setCategory(DocCategory.WORK.getCode());
55 holdings.setType(DocType.HOLDINGS.getCode());
56 holdings.setFormat(DocFormat.OLEML.getCode());
57
58 OleHoldings oleHoldings = new OleHoldings();
59 ShelvingScheme shelvingScheme = new ShelvingScheme();
60 shelvingScheme.setCodeValue("LCC");
61 CallNumber callNumber = new CallNumber();
62 callNumber.setNumber("1234");
63 callNumber.setShelvingScheme(shelvingScheme);
64 oleHoldings.setCallNumber(callNumber);
65 holdings.setContent(new HoldingOlemlRecordProcessor().toXML(oleHoldings));
66 holdings.setBib(getBibRecord());
67 return holdings;
68 }
69
70 private Bib getBibRecord() {
71 Bib bib = new Bib();
72 bib.setCategory(DocCategory.WORK.getCode());
73 bib.setType(DocType.BIB.getCode());
74 bib.setFormat(DocFormat.MARC.getCode());
75 bib.setId("wbm-10000001");
76 return bib;
77 }
78
79 }