From 4dd4ee027a115ea3e89d97f3f2e4d38c9c5fa6d9 Mon Sep 17 00:00:00 2001 From: Atit Gupta Date: Wed, 30 Oct 2019 23:19:16 -0700 Subject: [PATCH 1/4] adding unit tests for ReportService and ReportName --- .../intuit/ipp/services/ReportNameTest.java | 140 ++++++++++++++++++ .../ipp/services/ReportServiceTest.java | 114 ++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportNameTest.java create mode 100644 ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java diff --git a/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportNameTest.java b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportNameTest.java new file mode 100644 index 00000000..580bf2ed --- /dev/null +++ b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportNameTest.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2017 Intuit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package com.intuit.ipp.services; + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +public class ReportNameTest { + + private ReportName reportName; + + + + @Test + public void testProfitAndLoss() { + reportName = ReportName.PROFITANDLOSS; + assertEquals(reportName.toString(), "ProfitAndLoss"); + } + + @Test + public void testBalanceSheet() { + reportName = ReportName.BALANCESHEET; + assertEquals(reportName.toString(), "BalanceSheet"); + } + + @Test + public void testCashFlow() { + reportName = ReportName.CASHFLOW; + assertEquals(reportName.toString(), "CashFlow"); + } + + @Test + public void testCustomerIncome() { + reportName = ReportName.CUSTOMERINCOME; + assertEquals(reportName.toString(), "CustomerIncome"); + } + + @Test + public void testAgedReceivables() { + reportName = ReportName.AGEDRECEIVABLES; + assertEquals(reportName.toString(), "AgedReceivables"); + } + + @Test + public void testAgedPayables() { + reportName = ReportName.AGEDPAYABLES; + assertEquals(reportName.toString(), "AgedPayables"); + } + + @Test + public void testItemSales() { + reportName = ReportName.ITEMSALES; + assertEquals(reportName.toString(), "ItemSales"); + } + + @Test + public void testDepartmentSales() { + reportName = ReportName.DEPARTMENTSALES; + assertEquals(reportName.toString(), "DepartmentSales"); + } + + @Test + public void testClassSales() { + reportName = ReportName.CLASSSALES; + assertEquals(reportName.toString(), "ClassSales"); + } + + @Test + public void testTrialBalance() { + reportName = ReportName.TRIALBALANCE; + assertEquals(reportName.toString(), "TrialBalance"); + } + + @Test + public void testTrialBalanceFR() { + reportName = ReportName.TRIALBALANCE_FR; + assertEquals(reportName.toString(), "TrialBalanceFR"); + } + + @Test + public void testVendorBalance() { + reportName = ReportName.VENDORBALANCE; + assertEquals(reportName.toString(), "VendorBalance"); + } + + @Test + public void testVendorExpenses() { + reportName = ReportName.VENDOREXPENSES; + assertEquals(reportName.toString(), "VendorExpenses"); + } + + @Test + public void testInventoryValuationSummary() { + reportName = ReportName.INVENTORYVALUATIONSUMMARY; + assertEquals(reportName.toString(), "InventoryValuationSummary"); + } + + @Test + public void testBAS() { + reportName = ReportName.BAS; + assertEquals(reportName.toString(), "BAS"); + } + + @Test + public void testVendorBalanceDetail() { + reportName = ReportName.VENDORBALANCEDETAIL; + assertEquals(reportName.toString(), "VendorBalanceDetail"); + } + + @Test + public void testGeneralLedger() { + reportName = ReportName.GENERALLEDGER; + assertEquals(reportName.toString(), "GeneralLedger"); + } + + @Test + public void testGeneralLedgerFR() { + reportName = ReportName.GENERALLEDGER_FR; + assertEquals(reportName.toString(), "GeneralLedgerFR"); + } + + @Test + public void testAgedPayableDetail() { + reportName = ReportName.AGEDPAYABLEDETAIL; + assertEquals(reportName.toString(), "AgedPayableDetail"); + } +} diff --git a/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java new file mode 100644 index 00000000..0f19e8f8 --- /dev/null +++ b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2017 Intuit + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +package com.intuit.ipp.services; + +import com.intuit.ipp.core.Context; +import com.intuit.ipp.exception.FMSException; +import com.intuit.ipp.interceptors.IntuitInterceptorProvider; +import com.intuit.ipp.interceptors.IntuitMessage; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ReportServiceTest { + @Mocked + private Context context; + + private ReportService reportService; + + @BeforeClass + public void setup() { + reportService = new ReportService(context); + reportService = getMockedIntuitMessage(); + } + + @Test + public void testExecuteReport() throws FMSException { + MockIntuitInterceptorProvider mockIntuitInterceptorProvider + = new MockIntuitInterceptorProvider(); + reportService.executeReport("mock"); + } + + public ReportService getMockedIntuitMessage() { + reportService.setReport_date(""); + reportService.setStart_date(""); + reportService.setEnd_date(""); + reportService.setDate_macro(""); + reportService.setDate_macro(""); + reportService.setPast_due(""); + reportService.setEnd_duedate(""); + reportService.setStart_duedate(""); + reportService.setDuedate_macro(""); + reportService.setAccounting_method(""); + reportService.setAccount(""); + reportService.setSource_account(""); + reportService.setSource_account_type(""); + reportService.setSummarize_column_by(""); + reportService.setAccount_type(""); + reportService.setCustomer(""); + reportService.setVendor(""); + reportService.setItem(""); + reportService.setClassid(""); + reportService.setAppaid(""); + reportService.setDepartment(""); + reportService.setQzurl(""); + reportService.setAging_period(""); + reportService.setAging_method(""); + reportService.setNum_periods(""); + reportService.setTerm(""); + reportService.setColumns(""); + reportService.setSort_by(""); + reportService.setSort_order(""); + reportService.setGroup_by(""); + reportService.setCreatedate_macro(""); + reportService.setEnd_createdate(""); + reportService.setStart_createdate(""); + reportService.setModdate_macro(""); + reportService.setEnd_moddate(""); + reportService.setStart_moddate(""); + reportService.setPayment_method(""); + reportService.setName(""); + reportService.setTransaction_type(""); + reportService.setCleared(""); + reportService.setArpaid(""); + reportService.setPrinted(""); + reportService.setBoth_amount(""); + reportService.setMemo(""); + reportService.setDoc_num(""); + reportService.setJournal_code(""); + reportService.setEmployee(""); + reportService.setAgency_id(""); + reportService.setCustom1(""); + reportService.setCustom2(""); + reportService.setCustom3(""); + reportService.setShipvia(""); + reportService.setAccount_status(""); + reportService.setSubcol_pct_inc(""); + reportService.setSubcol_pct_exp(""); + + return reportService; + } +} + +class MockIntuitInterceptorProvider extends MockUp { + + @Mock + public void executeInterceptors(final IntuitMessage intuitMessage) throws FMSException { + // mocked executeInterceptors + } +} \ No newline at end of file From 434384cf9ba7bd05bf9fd5e6c9b944a99acb9496 Mon Sep 17 00:00:00 2001 From: Atit Gupta Date: Wed, 30 Oct 2019 23:50:29 -0700 Subject: [PATCH 2/4] updating access modifiers for mocked class --- .../com/intuit/ipp/services/ReportServiceTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java index 0f19e8f8..52e0e5b8 100644 --- a/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java +++ b/ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/ReportServiceTest.java @@ -103,12 +103,11 @@ public ReportService getMockedIntuitMessage() { return reportService; } -} + private static final class MockIntuitInterceptorProvider extends MockUp { -class MockIntuitInterceptorProvider extends MockUp { - - @Mock - public void executeInterceptors(final IntuitMessage intuitMessage) throws FMSException { - // mocked executeInterceptors + @Mock + public void executeInterceptors(final IntuitMessage intuitMessage) throws FMSException { + // mocked executeInterceptors + } } } \ No newline at end of file From efd6d47adc2b1dfaa3ae7d2da9a68d9615df9926 Mon Sep 17 00:00:00 2001 From: Atit Gupta Date: Thu, 31 Oct 2019 00:00:19 -0700 Subject: [PATCH 3/4] updating the version of jmockit for Java8+ compatibility --- ipp-v3-java-devkit/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipp-v3-java-devkit/pom.xml b/ipp-v3-java-devkit/pom.xml index 4fd9d44e..61e27f0a 100755 --- a/ipp-v3-java-devkit/pom.xml +++ b/ipp-v3-java-devkit/pom.xml @@ -88,7 +88,7 @@ org.jmockit jmockit - 1.25 + 1.48 test From 02f78e0739b90f4936514ec1496ff66bcbff5635 Mon Sep 17 00:00:00 2001 From: Atit Gupta Date: Thu, 31 Oct 2019 00:05:36 -0700 Subject: [PATCH 4/4] review comments --- ipp-v3-java-devkit/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipp-v3-java-devkit/pom.xml b/ipp-v3-java-devkit/pom.xml index 61e27f0a..e372b5f0 100755 --- a/ipp-v3-java-devkit/pom.xml +++ b/ipp-v3-java-devkit/pom.xml @@ -88,7 +88,7 @@ org.jmockit jmockit - 1.48 + 1.25 test @@ -144,6 +144,7 @@ maven-surefire-plugin 3.0.0-M3 + ${argLine} -Djdk.attach.allowAttachSelf testng-devkit.xml