clean up XBRLBuilderTest (re. FINERACT-940)

This commit is contained in:
Michael Vorburger
2020-05-08 17:04:43 +02:00
committed by Michael Vorburger ⛑️
parent 69a7b1e8da
commit ea85f9c739
@@ -51,43 +51,29 @@ public class XBRLBuilderTest {
@Mock
private NamespaceReadPlatformServiceImpl readNamespaceService;
@InjectMocks
private final XBRLBuilder xbrlBuilder = new XBRLBuilder();
@Before
public void setUp() {
this.readNamespaceService = Mockito.mock(NamespaceReadPlatformServiceImpl.class);
lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString())).thenReturn(
new NamespaceData(1l, "mockedprefix", "mockedurl"));
}
@SuppressWarnings("null")
@Test
public void shouldCorrectlyBuildMap() {
public void shouldCorrectlyBuildMap() throws SAXException, IOException, ParserConfigurationException {
final HashMap<MixTaxonomyData, BigDecimal> map = new HashMap<MixTaxonomyData, BigDecimal>();
final MixTaxonomyData data1 = Mockito.mock(MixTaxonomyData.class);
when(data1.getName()).thenReturn("Assets");
map.put(data1, new BigDecimal(10000));
final String result = this.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(StandardCharsets.UTF_8)))
.getElementsByTagName("Assets");
} catch (final SAXException e) {
e.printStackTrace();
} catch (final IOException e) {
e.printStackTrace();
} catch (final ParserConfigurationException e) {
e.printStackTrace();
}
NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))).getElementsByTagName("Assets");
assertNotNull(nodes);
assertNotNull(nodes.item(0));
assertEquals("Assets", nodes.item(0).getNodeName());
}
}