View Javadoc

1   package org.kuali.ole.ingest;
2   
3   import org.junit.Test;
4   import org.kuali.ole.OLETranscationalRecordGenerator;
5   import org.kuali.ole.converter.OLEEDIConverter;
6   import org.kuali.ole.ingest.pojo.ProfileAttributeBo;
7   import org.kuali.ole.pojo.OleTxRecord;
8   import org.kuali.ole.pojo.edi.EDIOrders;
9   import org.kuali.ole.pojo.edi.LineItemOrder;
10  
11  import java.io.File;
12  import java.net.URL;
13  import java.util.Arrays;
14  
15  import static junit.framework.Assert.assertNotNull;
16  
17  /**
18   * Created by IntelliJ IDEA.
19   * User: pvsubrah
20   * Date: 4/18/12
21   * Time: 7:55 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class OleTxRecordBuilder_UT {
25      @Test
26      public void testBuild() throws Exception {
27          URL ediResource = getClass().getResource("iu.edi");
28          File ediFile = new File(ediResource.toURI());
29          String ediXML = new OLEEDIConverter().convertToXML(new FileUtil().readFile(ediFile));
30  
31          EDIOrders ediOrders = new OLETranscationalRecordGenerator().fromXml(ediXML);
32          LineItemOrder lineItemOrder = ediOrders.getOrders().get(0).getLineItemOrder().get(0);
33  
34          ProfileAttributeBo profileAttributeBo = new ProfileAttributeBo();
35          profileAttributeBo.setAgendaName("MOCK_AGENDA");
36          profileAttributeBo.setAttributeName("chartCode");
37          profileAttributeBo.setAttributeValue("BL");
38          profileAttributeBo.setAttributeName("itemChartCode");
39          profileAttributeBo.setAttributeValue("BL");
40          OleTxRecord oleTxRecord =
41                  OleTxRecordBuilder.getInstance().build(lineItemOrder, Arrays.asList(profileAttributeBo), ediOrders.getOrders().get(0));
42          assertNotNull(oleTxRecord);
43          String accountNumber = oleTxRecord.getAccountNumber();
44          assertNotNull(accountNumber);
45          String objectCode = oleTxRecord.getObjectCode();
46          assertNotNull(objectCode);
47          System.out.println("Account Number: " + accountNumber);
48          System.out.println("Object Code: " + objectCode);
49  
50  
51      }
52  }