Improved: Used utility provided by OFBizTestCase class for userLogin instead of fetching from DB test cases also removed unused fetching of userLogin in some cases

(OFBIZ-11618)
This commit is contained in:
Pawan Verma
2020-04-30 22:00:04 +05:30
parent e1a16aa9fe
commit ffe9c46cf0
11 changed files with 14 additions and 48 deletions
@@ -38,7 +38,7 @@ public class FinAccountTests extends OFBizTestCase {
}
public void testFinAccountOperations() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
GenericValue userLogin = getUserLogin("system");
Map<String, Object> ctx = new HashMap<>();
ctx.put("finAccountId", "TESTACCOUNT1");
ctx.put("finAccountName", "Test Financial Account");
@@ -30,8 +30,6 @@ import java.util.Map;
public class OrderTest extends OFBizTestCase {
public static final String MODULE = OFBizTestCase.class.getName();
protected GenericValue userLogin = null;
public OrderTest(String name) {
super(name);
}
@@ -34,7 +34,6 @@ import org.apache.ofbiz.service.ServiceUtil;
public class PurchaseOrderTest extends OFBizTestCase {
public static final String MODULE = OFBizTestCase.class.getName();
protected GenericValue userLogin = null;
protected String orderId = null;
protected String statusId = null;
@@ -42,11 +41,6 @@ public class PurchaseOrderTest extends OFBizTestCase {
super(name);
}
@Override
protected void setUp() throws Exception {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
}
@Override
protected void tearDown() throws Exception {
}
@@ -93,7 +87,7 @@ public class PurchaseOrderTest extends OFBizTestCase {
ctx.put("billFromVendorPartyId", "DemoSupplier");
ctx.put("shipFromVendorPartyId", "Company");
ctx.put("supplierAgentPartyId", "DemoSupplier");
ctx.put("userLogin", userLogin);
ctx.put("userLogin", getUserLogin("system"));
Map <String, Object> resp = dispatcher.runSync("storeOrder", ctx);
if (ServiceUtil.isError(resp)) {
@@ -33,17 +33,11 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
public class SalesOrderTest extends OFBizTestCase {
public static final String MODULE = OFBizTestCase.class.getName();
protected GenericValue userLogin = null;
public SalesOrderTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
}
@Override
protected void tearDown() throws Exception {
}
@@ -141,7 +135,7 @@ public class SalesOrderTest extends OFBizTestCase {
ctx.put("billToCustomerPartyId", "DemoCustomer");
ctx.put("billFromVendorPartyId", "Company");
ctx.put("userLogin", userLogin);
ctx.put("userLogin", getUserLogin("system"));
Map<String, Object> resp = dispatcher.runSync("storeOrder", ctx);
if (ServiceUtil.isError(resp)) {
Debug.logError(ServiceUtil.getErrorMessage(resp), MODULE);
@@ -41,11 +41,10 @@ class ProductPromoActionTests extends OFBizTestCase {
}
ShoppingCart loadOrder(String orderId) {
GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
Map<String, Object> serviceCtx = [orderId: orderId,
skipInventoryChecks: true, // the items are already reserved, no need to check again
skipProductChecks: true, // the products are already in the order, no need to check their validity now
userLogin: permUserLogin]
userLogin: getUserLogin("system")]
Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
return loadCartResp.shoppingCart
@@ -52,13 +52,12 @@ class ProductPromoCondTests extends OFBizTestCase {
}
ShoppingCart loadOrder(String orderId) {
GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne()
Map<String, Object> serviceCtx = [orderId: orderId,
skipInventoryChecks: true, // the items are already reserved, no need to check again
skipProductChecks: true, // the products are already in the order, no need to check their validity now
includePromoItems: false,
createAsNewOrder: 'Y',
userLogin: permUserLogin]
userLogin: getUserLogin("system")]
Map<String, Object> loadCartResp = dispatcher.runSync("loadCartFromOrder", serviceCtx)
return loadCartResp.shoppingCart
@@ -30,7 +30,6 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
public class InventoryItemTransferTest extends OFBizTestCase {
protected GenericValue userLogin = null;
static String inventoryTransferId = null;
protected BigDecimal transferQty = BigDecimal.ONE;
@@ -38,16 +37,12 @@ public class InventoryItemTransferTest extends OFBizTestCase {
super(name);
}
@Override
protected void setUp() throws Exception {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
}
@Override
protected void tearDown() throws Exception {
}
public void testCreateInventoryItemsTransfer() throws Exception {
GenericValue userLogin = getUserLogin("system");
// create
Map<String, Object> ctx = new HashMap<>();
String inventoryItemId = "9005";
@@ -34,22 +34,16 @@ import org.apache.ofbiz.service.testtools.OFBizTestCase;
*/
public class StockMovesTest extends OFBizTestCase {
protected GenericValue userLogin = null;
public StockMovesTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
}
@Override
protected void tearDown() throws Exception {
}
public void testStockMoves() throws Exception {
GenericValue userLogin = getUserLogin("system");
Map<String, Object> fsmnCtx = new HashMap<>();
Map<?,?> stockMoveHandled = null;
List<?> warningList;
@@ -34,17 +34,10 @@ import org.apache.ofbiz.shipment.packing.PackingSession;
*/
public class IssuanceTest extends OFBizTestCase {
protected GenericValue userLogin = null;
public IssuanceTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne();
}
@Override
protected void tearDown() throws Exception {
}
@@ -57,7 +50,7 @@ public class IssuanceTest extends OFBizTestCase {
String shipGroupSeqId="00001";
String shipmentItemSeqId = "00001";
PackingSession packSession = new PackingSession(dispatcher, userLogin, facilityId, null, orderId, shipGroupSeqId);
PackingSession packSession = new PackingSession(dispatcher, getUserLogin("system"), facilityId, null, orderId, shipGroupSeqId);
packSession.addOrIncreaseLine(orderId, orderItemSeqId, shipGroupSeqId, productId, BigDecimal.valueOf(6L), 1,
BigDecimal.valueOf(1000L), false);
String shipmentId = packSession.complete(false);
@@ -112,7 +112,7 @@ public class PerformFindTests extends OFBizTestCase {
}
private void performFindConditionFieldEquals() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
prepareData();
Map<String, Object> inputFields = new HashMap<>();
@@ -149,7 +149,7 @@ public class PerformFindTests extends OFBizTestCase {
}
private void performFindConditionFieldLike() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
prepareData();
//first test like condition
@@ -186,7 +186,7 @@ public class PerformFindTests extends OFBizTestCase {
}
private void performFindConditionDistinct() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
prepareData();
//first test without distinct condition
@@ -207,7 +207,7 @@ public class PerformFindTests extends OFBizTestCase {
}
private void performFindFilterByDate() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
prepareData();
//first test without filterDate condition
@@ -227,7 +227,7 @@ public class PerformFindTests extends OFBizTestCase {
}
private void performFindFilterByDateWithDedicateDateField() throws Exception {
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
prepareData();
//first test without filterDate condition
@@ -200,7 +200,7 @@ public class ServiceEntityAutoTests extends OFBizTestCase {
delegator.create("StatusType", "statusTypeId", "TESTINGSTATUS");
delegator.create("StatusItem", "statusId", "TESTING_CREATE", "statusTypeId", "TESTINGSTATUS");
delegator.create("StatusItem", "statusId", "TESTING_UPDATE", "statusTypeId", "TESTINGSTATUS");
GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
GenericValue userLogin = getUserLogin("system");
//test create testingStatus with userlogin
Map<String, Object> testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE", "userLogin", userLogin);