001package org.kuali.ole.docstore.common.document; 002 003import org.junit.Assert; 004import org.junit.Test; 005import org.kuali.ole.docstore.common.document.content.enums.DocCategory; 006import org.kuali.ole.docstore.common.document.content.enums.DocFormat; 007import org.kuali.ole.docstore.common.document.content.enums.DocType; 008import org.kuali.ole.docstore.common.document.content.instance.CallNumber; 009import org.kuali.ole.docstore.common.document.content.instance.OleHoldings; 010import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme; 011import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor; 012import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor; 013 014/** 015 * Created with IntelliJ IDEA. 016 * User: jayabharathreddy 017 * Date: 1/7/14 018 * Time: 4:33 PM 019 * To change this template use File | Settings | File Templates. 020 */ 021public class HoldingsTree_UT { 022 023 @Test 024 public void serializeAndDedeserialize() { 025 HoldingsTree holdingsTree = getHoldingsTreeRecord(); 026 String serializeXml = holdingsTree.serialize(holdingsTree); 027 System.out.println(serializeXml); 028 Assert.assertNotNull(serializeXml); 029 030 HoldingsTree holdingsObj = new HoldingsTree(); 031 holdingsObj=(HoldingsTree) holdingsTree.deserialize(serializeXml); 032 Assert.assertSame(holdingsObj, holdingsObj); 033 034 } 035 036 037 038 private HoldingsTree getHoldingsTreeRecord() { 039 HoldingsTree holdingsTree = new HoldingsTree(); 040 holdingsTree.setHoldings(getHoldingsRecord()); 041 holdingsTree.getItems().add(getItemRecord()); 042 return holdingsTree; 043 } 044 045 private Bib getBibRecord() { 046 Bib bib = new Bib(); 047 bib.setCategory(DocCategory.WORK.getCode()); 048 bib.setType(DocType.BIB.getCode()); 049 bib.setFormat(DocFormat.MARC.getCode()); 050 bib.setId("wbm-10000001"); 051 return bib; 052 } 053 054 private Item getItemRecord() { 055 Item item = new ItemOleml(); 056 item.setCategory("work"); 057 item.setType("item"); 058 item.setFormat("oleml"); 059 org.kuali.ole.docstore.common.document.content.instance.Item item1 = new org.kuali.ole.docstore.common.document.content.instance.Item(); 060 item1.setVolumeNumber("123"); 061 item1.setChronology("12344"); 062 item1.setEnumeration("en"); 063 item1.setBarcodeARSL("bararsl"); 064 item.setContent(new ItemOlemlRecordProcessor().toXML(item1)); 065 return item; 066 } 067 068 private Holdings getHoldingsRecord() { 069 Holdings holdings = new PHoldings(); 070 holdings.setCategory(DocCategory.WORK.getCode()); 071 holdings.setType(DocType.HOLDINGS.getCode()); 072 holdings.setFormat(DocFormat.OLEML.getCode()); 073 074 OleHoldings oleHoldings = new OleHoldings(); 075 ShelvingScheme shelvingScheme = new ShelvingScheme(); 076 shelvingScheme.setCodeValue("LCC"); 077 CallNumber callNumber = new CallNumber(); 078 callNumber.setNumber("1234"); 079 callNumber.setShelvingScheme(shelvingScheme); 080 oleHoldings.setCallNumber(callNumber); 081 holdings.setContent(new HoldingOlemlRecordProcessor().toXML(oleHoldings)); 082 holdings.setBib(getBibRecord()); 083 return holdings; 084 } 085 086}