@Test public void testHTMLParser() { DocumentDto documentDto = GrouponPurchaseParserV2.parse( "./app-receipts/test-data/groupon/valid_v2/V2_regexUpdate1.html"); Assert.assertNotNull("Document is null !", documentDto); Assert.assertNotNull("Document Title is null !", documentDto.getTitle()); Assert.assertNotNull("Head Element is null", documentDto.getHeadElements()); Assert.assertNotNull("Body Element is null", documentDto.getBodyElements()); }
@Test public void testV2RegexUpdate1() throws Exception { byte[] encoded = Files.readAllBytes( Paths.get("./app-receipts/test-data/groupon/valid_v2/V2_regexUpdate1.html")); String HTML = new String(encoded, Charset.defaultCharset()); Document doc = Jsoup.parse(HTML); EcommerceReceipt receipt = GrouponPurchaseParserV2.parse(doc); EcommerceItem item = receipt.getShipments().get(0).getItems().get(0); Address address = receipt.getShipping(); assertEquals("12345 Test St", address.getStreetOrBoxInfo()); assertEquals("Sun Valley", address.getCity()); assertEquals("California", address.getState()); assertEquals("12345-1234", address.getPostalCode()); assertEquals("Sirius Beauty Sonic Skincare System", item.getDescription()); assertEquals(24.0, receipt.getOrderSubTotal(), 0); assertEquals(28.74, receipt.getOrderTotal(), 0); }