1 package org.kuali.ole.ingest.action;
2
3 import org.joda.time.DateTime;
4 import org.junit.Before;
5 import org.junit.Ignore;
6 import org.junit.Test;
7 import org.kuali.ole.BibliographicRecordHandler;
8 import org.kuali.ole.DataCarrierService;
9 import org.kuali.ole.OLEConstants;
10 import org.kuali.ole.describe.service.DiscoveryHelperService;
11 import org.kuali.ole.docstore.model.xmlpojo.work.bib.marc.DataField;
12 import org.kuali.ole.ingest.FileUtil;
13 import org.kuali.ole.ingest.pojo.ProfileAttributeBo;
14 import org.kuali.ole.pojo.bib.BibliographicRecord;
15 import org.kuali.ole.pojo.bib.Collection;
16 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
17 import org.kuali.rice.krms.api.engine.ExecutionOptions;
18 import org.kuali.rice.krms.api.engine.SelectionCriteria;
19 import org.kuali.rice.krms.api.engine.Term;
20 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
21 import org.kuali.rice.krms.framework.engine.BasicExecutionEnvironment;
22 import org.kuali.rice.krms.framework.engine.TermResolutionEngineImpl;
23 import org.mockito.Mock;
24 import org.mockito.Mockito;
25 import org.mockito.MockitoAnnotations;
26 import org.springframework.util.Assert;
27
28 import java.io.File;
29 import java.net.URL;
30 import java.util.Arrays;
31 import java.util.Collections;
32 import java.util.Iterator;
33 import java.util.List;
34
35
36
37
38
39
40
41
42 public class UpdateItemAction_UT {
43
44 @Mock
45 private ExecutionEnvironment mockExecutionEnvironment;
46
47 @Mock
48 private DataCarrierService mockDataCarrierService;
49
50 @Before
51 public void setUp() throws Exception {
52 MockitoAnnotations.initMocks(this);
53 }
54
55
56 @Test
57 public void testRouteToPrincipal() throws Exception {
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 }
79
80
81
82 private List<ProfileAttributeBo> getProfileAttributeBos() {
83 ProfileAttributeBo profileAttributeBo1 = new ProfileAttributeBo();
84 profileAttributeBo1.setAgendaName(OLEConstants.PROFILE_AGENDA_NM);
85 profileAttributeBo1.setId(1);
86 profileAttributeBo1.setAttributeName(OLEConstants.PROFILE_ATTRIBUTE_NM);
87 profileAttributeBo1.setAttributeValue(OLEConstants.PROFILE_ATTRIBUTE_VALUE);
88 List<ProfileAttributeBo> mockProfileAttributes = Arrays.asList(profileAttributeBo1);
89 return mockProfileAttributes;
90 }
91
92 private String getIsbn(BibliographicRecord bibliographicRecord){
93 String isbn=null;
94 List<DataField> marcDataFields = bibliographicRecord.getDatafields() ;
95 for(DataField marcDataField :marcDataFields){
96 if(marcDataField.getTag().equals("020")){
97 isbn = marcDataField.getSubFields().get(0).getValue();
98 break;
99 }
100 }
101 return isbn;
102 }
103
104 public ExecutionEnvironment getMockExecutionEnvironment() {
105 SelectionCriteria sc1 =
106 SelectionCriteria.createCriteria(new DateTime(), Collections.<String, String>emptyMap(), Collections.singletonMap(
107 AgendaDefinition.Constants.EVENT, "foo"));
108 mockExecutionEnvironment = new BasicExecutionEnvironment(sc1, Collections.<Term, Object>emptyMap(), new ExecutionOptions(), new TermResolutionEngineImpl());
109 return mockExecutionEnvironment;
110 }
111 private class MockUpdateItemAction extends UpdateItemAction {
112 @Override
113 protected DataCarrierService getDataCarrierService() {
114 return mockDataCarrierService;
115 }
116 }
117 }