Author: mbrohl
Date: Sun Dec 17 11:25:11 2017 New Revision: 1818475 URL: http://svn.apache.org/viewvc?rev=1818475&view=rev Log: Improved: General refactoring and code improvements, package org.apache.ofbiz.entity.test. (OFBIZ-9952) Thanks Dennis Balkir for reporting and providing the patches. Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityCryptoTestSuite.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityCryptoTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityCryptoTestSuite.java?rev=1818475&r1=1818474&r2=1818475&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityCryptoTestSuite.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityCryptoTestSuite.java Sun Dec 17 11:25:11 2017 @@ -122,7 +122,7 @@ public class EntityCryptoTestSuite exten assertEquals(1, (EntityQuery.use(delegator).from("TestingCrypto").where("testingCryptoTypeId", "LOOKUP", "saltedEncryptedValue", null).queryList()).size()); assertEquals(1, (EntityQuery.use(delegator).from("TestingCrypto").where("testingCryptoTypeId", "LOOKUP", "encryptedValue", nanoTime).queryList()).size()); assertEquals(0, (EntityQuery.use(delegator).from("TestingCrypto").where("testingCryptoTypeId", "LOOKUP", "saltedEncryptedValue", nanoTime).queryList()).size()); - + assertEquals(1, EntityQuery.use(delegator).from("TestingCrypto").where("testingCryptoTypeId", "LOOKUP", "encryptedValue", nanoTime).queryList().size()); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java?rev=1818475&r1=1818474&r2=1818475&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityQueryTestSuite.java Sun Dec 17 11:25:11 2017 @@ -41,12 +41,12 @@ public class EntityQueryTestSuite extend super(name); } - /* + /* * queryCount(): This method returns number of records found for the particular query. * assert: Compared count of number of records found by Entity Engine method with count of number of records found by EntityQuery method. */ public void testQueryCount() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "record-1", "description", "Record One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "record-2", "description", "Record Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "record-3", "description", "Record Three")); @@ -65,7 +65,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testWhere() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "where-1", "description", "find me")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "where-2", "description", "find me not")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "where-3", "description", "find me")); @@ -86,7 +86,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testQueryList() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryList-1", "description", "queryList record one")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryList-2", "description", "queryList record two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryList-3", "description", "queryList record three")); @@ -106,7 +106,7 @@ public class EntityQueryTestSuite extend * assert 2: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testQueryFirst() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryFirst-1", "description", "first record")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryFirst-2", "description", "second record")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryFirst-3", "description", "third record")); @@ -125,7 +125,7 @@ public class EntityQueryTestSuite extend * assert 2: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testQueryOne() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOne-1", "description", "query one")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOne-2", "description", "query two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOne-3", "description", "query three")); @@ -144,7 +144,7 @@ public class EntityQueryTestSuite extend * assert 2: Check the TestingType entity queryOneMap-3 has been resolve with the parameters map present in context */ public void testQueryOneWithContext() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOneMap-1", "description", "query one by map")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOneMap-2", "description", "query two by map")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryOneMap-3", "description", "query three by map")); @@ -167,7 +167,7 @@ public class EntityQueryTestSuite extend * assert 2: Compared 'testingTypeId' field for null which is fetched by EntityQuery method. */ public void testSelect() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "select-1", "description", "description one")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "select-2", "description", "description two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "select-3", "description", "description three")); @@ -187,7 +187,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'testingTypeId' field for null which is fetched by EntityQuery method. */ public void testDistinctAndSelect() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "distinct-1", "description", "Distinct Record")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "distinct-2", "description", "Distinct Record")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "distinct-3", "description", "Not a Distinct Record")); @@ -210,7 +210,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testOrderBy() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "orderBy-1", "description", "B")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "orderBy-2", "description", "C")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "orderBy-3", "description", "A")); @@ -267,7 +267,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testMaxRows() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "maxRows-1", "description", "Max Row One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "maxRows-2", "description", "Max Row Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "maxRows-3", "description", "Max Row Three")); @@ -290,7 +290,7 @@ public class EntityQueryTestSuite extend * assert 3: Compared 'description' field of first record fetched by Entity Engine method and by EntityQuery method. */ public void testFetchSize() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "fetchSize-1", "description", "Fetch Size One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "fetchSize-2", "description", "Fetch Size Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "fetchSize-3", "description", "Fetch Size Three")); @@ -311,7 +311,7 @@ public class EntityQueryTestSuite extend * assert: Compared first record of both the iterator. */ public void testQueryIterator() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryIterator-1", "description", "Value One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryIterator-2", "description", "Value Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "queryIterator-3", "description", "Value Three")); @@ -344,7 +344,7 @@ public class EntityQueryTestSuite extend * assert: Compared first record found by both the iterator. */ public void testCursorForwardOnly() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "cursorForwardOnly-1", "description", "cursorForwardOnly One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "cursorForwardOnly-2", "description", "cursorForwardOnly Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "cursorForwardOnly-3", "description", "cursorForwardOnly Three")); @@ -379,7 +379,7 @@ public class EntityQueryTestSuite extend * assert: Compared first record found by both the iterators. */ public void testCursorScrollSensitive() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollSensitive-1", "description", "cursorScrollSensitive One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollSensitive-2", "description", "cursorScrollSensitive Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollSensitive-3", "description", "cursorScrollSensitive Three")); @@ -414,7 +414,7 @@ public class EntityQueryTestSuite extend * assert: Compared first record found by both the iterators. */ public void testCursorScrollInSensitive() throws GenericEntityException { - List<GenericValue> testingTypes = new LinkedList<GenericValue>(); + List<GenericValue> testingTypes = new LinkedList<>(); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollInSensitive-1", "description", "cursorScrollInSensitive One")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollInSensitive-2", "description", "cursorScrollInSensitive Two")); testingTypes.add(delegator.makeValue("TestingType", "testingTypeId", "scrollInSensitive-3", "description", "cursorScrollInSensitive Three")); Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java?rev=1818475&r1=1818474&r2=1818475&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java Sun Dec 17 11:25:11 2017 @@ -106,7 +106,7 @@ public class EntityTestSuite extends Ent assertFalse("Observable has not changed", createdValue.hasChanged()); // This sequence creates the GenericValue entities first, puts them in a List, then calls the delegator to store them all - List<GenericValue> newValues = new LinkedList<GenericValue>(); + List<GenericValue> newValues = new LinkedList<>(); newValues.add(delegator.makeValue("TestingType", "testingTypeId", "TEST-MAKE-2", "description", "Testing Type #Make-2")); newValues.add(delegator.makeValue("TestingType", "testingTypeId", "TEST-MAKE-3", "description", "Testing Type #Make-3")); @@ -377,7 +377,7 @@ public class EntityTestSuite extends Ent .where(EntityCondition.makeCondition("primaryParentNodeId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD)) .queryList(); - List<GenericValue> newValues = new LinkedList<GenericValue>(); + List<GenericValue> newValues = new LinkedList<>(); Timestamp now = UtilDateTime.nowTimestamp(); for (GenericValue node: nodeLevel1) { @@ -586,7 +586,7 @@ public class EntityTestSuite extends Ent .where(EntityCondition.makeCondition("testingId", EntityOperator.LIKE, "rnmat:%")) .queryList(); - List<GenericValue> testings = new ArrayList<GenericValue>(); + List<GenericValue> testings = new ArrayList<>(); for (GenericValue nodeMember: values) { testings.add(nodeMember.getRelatedOne("Testing", false)); @@ -689,7 +689,7 @@ public class EntityTestSuite extends Ent */ public void testCreateManyAndStoreAtOnce() throws Exception { try { - List<GenericValue> newValues = new LinkedList<GenericValue>(); + List<GenericValue> newValues = new LinkedList<>(); for (int i = 0; i < TEST_COUNT; i++) { newValues.add(delegator.makeValue("Testing", "testingId", getTestId("T1-", i))); } @@ -739,7 +739,7 @@ public class EntityTestSuite extends Ent */ public void testEntityListIterator() throws Exception { try { - List<GenericValue> newValues = new LinkedList<GenericValue>(); + List<GenericValue> newValues = new LinkedList<>(); for (int i = 0; i < TEST_COUNT; i++) { newValues.add(delegator.makeValue("Testing", "testingId", getTestId("T3-", i))); } @@ -944,8 +944,8 @@ public class EntityTestSuite extends Ent strBufTemp.append(iNum); return strBufTemp.toString(); } - - + + /* * This test will verify that the LIMIT and OFFSET options can work properly. * Commented out because it makes the framework dependent on the content component @@ -999,7 +999,7 @@ public class EntityTestSuite extends Ent long end = UtilDateTime.nowTimestamp().getTime(); long time1 = end - start; Debug.logInfo("Time consumed WITH limit and offset option (ms): " + time1, module); - + start = UtilDateTime.nowTimestamp().getTime(); for (int page = 1; page <= pages; page++) { Debug.logInfo("Page " + page + ":", module); @@ -1038,7 +1038,7 @@ public class EntityTestSuite extends Ent }*/ /* - * Tests EntitySaxReader, verification loading data with tag create, create-update, create-replace, delete + * Tests EntitySaxReader, verification loading data with tag create, create-update, create-replace, delete */ public void testEntitySaxReaderCreation() throws Exception { String xmlContentLoad = @@ -1149,7 +1149,7 @@ public class EntityTestSuite extends Ent } public void testEntitySaxReaderDelete() throws Exception { - String xmlContentLoad = + String xmlContentLoad = "<delete>" + " <Testing testingId=\"T1\"/>" + " <Testing testingId=\"T2\"/>" + @@ -1193,11 +1193,11 @@ public class EntityTestSuite extends Ent "seqName", "seqId"); UUID id = UUID.randomUUID(); final String sequenceName = "BogusSequence" + id.toString(); - final ConcurrentMap<Long, Long> seqIds = new ConcurrentHashMap<Long, Long>(); + final ConcurrentMap<Long, Long> seqIds = new ConcurrentHashMap<>(); final AtomicBoolean duplicateFound = new AtomicBoolean(false); final AtomicBoolean nullSeqIdReturned = new AtomicBoolean(false); - List<Future<Void>> futures = new ArrayList<Future<Void>>(); + List<Future<Void>> futures = new ArrayList<>(); Callable<Void> getSeqIdTask = new Callable<Void>() { public Void call() throws Exception { Long seqId = sequencer.getNextSeqId(sequenceName, 1, null); @@ -1291,27 +1291,6 @@ public class EntityTestSuite extends Ent assertTrue("One big transaction was not faster than several small ones", totalTimeOneTransaction < totalTimeSeveralSmallTransactions); } -/* - public void testConverters() throws Exception { - // Must use the default delegator because the deserialized GenericValue can't - // find the randomized one. - Delegator localDelegator = DelegatorFactory.getDelegator("default"); - TransactionUtil.begin(); - localDelegator.create("TestingType", "testingTypeId", "TEST-UPDATE-1", "description", "Testing Type #Update-1"); - GenericValue testValue = localDelegator.create("Testing", "testingId", "JSON_TEST", "testingTypeId", "TEST-UPDATE-1", - "description", "Testing JSON Converters", "testingSize", (long) 123, "testingDate", - new Timestamp(System.currentTimeMillis())); - assertNotNull("Created GenericValue not null", testValue); - JSON json = (JSON) ObjectType.simpleTypeConvert(testValue, "org.apache.ofbiz.base.lang.JSON", null, null); - assertNotNull("JSON instance not null", json); - GenericValue convertedValue = (GenericValue) ObjectType.simpleTypeConvert(json, "org.apache.ofbiz.entity.GenericValue", null, - null); - assertNotNull("GenericValue converted from JSON not null", convertedValue); - assertEquals("GenericValue converted from JSON equals original value", testValue, convertedValue); - TransactionUtil.rollback(); - } -*/ - private final class TestObserver implements Observer { private Observable observable; private Object arg; |
Free forum by Nabble | Edit this page |