...
Java
Code Block language java title JUnit package com.example.coa.service; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBElement; import org.junit.Test; import org.kuali.kfs.core.v5_0.GetAccountsResponseGetAccountBalanceResponse; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import junit.framework.TestCase; public class AccountInquiryServiceTestAccountBalanceInquiryServiceTest extends TestCase { @Test public void testGetAccounts() throws Exception { String chartOfAccountsCode List<String> subFunds = new ArrayList<String>(); subFunds.add("PLEQP")"UC"; subFunds.add("PLRES"); subFunds.add("PLBHC"); subFunds.add("PLRHC"); subFunds.add("OPOTF"); subFunds.add("PLBND"); subFunds.add("PLREV"); subFunds.add("PLUNR"); List<String> organizationcodes = new ArrayList<String>(); organizationcodes.add("1832")String accountNumber = "5612710"; organizationcodes.add("1731"); organizationcodes.add("1863"); LocalDate fromDate = LocalDate.parse("2016-08-26"); LocalDate toDate = LocalDate.parse("2016-09-15"); ChartOfAccountsInquiryServiceClient AccountBalanceInquiryServiceClient client = new ChartOfAccountsInquiryServiceClientAccountBalanceInquiryServiceClient(); Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("org.kuali.kfs.core.v5_0"); client.setMarshaller(marshaller); client.setUnmarshaller(marshaller); JAXBElement<GetAccountsResponse>JAXBElement<GetAccountBalanceResponse> response = client.getAccountsgetAccountBalance(subFundschartOfAccountsCode, organizationcodes, fromDate, toDateaccountNumber); assertNotNull(response); } }
Code Block language java title Client package com.example.coa.service; import java.timeio.LocalDateStringWriter; import javajavax.xml.utilbind.ListJAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.datatype.DatatypeFactorytransform.Result; import javax.xml.transform.stream.StreamResult; import org.kuali.kfs.core.v5_0.AllAccountRequestAccountBalanceInquiryRequest; import org.kuali.kfs.core.v5_0.GetAccountsGetAccountBalance; import org.kuali.kfs.core.v5_0.GetAccountsResponseGetAccountBalanceResponse; import org.kualispringframework.kfs.core.v5_0.ObjectFactoryoxm.Marshaller; import org.springframework.ws.client.core.support.WebServiceGatewaySupport; public class ChartOfAccountsInquiryServiceClientAccountBalanceInquiryServiceClient extends WebServiceGatewaySupport { public JAXBElement<GetAccountsResponse>JAXBElement<GetAccountBalanceResponse> getAccountsgetAccountBalance(List<String>String subFundschartOfAccountsCode, List<String> organizationcodes, LocalDate fromDate, LocalDate toDateString accountNumber) throws Exception { ObjectFactory factory = new ObjectFactory(); DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); String uri = "https://kualinp.uconn.edu/kfs-dev/remoting/chartOfAccountsInquiryaccountBalanceInquiry"; GetAccountsGetAccountBalance request = new GetAccountsGetAccountBalance(); AllAccountRequestAccountBalanceInquiryRequest allAccountRequestaccountBalanceInquiryRequest = new AllAccountRequestAccountBalanceInquiryRequest(); allAccountRequestaccountBalanceInquiryRequest.getSubFundsetChartOfAccountsCode(chartOfAccountsCode).addAll(subFunds; accountBalanceInquiryRequest.setAccountNumber(accountNumber); allAccountRequestrequest.getOrganizationCodesetArg0().addAll(organizationcodes);accountBalanceInquiryRequest); logXml(request); allAccountRequest.setFromDate(factory.createAllAccountRequestFromDate(datatypeFactory.newXMLGregorianCalendar(fromDate.toString())))Object object = getWebServiceTemplate().marshalSendAndReceive(uri, request); logXml(object); return (JAXBElement<GetAccountBalanceResponse>) object; } allAccountRequest.setToDate(factory.createAllAccountRequestToDate(datatypeFactory.newXMLGregorianCalendar(toDate.toString())));public void logXml(Object element) { try { JAXBContext jc = JAXBContext.newInstance(element.getClass()); Marshaller marshaller = getMarshaller(); StreamResult result = new StreamResult(new StringWriter()); request marshaller.setArg0(allAccountRequest);marshal(element, result); System.out.println("XML : " + result.getWriter().toString()); } returncatch (JAXBElement<GetAccountsResponse>) getWebServiceTemplate().marshalSendAndReceive(uri, request);Exception e) { e.printStackTrace(); } } }
Criteria Used for Balance Checking:
...