xbrl reporting integration:
add four apis: /mixtaxonomy get /mixmapping get /mixmapping put /mixreport ger
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
package org.mifosplatform.xbrl.report.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReadTaxonomyMappingServiceImplTest {
|
||||
|
||||
XBRLResultServiceImpl readService;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
RoutingDataSource dataSource = Mockito.mock(RoutingDataSource.class);
|
||||
readService = new XBRLResultServiceImpl(dataSource, null, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCorrectlyGetGLCode() {
|
||||
ArrayList<String> result = readService.getGLCodes("{12000}+{11000}");
|
||||
assertEquals("12000", result.get(0));
|
||||
assertEquals("11000", result.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package org.mifosplatform.xbrl.report.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mifosplatform.xbrl.report.data.NamespaceData;
|
||||
import org.mifosplatform.xbrl.taxonomy.data.TaxonomyData;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class XBRLBuilderTest {
|
||||
|
||||
@Mock
|
||||
private ReadNamespaceServiceImpl readNamespaceService;
|
||||
@InjectMocks
|
||||
private XBRLBuilder xbrlBuilder = new XBRLBuilder();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
readNamespaceService = Mockito.mock(ReadNamespaceServiceImpl.class);
|
||||
when(readNamespaceService.retrieveNamespaceByPrefix(Mockito.anyString())).thenReturn(
|
||||
new NamespaceData(1l, "mockedprefix", "mockedurl"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCorrectlyBuildMap() {
|
||||
|
||||
HashMap<TaxonomyData, BigDecimal> map = new HashMap<TaxonomyData, BigDecimal>();
|
||||
TaxonomyData data1 = Mockito.mock(TaxonomyData.class);
|
||||
when(data1.getName()).thenReturn("Assets");
|
||||
map.put(data1, new BigDecimal(10000));
|
||||
String result = xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"), "USD");
|
||||
System.out.println(result);
|
||||
NodeList nodes = null;
|
||||
try {
|
||||
nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(result.getBytes()))
|
||||
.getElementsByTagName("Assets");
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertNotNull(nodes);
|
||||
assertNotNull(nodes.item(0));
|
||||
assertEquals("Assets", nodes.item(0).getNodeName());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user