From ccbce41676bc48c8961041c2ed52e8ecbbf5dd5b Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 15:36:32 +0700 Subject: [PATCH 1/6] remove for prevent error 'ClassNotFoundException: org.apache.juli.FileHandler' --- .../be5/base/services/impl/LogConfigurator.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/base/src/main/java/com/developmentontheedge/be5/base/services/impl/LogConfigurator.java b/base/src/main/java/com/developmentontheedge/be5/base/services/impl/LogConfigurator.java index 60c5469e8..a5ae9a69f 100644 --- a/base/src/main/java/com/developmentontheedge/be5/base/services/impl/LogConfigurator.java +++ b/base/src/main/java/com/developmentontheedge/be5/base/services/impl/LogConfigurator.java @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; -import java.util.logging.Handler; import java.util.logging.LogManager; import java.util.logging.Logger; @@ -34,15 +33,7 @@ public LogConfigurator() String parentLevel = log.getParent().getLevel() != null ? log.getParent().getLevel().getName() : "null"; - StringBuilder sb = new StringBuilder(); - sb.append("Log root level: ").append(parentLevel); - - for (Handler handler : log.getParent().getHandlers()) - { - sb.append("\n - ").append(handler.getClass().getName()).append(" ").append(handler.getLevel()); - } - - log.info(sb.toString()); + log.info("Log root level: " + parentLevel); } } From 266997aff2903de62b15dd89e01e90d4fde66088 Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 15:41:26 +0700 Subject: [PATCH 2/6] rename module test - test-base --- database-model/pom.xml | 2 +- operation/pom.xml | 2 +- pom.xml | 2 +- query/pom.xml | 2 +- server/pom.xml | 2 +- {test => test-base}/pom.xml | 4 ++-- .../java/com/developmentontheedge/be5/test/BaseTestUtils.java | 0 .../developmentontheedge/be5/test/TestProjectProvider.java | 0 .../developmentontheedge/be5/test/mocks/Be5CachesForTest.java | 0 .../be5/test/mocks/ConnectionServiceMock.java | 0 .../developmentontheedge/be5/test/mocks/CoreUtilsForTest.java | 0 .../be5/test/mocks/DataSourceServiceMock.java | 0 .../developmentontheedge/be5/test/mocks/DbServiceMock.java | 0 13 files changed, 7 insertions(+), 7 deletions(-) rename {test => test-base}/pom.xml (95%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/TestProjectProvider.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/mocks/Be5CachesForTest.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/mocks/ConnectionServiceMock.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/mocks/CoreUtilsForTest.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/mocks/DataSourceServiceMock.java (100%) rename {test => test-base}/src/main/java/com/developmentontheedge/be5/test/mocks/DbServiceMock.java (100%) diff --git a/database-model/pom.xml b/database-model/pom.xml index c8c582082..1f69edde1 100644 --- a/database-model/pom.xml +++ b/database-model/pom.xml @@ -29,7 +29,7 @@ com.developmentontheedge.be5 - be5-test + be5-test-base 0.0.3-SNAPSHOT test diff --git a/operation/pom.xml b/operation/pom.xml index 00270f78a..8549e68ff 100644 --- a/operation/pom.xml +++ b/operation/pom.xml @@ -29,7 +29,7 @@ com.developmentontheedge.be5 - be5-test + be5-test-base 0.0.3-SNAPSHOT test diff --git a/pom.xml b/pom.xml index 39b57fc10..89a2ef37a 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ metadata maven base + test-base operation query database-model @@ -24,7 +25,6 @@ server modules/core modules/system - test diff --git a/query/pom.xml b/query/pom.xml index f19d905df..bc529b7ab 100644 --- a/query/pom.xml +++ b/query/pom.xml @@ -29,7 +29,7 @@ com.developmentontheedge.be5 - be5-test + be5-test-base 0.0.3-SNAPSHOT test diff --git a/server/pom.xml b/server/pom.xml index 7a9cbb93d..01fddfdb2 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -60,7 +60,7 @@ com.developmentontheedge.be5 - be5-test + be5-test-base 0.0.3-SNAPSHOT diff --git a/test/pom.xml b/test-base/pom.xml similarity index 95% rename from test/pom.xml rename to test-base/pom.xml index 96d9ce25a..d8df53bb2 100644 --- a/test/pom.xml +++ b/test-base/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - be5 test - be5-test + be5 test base + be5-test-base be5 diff --git a/test/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java b/test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestProjectProvider.java b/test-base/src/main/java/com/developmentontheedge/be5/test/TestProjectProvider.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/TestProjectProvider.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/TestProjectProvider.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/Be5CachesForTest.java b/test-base/src/main/java/com/developmentontheedge/be5/test/mocks/Be5CachesForTest.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/mocks/Be5CachesForTest.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/mocks/Be5CachesForTest.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/ConnectionServiceMock.java b/test-base/src/main/java/com/developmentontheedge/be5/test/mocks/ConnectionServiceMock.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/mocks/ConnectionServiceMock.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/mocks/ConnectionServiceMock.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/CoreUtilsForTest.java b/test-base/src/main/java/com/developmentontheedge/be5/test/mocks/CoreUtilsForTest.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/mocks/CoreUtilsForTest.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/mocks/CoreUtilsForTest.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/DataSourceServiceMock.java b/test-base/src/main/java/com/developmentontheedge/be5/test/mocks/DataSourceServiceMock.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/mocks/DataSourceServiceMock.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/mocks/DataSourceServiceMock.java diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/DbServiceMock.java b/test-base/src/main/java/com/developmentontheedge/be5/test/mocks/DbServiceMock.java similarity index 100% rename from test/src/main/java/com/developmentontheedge/be5/test/mocks/DbServiceMock.java rename to test-base/src/main/java/com/developmentontheedge/be5/test/mocks/DbServiceMock.java From 63821919fee43d7ed2221241f55eb3d5b7982b38 Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 16:05:30 +0700 Subject: [PATCH 3/6] move test package - to new test module --- modules/core/pom.xml | 40 +-- .../modules/core/CoreBe5ProjectDBTest.java | 2 +- .../be5/modules/core/CoreBe5ProjectTest.java | 3 +- modules/system/pom.xml | 12 +- .../modules/system/SystemBe5ProjectTest.java | 2 +- pom.xml | 1 + server/pom.xml | 19 +- .../be5/server/RequestTest.groovy | 3 +- .../be5/server/controllers/FormTest.groovy | 2 +- .../be5/server/helpers/DpsHelperTest.groovy | 2 +- .../helpers/DpsRecordAdapterTest.groovy | 2 +- .../server/model/beans/GroovyDPSTest.groovy | 2 +- .../beans/GroovyDpsGetPropertyTest.groovy | 2 +- .../operations/FilterOperationTest.groovy | 2 +- .../operations/GroovyOperationTest.groovy | 2 +- .../server/operations/OperationTest.groovy | 2 +- .../operationParams/CustomOpTest.groovy | 2 +- .../GetRedirectParamsTest.groovy | 2 +- .../operationParams/InsertOpTest.groovy | 2 +- .../services/ConfigurationProviderTest.groovy | 2 +- .../services/OperationExecutorTest.groovy | 2 +- .../services/OperationHelperTest.groovy | 2 +- .../OperationServiceExtendTest.groovy | 2 +- .../services/OperationServiceTest.groovy | 2 +- .../services/TestTableQueryDBTest.groovy | 2 +- .../ValidatorServiceNumbersTest.groovy | 2 +- .../services/ValidatorServiceTest.groovy | 2 +- .../ValidatorServiceValueInTagsTest.groovy | 2 +- .../impl/OperationServiceImplTest.groovy | 2 +- .../test/AbstractProjectTestTest.groovy | 2 +- .../be5/server/ResponseXmlTest.java | 2 +- .../controllers/DownloadControllerTest.java | 2 +- .../controllers/LanguageSelectorTest.java | 3 +- .../be5/server/controllers/MenuTest.java | 2 +- .../server/controllers/QueryBuilderTest.java | 2 +- .../controllers/StaticPageControllerTest.java | 2 +- .../be5/server/controllers/TableTest.java | 2 +- .../be5/server/helpers/MenuHelperTest.java | 3 +- .../server/helpers/OperationHelperTest.java | 2 +- .../helpers/impl/UserAwareMetaImplTest.java | 2 +- .../be5/server/model/UserInfoTest.java | 4 +- .../operations/CustomOperationTest.java | 2 +- .../be5/server/operations/DateTimeTest.java | 2 +- .../operations/StandardOperationsDBTest.java | 4 +- .../operations/StandardOperationsTest.java | 2 +- .../TransactionalOperationTest.java | 2 +- .../operations/extenders/ExtendersTest.java | 2 +- .../services/impl/LogConfiguratorTest.java | 2 +- .../be5/server/servlet/MainServletTest.java | 2 +- .../server/servlet/TemplateFilterTest.java | 2 +- .../be5/server/util/ActionHelperTest.java | 2 +- .../test/ServerBe5ProjectDBTest.java | 2 +- .../test/ServerBe5ProjectTest.java | 2 +- .../test/SqlMockOperationTest.java | 2 +- .../be5}/test/TestRequest.java | 2 +- .../be5}/test/TestSession.java | 2 +- .../be5/test/TestUtils.java | 306 ++++++++++++++++++ .../test/mocks/CategoriesServiceForTest.java | 2 +- test/pom.xml | 30 ++ .../be5/test/TestRequest.java | 134 ++++++++ .../be5/test/TestSession.java | 63 ++++ .../be5}/test/TestUtils.java | 35 +- .../test/mocks/CategoriesServiceForTest.java | 29 ++ 63 files changed, 653 insertions(+), 130 deletions(-) rename server/src/test/groovy/com/developmentontheedge/be5/{server => }/test/AbstractProjectTestTest.groovy (93%) rename server/src/test/java/com/developmentontheedge/be5/{server => }/test/ServerBe5ProjectDBTest.java (95%) rename server/src/test/java/com/developmentontheedge/be5/{server => }/test/ServerBe5ProjectTest.java (94%) rename server/src/test/java/com/developmentontheedge/be5/{server => }/test/SqlMockOperationTest.java (93%) rename server/src/{main/java/com/developmentontheedge/be5/server => test/java/com/developmentontheedge/be5}/test/TestRequest.java (97%) rename server/src/{main/java/com/developmentontheedge/be5/server => test/java/com/developmentontheedge/be5}/test/TestSession.java (95%) create mode 100644 server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java rename server/src/{main/java/com/developmentontheedge/be5/server => test/java/com/developmentontheedge/be5}/test/mocks/CategoriesServiceForTest.java (92%) create mode 100644 test/pom.xml create mode 100644 test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java create mode 100644 test/src/main/java/com/developmentontheedge/be5/test/TestSession.java rename {server/src/main/java/com/developmentontheedge/be5/server => test/src/main/java/com/developmentontheedge/be5}/test/TestUtils.java (98%) create mode 100644 test/src/main/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java diff --git a/modules/core/pom.xml b/modules/core/pom.xml index d57868a66..33557f475 100644 --- a/modules/core/pom.xml +++ b/modules/core/pom.xml @@ -31,12 +31,6 @@ - - com.developmentontheedge.be5 - be5-server - 0.1.2-SNAPSHOT - - com.developmentontheedge.be5.modules be5-modules-system @@ -44,18 +38,12 @@ - com.h2database - h2 - 1.4.193 + com.developmentontheedge.be5 + be5-test + 0.0.3-SNAPSHOT test - - junit - junit - 4.12 - test - @@ -77,20 +65,20 @@ - - org.codehaus.gmavenplus - gmavenplus-plugin - 1.6 - - - + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.6 + + + addTestSources compileTests removeTestStubs - - - - + + + + diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java index 139b59b67..609404284 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java @@ -3,7 +3,7 @@ import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; import com.developmentontheedge.be5.modules.core.CoreModule; -import com.developmentontheedge.be5.server.test.TestUtils; +import com.developmentontheedge.be5.test.TestUtils; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java index 741cbd1b2..aafe38d57 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java @@ -2,8 +2,7 @@ import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; -import com.developmentontheedge.be5.modules.core.CoreModule; -import com.developmentontheedge.be5.server.test.TestUtils; +import com.developmentontheedge.be5.test.TestUtils; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; diff --git a/modules/system/pom.xml b/modules/system/pom.xml index 013920bc1..da921aea3 100644 --- a/modules/system/pom.xml +++ b/modules/system/pom.xml @@ -37,18 +37,12 @@ - com.h2database - h2 - 1.4.193 + com.developmentontheedge.be5 + be5-test + 0.0.3-SNAPSHOT test - - junit - junit - 4.12 - test - diff --git a/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java b/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java index 84341f708..47e0a7b16 100644 --- a/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java +++ b/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.modules.system; import com.developmentontheedge.be5.server.ServerModule; -import com.developmentontheedge.be5.server.test.TestUtils; +import com.developmentontheedge.be5.test.TestUtils; import com.google.inject.Injector; import com.google.inject.util.Modules; diff --git a/pom.xml b/pom.xml index 89a2ef37a..700dbb97c 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ server modules/core modules/system + test diff --git a/server/pom.xml b/server/pom.xml index 01fddfdb2..87cb3021d 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -62,29 +62,14 @@ com.developmentontheedge.be5 be5-test-base 0.0.3-SNAPSHOT - - - - junit - junit - 4.12 - - - - org.mockito - mockito-all - 1.10.19 + test com.developmentontheedge.be5 be5-maven-plugin 0.1.1-SNAPSHOT - - - com.developmentontheedge.be5 - be5-base - 0.0.3-SNAPSHOT + test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy index c76f2becc..8f391ff75 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy @@ -1,8 +1,7 @@ package com.developmentontheedge.be5.server -import com.developmentontheedge.be5.server.RestApiConstants import com.developmentontheedge.be5.server.model.Base64File -import com.developmentontheedge.be5.server.test.TestUtils +import com.developmentontheedge.be5.test.TestUtils import com.developmentontheedge.be5.server.util.ParseRequestUtils import com.developmentontheedge.be5.web.Request import com.google.common.collect.ImmutableMap diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/controllers/FormTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/controllers/FormTest.groovy index b59d3866a..a4af12d4a 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/controllers/FormTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/controllers/FormTest.groovy @@ -8,7 +8,7 @@ import javax.inject.Inject import com.developmentontheedge.be5.metadata.RoleType import com.developmentontheedge.be5.web.model.jsonapi.ErrorModel import com.developmentontheedge.be5.web.model.jsonapi.ResourceData -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest +import com.developmentontheedge.be5.test.ServerBe5ProjectTest import com.google.common.collect.ImmutableMap import groovy.transform.TypeChecked import org.junit.After diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsHelperTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsHelperTest.groovy index 29c53e67b..430de145c 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsHelperTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsHelperTest.groovy @@ -3,7 +3,7 @@ package com.developmentontheedge.be5.server.helpers import com.developmentontheedge.be5.base.services.Meta import com.developmentontheedge.be5.base.util.DpsUtils import com.developmentontheedge.be5.server.model.beans.GDynamicPropertySetSupport -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import com.developmentontheedge.beans.BeanInfoConstants import com.developmentontheedge.beans.DynamicProperty import com.developmentontheedge.beans.DynamicPropertySet diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsRecordAdapterTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsRecordAdapterTest.groovy index bab2dd585..fdf905a9d 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsRecordAdapterTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/helpers/DpsRecordAdapterTest.groovy @@ -2,7 +2,7 @@ package com.developmentontheedge.be5.server.helpers import com.developmentontheedge.be5.databasemodel.DatabaseModel import javax.inject.Inject -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import org.junit.Before; import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDPSTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDPSTest.groovy index 1c05ad0bd..fc00f6b07 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDPSTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDPSTest.groovy @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.server.model.beans import com.developmentontheedge.be5.operation.services.validation.ValidationRules -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import com.developmentontheedge.beans.json.JsonFactory import groovy.transform.TypeChecked import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDpsGetPropertyTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDpsGetPropertyTest.groovy index 850cd6cd4..332152476 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDpsGetPropertyTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/model/beans/GroovyDpsGetPropertyTest.groovy @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.server.model.beans -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import org.junit.Test import static org.junit.Assert.assertEquals diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/FilterOperationTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/FilterOperationTest.groovy index dc984b16a..d1e574bf3 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/FilterOperationTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/FilterOperationTest.groovy @@ -4,7 +4,7 @@ import com.developmentontheedge.be5.server.model.FrontendAction import com.developmentontheedge.be5.server.model.TablePresentation import com.developmentontheedge.be5.web.model.jsonapi.JsonApiModel import com.developmentontheedge.be5.operation.model.OperationResult -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.be5.server.util.Either import com.developmentontheedge.beans.json.JsonFactory import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/GroovyOperationTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/GroovyOperationTest.groovy index 6638281a8..fc88c1a99 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/GroovyOperationTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/GroovyOperationTest.groovy @@ -3,7 +3,7 @@ package com.developmentontheedge.be5.server.operations import com.developmentontheedge.be5.operation.model.Operation import com.developmentontheedge.be5.operation.model.OperationResult import com.developmentontheedge.be5.operation.model.OperationStatus -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.be5.test.mocks.DbServiceMock import com.developmentontheedge.be5.server.util.Either import com.developmentontheedge.beans.json.JsonFactory diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/OperationTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/OperationTest.groovy index bc2d1e8f0..402761109 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/OperationTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/OperationTest.groovy @@ -3,7 +3,7 @@ package com.developmentontheedge.be5.server.operations import com.developmentontheedge.be5.base.FrontendConstants import com.developmentontheedge.be5.operation.model.OperationContext import com.developmentontheedge.be5.operation.model.OperationResult -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.be5.test.mocks.DbServiceMock import com.developmentontheedge.be5.server.util.Either import com.developmentontheedge.beans.json.JsonFactory diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/CustomOpTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/CustomOpTest.groovy index 64da9e37e..23b35be69 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/CustomOpTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/CustomOpTest.groovy @@ -2,7 +2,7 @@ package com.developmentontheedge.be5.server.operations.operationParams import com.developmentontheedge.be5.operation.model.OperationContext import com.developmentontheedge.be5.operation.model.OperationResult -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.be5.server.util.Either import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/GetRedirectParamsTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/GetRedirectParamsTest.groovy index 1669a4d97..a02418f87 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/GetRedirectParamsTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/GetRedirectParamsTest.groovy @@ -2,7 +2,7 @@ package com.developmentontheedge.be5.server.operations.operationParams import com.developmentontheedge.be5.operation.model.Operation import com.developmentontheedge.be5.operation.model.OperationContext -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import org.junit.Test import static com.developmentontheedge.be5.base.FrontendConstants.SEARCH_PARAM diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/InsertOpTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/InsertOpTest.groovy index 7ca301691..7f700810c 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/InsertOpTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/operations/operationParams/InsertOpTest.groovy @@ -2,7 +2,7 @@ package com.developmentontheedge.be5.server.operations.operationParams import com.developmentontheedge.be5.operation.model.OperationContext import com.developmentontheedge.be5.operation.model.OperationResult -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.be5.server.util.Either import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ConfigurationProviderTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ConfigurationProviderTest.groovy index 186e05f7f..202a2c223 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ConfigurationProviderTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ConfigurationProviderTest.groovy @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.server.services -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import org.junit.Ignore import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationExecutorTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationExecutorTest.groovy index 5d075bce4..c70eccd32 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationExecutorTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationExecutorTest.groovy @@ -8,7 +8,7 @@ import com.developmentontheedge.be5.operation.model.OperationInfo import com.developmentontheedge.be5.operation.model.OperationStatus import com.developmentontheedge.be5.operation.services.OperationExecutor import com.developmentontheedge.be5.operation.services.OperationsFactory -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import org.junit.Test import javax.inject.Inject diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationHelperTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationHelperTest.groovy index 63478b779..4716c9445 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationHelperTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationHelperTest.groovy @@ -6,7 +6,7 @@ import com.developmentontheedge.be5.query.sql.DpsRecordAdapter import javax.inject.Inject import com.developmentontheedge.be5.server.model.beans.QRec import com.developmentontheedge.be5.databasemodel.DatabaseModel -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import com.developmentontheedge.beans.DynamicPropertySet import org.junit.Before import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceExtendTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceExtendTest.groovy index c5fe6c5ab..492e0968e 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceExtendTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceExtendTest.groovy @@ -5,7 +5,7 @@ import com.developmentontheedge.be5.base.services.ProjectProvider import com.developmentontheedge.be5.operation.services.GroovyOperationLoader import javax.inject.Inject -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import groovy.transform.TypeChecked import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceTest.groovy index 744f370f9..38e451c3d 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/OperationServiceTest.groovy @@ -5,7 +5,7 @@ import com.developmentontheedge.be5.metadata.RoleType import com.developmentontheedge.be5.operation.model.Operation import com.developmentontheedge.be5.operation.model.OperationResult import com.developmentontheedge.be5.operation.model.OperationStatus -import com.developmentontheedge.be5.server.test.SqlMockOperationTest +import com.developmentontheedge.be5.test.SqlMockOperationTest import com.developmentontheedge.beans.json.JsonFactory import org.junit.Ignore import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/TestTableQueryDBTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/TestTableQueryDBTest.groovy index 072cd5f4e..1c156884c 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/TestTableQueryDBTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/TestTableQueryDBTest.groovy @@ -4,7 +4,7 @@ import com.developmentontheedge.be5.base.services.ProjectProvider import com.developmentontheedge.be5.database.DbService import javax.inject.Inject -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest import org.junit.Before abstract class TestTableQueryDBTest extends ServerBe5ProjectDBTest diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceNumbersTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceNumbersTest.groovy index a8ab83d1a..43ef76290 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceNumbersTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceNumbersTest.groovy @@ -4,7 +4,7 @@ import com.developmentontheedge.be5.base.exceptions.Be5Exception import com.developmentontheedge.be5.operation.services.validation.Validator import javax.inject.Inject import com.developmentontheedge.be5.server.model.beans.GDynamicPropertySetSupport -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest +import com.developmentontheedge.be5.test.ServerBe5ProjectTest import com.developmentontheedge.beans.json.JsonFactory import org.junit.Before import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceTest.groovy index 8a8843519..3c84fe159 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceTest.groovy @@ -3,7 +3,7 @@ package com.developmentontheedge.be5.server.services import com.developmentontheedge.be5.operation.services.validation.Validator import javax.inject.Inject import com.developmentontheedge.be5.server.model.beans.GDynamicPropertySetSupport -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest +import com.developmentontheedge.be5.test.ServerBe5ProjectTest import com.developmentontheedge.beans.BeanInfoConstants import com.developmentontheedge.beans.DynamicProperty import org.junit.Before diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceValueInTagsTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceValueInTagsTest.groovy index 3359957bc..516f781ba 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceValueInTagsTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/ValidatorServiceValueInTagsTest.groovy @@ -3,7 +3,7 @@ package com.developmentontheedge.be5.server.services import com.developmentontheedge.be5.operation.services.validation.Validator import javax.inject.Inject import com.developmentontheedge.be5.server.model.beans.GDynamicPropertySetSupport -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest +import com.developmentontheedge.be5.test.ServerBe5ProjectTest import com.developmentontheedge.beans.json.JsonFactory import org.junit.Before import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy index 103f49fcb..c3b68a21d 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.server.services.impl -import com.developmentontheedge.be5.server.test.TestUtils +import com.developmentontheedge.be5.test.TestUtils import com.developmentontheedge.beans.DynamicPropertySetSupport import org.junit.Test diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/test/AbstractProjectTestTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/test/AbstractProjectTestTest.groovy similarity index 93% rename from server/src/test/groovy/com/developmentontheedge/be5/server/test/AbstractProjectTestTest.groovy rename to server/src/test/groovy/com/developmentontheedge/be5/test/AbstractProjectTestTest.groovy index 4f5f652dc..fefa3ca88 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/test/AbstractProjectTestTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/test/AbstractProjectTestTest.groovy @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test +package com.developmentontheedge.be5.test import com.developmentontheedge.be5.web.Request import org.junit.Test diff --git a/server/src/test/java/com/developmentontheedge/be5/server/ResponseXmlTest.java b/server/src/test/java/com/developmentontheedge/be5/server/ResponseXmlTest.java index 1a763f2ae..1e378b350 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/ResponseXmlTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/ResponseXmlTest.java @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.server; import com.developmentontheedge.be5.web.impl.ResponseImpl; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.server.util.Jaxb; import com.developmentontheedge.be5.web.Response; import org.junit.Before; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/DownloadControllerTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/DownloadControllerTest.java index 5377fc26e..3b084b5ac 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/DownloadControllerTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/DownloadControllerTest.java @@ -2,7 +2,7 @@ import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Response; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import javax.inject.Inject; import com.google.common.collect.ImmutableMap; import org.junit.Ignore; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/LanguageSelectorTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/LanguageSelectorTest.java index c86a9e2ef..64a9cc202 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/LanguageSelectorTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/LanguageSelectorTest.java @@ -2,11 +2,10 @@ import javax.inject.Inject; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Response; import com.developmentontheedge.be5.base.exceptions.Be5ErrorCode; -import com.developmentontheedge.be5.base.exceptions.Be5Exception; import com.developmentontheedge.be5.base.exceptions.ErrorTitles; import com.google.common.collect.ImmutableMap; import org.junit.Rule; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/MenuTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/MenuTest.java index 2a6f9585a..4c0739638 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/MenuTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/MenuTest.java @@ -2,7 +2,7 @@ import javax.inject.Inject; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.web.Response; import com.developmentontheedge.be5.metadata.RoleType; import org.junit.Before; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/QueryBuilderTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/QueryBuilderTest.java index 7fbacef0b..def417ac3 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/QueryBuilderTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/QueryBuilderTest.java @@ -4,7 +4,7 @@ import com.developmentontheedge.be5.server.RestApiConstants; import javax.inject.Inject; import com.developmentontheedge.be5.web.model.jsonapi.JsonApiModel; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/StaticPageControllerTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/StaticPageControllerTest.java index 1ba5f8544..7ffc916f5 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/StaticPageControllerTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/StaticPageControllerTest.java @@ -5,7 +5,7 @@ import com.developmentontheedge.be5.web.model.jsonapi.ErrorModel; import com.developmentontheedge.be5.web.model.jsonapi.ResourceData; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.web.Response; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/controllers/TableTest.java b/server/src/test/java/com/developmentontheedge/be5/server/controllers/TableTest.java index 3fa93c3f8..bbd3479ac 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/controllers/TableTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/controllers/TableTest.java @@ -3,7 +3,7 @@ import com.developmentontheedge.be5.web.Response; import com.developmentontheedge.be5.server.RestApiConstants; import com.developmentontheedge.be5.web.model.jsonapi.JsonApiModel; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/helpers/MenuHelperTest.java b/server/src/test/java/com/developmentontheedge/be5/server/helpers/MenuHelperTest.java index 70596da0b..723fee75f 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/helpers/MenuHelperTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/helpers/MenuHelperTest.java @@ -2,9 +2,8 @@ import com.developmentontheedge.be5.metadata.RoleType; import com.developmentontheedge.be5.metadata.model.EntityType; -import com.developmentontheedge.be5.server.helpers.MenuHelper; import com.developmentontheedge.be5.server.model.Action; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import org.junit.Test; import javax.inject.Inject; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/helpers/OperationHelperTest.java b/server/src/test/java/com/developmentontheedge/be5/server/helpers/OperationHelperTest.java index 9b0640af7..08209ce71 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/helpers/OperationHelperTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/helpers/OperationHelperTest.java @@ -2,7 +2,7 @@ import javax.inject.Inject; import com.developmentontheedge.be5.server.model.beans.QRec; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest; import com.developmentontheedge.beans.DynamicPropertySet; import com.google.common.collect.ImmutableList; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/helpers/impl/UserAwareMetaImplTest.java b/server/src/test/java/com/developmentontheedge/be5/server/helpers/impl/UserAwareMetaImplTest.java index a95e05714..1f5c079ca 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/helpers/impl/UserAwareMetaImplTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/helpers/impl/UserAwareMetaImplTest.java @@ -2,7 +2,7 @@ import com.developmentontheedge.be5.base.services.UserAwareMeta; import javax.inject.Inject; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import org.junit.Test; import static org.junit.Assert.*; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java b/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java index 84a3cd54e..6ae2d8e70 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java @@ -3,9 +3,9 @@ import javax.inject.Inject; import com.developmentontheedge.be5.base.model.UserInfo; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.server.servlet.UserInfoHolder; -import com.developmentontheedge.be5.server.test.TestSession; +import com.developmentontheedge.be5.test.TestSession; import com.developmentontheedge.be5.server.helpers.UserHelper; import org.junit.Before; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/CustomOperationTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/CustomOperationTest.java index f1c6390ba..ff852b5af 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/CustomOperationTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/CustomOperationTest.java @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.server.operations; import com.developmentontheedge.be5.operation.model.OperationResult; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.developmentontheedge.be5.server.util.Either; import com.developmentontheedge.beans.json.JsonFactory; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/DateTimeTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/DateTimeTest.java index 7b3437afa..77cb96073 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/DateTimeTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/DateTimeTest.java @@ -2,7 +2,7 @@ import com.developmentontheedge.be5.operation.model.Operation; import com.developmentontheedge.be5.operation.model.OperationResult; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.developmentontheedge.be5.test.mocks.DbServiceMock; import com.developmentontheedge.be5.server.util.Either; import com.developmentontheedge.beans.json.JsonFactory; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java index 17f7bf65a..7fece440c 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java @@ -2,8 +2,8 @@ import com.developmentontheedge.be5.metadata.RoleType; import com.developmentontheedge.be5.operation.model.OperationResult; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest; -import com.developmentontheedge.be5.server.test.TestUtils; +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest; +import com.developmentontheedge.be5.test.TestUtils; import com.developmentontheedge.beans.json.JsonFactory; import com.google.common.collect.ImmutableMap; import org.junit.Before; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsTest.java index 315e83154..8b9438f07 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsTest.java @@ -3,7 +3,7 @@ import com.developmentontheedge.be5.operation.model.Operation; import com.developmentontheedge.be5.operation.model.OperationResult; import com.developmentontheedge.be5.operation.model.OperationStatus; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.developmentontheedge.be5.test.mocks.DbServiceMock; import com.developmentontheedge.beans.DynamicPropertySet; import com.developmentontheedge.beans.DynamicPropertySetSupport; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/TransactionalOperationTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/TransactionalOperationTest.java index c32163275..37d8d8957 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/TransactionalOperationTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/TransactionalOperationTest.java @@ -2,7 +2,7 @@ import com.developmentontheedge.be5.metadata.RoleType; import com.developmentontheedge.be5.operation.model.OperationResult; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectDBTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest; import com.developmentontheedge.be5.server.util.Either; import org.junit.Before; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/extenders/ExtendersTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/extenders/ExtendersTest.java index 1dc67f978..765432986 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/extenders/ExtendersTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/extenders/ExtendersTest.java @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.server.operations.extenders; import com.developmentontheedge.be5.operation.model.OperationResult; -import com.developmentontheedge.be5.server.test.SqlMockOperationTest; +import com.developmentontheedge.be5.test.SqlMockOperationTest; import com.developmentontheedge.be5.test.mocks.DbServiceMock; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/services/impl/LogConfiguratorTest.java b/server/src/test/java/com/developmentontheedge/be5/server/services/impl/LogConfiguratorTest.java index 51aecd71a..5549346a8 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/services/impl/LogConfiguratorTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/services/impl/LogConfiguratorTest.java @@ -3,7 +3,7 @@ import javax.inject.Inject; import com.developmentontheedge.be5.base.services.impl.LogConfigurator; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/servlet/MainServletTest.java b/server/src/test/java/com/developmentontheedge/be5/server/servlet/MainServletTest.java index a8a8104f3..d69d7379d 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/servlet/MainServletTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/servlet/MainServletTest.java @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.server.servlet; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/servlet/TemplateFilterTest.java b/server/src/test/java/com/developmentontheedge/be5/server/servlet/TemplateFilterTest.java index 887e622fc..14fc9fd03 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/servlet/TemplateFilterTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/servlet/TemplateFilterTest.java @@ -3,7 +3,7 @@ import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Response; import com.developmentontheedge.be5.metadata.RoleType; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import javax.inject.Inject; import org.junit.Before; import org.junit.Test; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/util/ActionHelperTest.java b/server/src/test/java/com/developmentontheedge/be5/server/util/ActionHelperTest.java index cb34804bf..a8b03f7c5 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/util/ActionHelperTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/util/ActionHelperTest.java @@ -5,7 +5,7 @@ import com.developmentontheedge.be5.metadata.QueryType; import com.developmentontheedge.be5.metadata.model.Entity; import com.developmentontheedge.be5.metadata.model.Query; -import com.developmentontheedge.be5.server.test.ServerBe5ProjectTest; +import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import org.junit.Test; import static org.junit.Assert.*; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectDBTest.java b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java similarity index 95% rename from server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectDBTest.java rename to server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java index c29729bd8..89d38f0b4 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectDBTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectTest.java b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java similarity index 94% rename from server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectTest.java rename to server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java index bf61ea086..50ec69bec 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/test/ServerBe5ProjectTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; diff --git a/server/src/test/java/com/developmentontheedge/be5/server/test/SqlMockOperationTest.java b/server/src/test/java/com/developmentontheedge/be5/test/SqlMockOperationTest.java similarity index 93% rename from server/src/test/java/com/developmentontheedge/be5/server/test/SqlMockOperationTest.java rename to server/src/test/java/com/developmentontheedge/be5/test/SqlMockOperationTest.java index 97d8d985e..555228157 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/test/SqlMockOperationTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/SqlMockOperationTest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; import com.developmentontheedge.be5.server.helpers.DpsHelper; import com.developmentontheedge.be5.base.services.Meta; diff --git a/server/src/main/java/com/developmentontheedge/be5/server/test/TestRequest.java b/server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java similarity index 97% rename from server/src/main/java/com/developmentontheedge/be5/server/test/TestRequest.java rename to server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java index 0ebd60f6c..3339a7d68 100644 --- a/server/src/main/java/com/developmentontheedge/be5/server/test/TestRequest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Session; diff --git a/server/src/main/java/com/developmentontheedge/be5/server/test/TestSession.java b/server/src/test/java/com/developmentontheedge/be5/test/TestSession.java similarity index 95% rename from server/src/main/java/com/developmentontheedge/be5/server/test/TestSession.java rename to server/src/test/java/com/developmentontheedge/be5/test/TestSession.java index 01ccbf04e..865fcc772 100644 --- a/server/src/main/java/com/developmentontheedge/be5/server/test/TestSession.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/TestSession.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; import com.developmentontheedge.be5.web.Session; diff --git a/server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java b/server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java new file mode 100644 index 000000000..46147f36e --- /dev/null +++ b/server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java @@ -0,0 +1,306 @@ +package com.developmentontheedge.be5.test; + +import com.developmentontheedge.be5.web.Request; +import com.developmentontheedge.be5.server.RestApiConstants; +import com.developmentontheedge.be5.base.services.UserAwareMeta; +import com.developmentontheedge.be5.server.helpers.UserHelper; +import com.developmentontheedge.be5.web.impl.RequestImpl; +import com.developmentontheedge.be5.server.services.CategoriesService; +import com.developmentontheedge.be5.base.services.CoreUtils; +import com.developmentontheedge.be5.database.DbService; +import com.developmentontheedge.be5.base.services.Meta; +import com.developmentontheedge.be5.operation.services.OperationExecutor; +import com.developmentontheedge.be5.server.services.OperationService; +import com.developmentontheedge.be5.databasemodel.DatabaseModel; +import com.developmentontheedge.be5.server.model.beans.QRec; +import com.developmentontheedge.be5.base.model.UserInfo; +import com.developmentontheedge.be5.operation.model.Operation; +import com.developmentontheedge.be5.operation.model.OperationContext; +import com.developmentontheedge.be5.operation.model.OperationInfo; +import com.developmentontheedge.be5.operation.model.OperationResult; +import com.developmentontheedge.be5.server.servlet.UserInfoHolder; +import com.developmentontheedge.be5.test.mocks.CategoriesServiceForTest; +import com.developmentontheedge.be5.test.mocks.CoreUtilsForTest; +import com.developmentontheedge.be5.server.util.Either; +import com.developmentontheedge.be5.server.util.ParseRequestUtils; +import com.developmentontheedge.be5.base.util.Utils; +import com.google.common.collect.ImmutableMap; +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; +import org.junit.Rule; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; +import org.mockito.Mockito; + +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.logging.Logger; + +import static com.developmentontheedge.be5.metadata.model.Operation.OPERATION_TYPE_GROOVY; +import static com.developmentontheedge.be5.server.util.ParseRequestUtils.replaceEmptyStringToNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + + +public abstract class TestUtils extends BaseTestUtils +{ + public static final Logger log = Logger.getLogger(BaseTestUtils.class.getName()); + + @Rule + public ShowCreatedOperations showCreatedOperations = new ShowCreatedOperations(); + + @Inject private OperationService operationService; + @Inject private Meta meta; + @Inject private OperationExecutor operationExecutor; + @Inject protected UserAwareMeta userAwareMeta; + @Inject protected DatabaseModel database; + @Inject protected DbService db; + + protected void initUserWithRoles(String... roles) + { + TestSession testSession = new TestSession(); + UserInfo userInfo = getInjector().getInstance(UserHelper.class).saveUser(TEST_USER, Arrays.asList(roles), Arrays.asList(roles), + Locale.US, "", testSession); + + UserInfoHolder.setRequest(new TestRequest(testSession)); + UserInfoProviderForTest.userInfo = userInfo; + } + + protected Request getMockRequest(String requestUri) + { + Request request = mock(Request.class); + when(request.getRequestUri()).thenReturn(requestUri); + return request; + } + + protected Request getSpyMockRequest(String requestUri) + { + return getSpyMockRequest(requestUri, new HashMap<>(), new HashMap<>()); + } + + protected Request getSpyMockRequest(String requestUri, Map parameters) + { + return getSpyMockRequest(requestUri, parameters, new HashMap<>()); + } + + protected Request getSpyMockRequest(String requestUri, Map parameters, Map sessionValues) + { + HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); + when(httpServletRequest.getSession()).thenReturn(mock(HttpSession.class)); + + parameters.forEach((k,v) -> + when(httpServletRequest.getParameter(k)).thenReturn((String) v) + ); + + Request request = Mockito.spy(new RequestImpl(httpServletRequest, null)); + when(request.getRequestUri()).thenReturn(requestUri); + + for (Map.Entry entry: sessionValues.entrySet()) + { + when(request.getAttribute(entry.getKey())).thenReturn(entry.getValue()); + } + + return request; + } + + protected Request getSpyMockRecForOp(String entity, String query, String operation, String selectedRows, String values, Map sessionValues) + { + return getSpyMockRequest("", ImmutableMap.of( + RestApiConstants.ENTITY, entity, + RestApiConstants.QUERY, query, + RestApiConstants.OPERATION, operation, + RestApiConstants.SELECTED_ROWS, selectedRows, + RestApiConstants.VALUES, values), + sessionValues + ); + } + + protected Request getSpyMockRecForQuery(String entity, String query, String values) + { + return getSpyMockRecForQuery(entity, query, values, new HashMap<>()); + } + + protected Request getSpyMockRecForQuery(String entity, String query, String values, Map sessionValues) + { + return getSpyMockRequest("", ImmutableMap.of( + RestApiConstants.ENTITY, entity, + RestApiConstants.QUERY, query, + RestApiConstants.VALUES, values), + sessionValues + ); + } + + protected Request getSpyMockRecForOp(String entity, String query, String operation, String selectedRows, String values) + { + return getSpyMockRecForOp(entity, query, operation, selectedRows, values, new HashMap<>()); + } + + public static QRec getQRec(Map nameValues) + { + return getDps(new QRec(), nameValues); + } + + protected Either generateOperation(String entityName, String queryName, String operationName, + String selectedRows) + { + return generateOperation(entityName, queryName, operationName, selectedRows, Collections.emptyMap()); + } + + protected Either generateOperation(String entityName, String queryName, String operationName, + String selectedRows, String values) + { + return generateOperation(entityName, queryName, operationName, selectedRows, ParseRequestUtils.getValuesFromJson(values)); + } + + protected Either generateOperation(String entityName, String queryName, String operationName, + String selectedRows, Map presetValues) + { + return generateOperation(createOperation(entityName, queryName, operationName, selectedRows), presetValues); + } + + protected Either generateOperation(Operation operation, String values) + { + return operationService.generate(operation, ParseRequestUtils.getValuesFromJson(values)); + } + + protected Either generateOperation(Operation operation) + { + return operationService.generate(operation, Collections.emptyMap()); + } + + protected Either generateOperation(Operation operation, Map presetValues) + { + return operationService.generate(operation, replaceEmptyStringToNull(presetValues)); + } + + protected Either executeOperation(String entityName, String queryName, String operationName, + String selectedRows) + { + return executeOperation(entityName, queryName, operationName, selectedRows, Collections.emptyMap()); + } + + protected Either executeOperation(String entityName, String queryName, String operationName, + String selectedRows, String values) + { + return executeOperation(entityName, queryName, operationName, selectedRows, ParseRequestUtils.getValuesFromJson(values)); + } + + protected Either executeOperation(String entityName, String queryName, String operationName, + String selectedRows, Map presetValues) + { + return executeOperation(createOperation(entityName, queryName, operationName, selectedRows), presetValues); + } + + protected Either executeOperation(Operation operation, String values) + { + return executeOperation(operation, ParseRequestUtils.getValuesFromJson(values)); + } + + protected Either executeOperation(Operation operation) + { + return executeOperation(operation, Collections.emptyMap()); + } + + protected Either executeOperation(Operation operation, Map presetValues) + { + return operationService.execute(operation, replaceEmptyStringToNull(presetValues)); + } + + protected Operation createOperation(String entityName, String operationName, OperationContext context) + { + OperationInfo operationInfo = new OperationInfo(meta.getOperation(entityName, context.getQueryName(), operationName)); + + Operation operation = operationExecutor.create(operationInfo, context); + ShowCreatedOperations.addOperation(operation); + + return operation; + } + + protected Operation createOperation(String entityName, String queryName, String operationName, String selectedRowsParam) + { + OperationInfo operationInfo = new OperationInfo(meta.getOperation(entityName, queryName, operationName)); + + String[] stringSelectedRows = ParseRequestUtils.selectedRows(selectedRowsParam); + Object[] selectedRows = stringSelectedRows; + if(!operationInfo.getEntityName().startsWith("_")) + { + Class primaryKeyColumnType = meta.getColumnType(operationInfo.getEntity(), operationInfo.getPrimaryKey()); + selectedRows = Utils.changeTypes(stringSelectedRows, primaryKeyColumnType); + } + + Operation operation = operationExecutor.create(operationInfo, new OperationContext(selectedRows, queryName, Collections.emptyMap())); + ShowCreatedOperations.addOperation(operation); + + return operation; + } + + protected void setSession(String name, Object value) + { + UserInfoHolder.getSession().set(name, value); + } + + protected Object getSession(String name) + { + return UserInfoHolder.getSession().get(name); + } + + public static class ShowCreatedOperations extends TestWatcher + { + private static List operations = Collections.synchronizedList(new ArrayList<>()); + + public static void addOperation(Operation operation) + { + operations.add(operation); + } + + @Override + protected void starting(Description description) + { + operations.clear(); + } + + @Override + protected void failed(Throwable e, Description description) + { + if(!operations.isEmpty()) + { + StringBuilder sb = new StringBuilder(); + sb.append("Created operations:"); + operations.forEach(o -> + { + String line = "\n" + o.getClass().getCanonicalName() + "(" + o.getClass().getSimpleName() + extension(o) + ":0)"; + sb.append(line); + }); + log.info(sb.toString()); + } + } + + private String extension(Operation o) + { + if(OPERATION_TYPE_GROOVY.equals(o.getInfo().getModel().getType())){ + return ".groovy"; + } else { + return ".java"; + } + } + } + + public static class CoreModuleForTest extends AbstractModule + { + @Override + protected void configure() + { + bind(CoreUtils.class).to(CoreUtilsForTest.class).in(Scopes.SINGLETON); + bind(CategoriesService.class).to(CategoriesServiceForTest.class).in(Scopes.SINGLETON); + } + } + +} diff --git a/server/src/main/java/com/developmentontheedge/be5/server/test/mocks/CategoriesServiceForTest.java b/server/src/test/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java similarity index 92% rename from server/src/main/java/com/developmentontheedge/be5/server/test/mocks/CategoriesServiceForTest.java rename to server/src/test/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java index 314de4f3b..ded4d05c0 100644 --- a/server/src/main/java/com/developmentontheedge/be5/server/test/mocks/CategoriesServiceForTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.server.test.mocks; +package com.developmentontheedge.be5.test.mocks; import com.developmentontheedge.be5.server.services.CategoriesService; import com.developmentontheedge.be5.server.services.model.Category; diff --git a/test/pom.xml b/test/pom.xml new file mode 100644 index 000000000..4943b6055 --- /dev/null +++ b/test/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + be5 test + be5-test + + + be5 + com.developmentontheedge.be5 + 0.0.3-SNAPSHOT + + + + + com.developmentontheedge.be5 + be5-test-base + 0.0.3-SNAPSHOT + + + + com.developmentontheedge.be5 + be5-server + 0.1.2-SNAPSHOT + + + + \ No newline at end of file diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java b/test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java new file mode 100644 index 000000000..3339a7d68 --- /dev/null +++ b/test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java @@ -0,0 +1,134 @@ +package com.developmentontheedge.be5.test; + +import com.developmentontheedge.be5.web.Request; +import com.developmentontheedge.be5.web.Session; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.Locale; +import java.util.Map; + + +public class TestRequest implements Request +{ + private Session session = null; + + public TestRequest(Session session) + { + this.session = session; + } + + public TestRequest() + { + } + + @Override + public Session getSession() + { + return session == null ? new TestSession() : session; + } + + @Override + public Session getSession(boolean create) + { + if(create)return getSession(); + else return session; + } + + @Override + public String getRequestUri() + { + return null; + } + + @Override + public String getRemoteAddr() + { + return null; + } + + @Override + public HttpServletRequest getRawRequest() + { + return null; + } + + @Override + public HttpSession getRawSession() + { + return null; + } + + @Override + public String getServerUrl() + { + return null; + } + + @Override + public String getServerUrlWithContext() + { + return null; + } + + @Override + public String getContextPath() + { + return null; + } + + @Override + public String getBody() + { + return null; + } + + @Override + public Locale getLocale() + { + return null; + } + + @Override + public Map getParameters() + { + return null; + } + + @Override + public String get(String parameter) + { + return null; + } + + @Override + public List getList(String parameter) + { + return null; + } + + @Override + public String[] getParameterValues(String name) + { + return new String[0]; + } + + @Override + public String getSessionId() + { + return null; + } + + @Override + public Object getAttribute(String name) + { + return null; + } + + @Override + public void setAttribute(String name, Object value) + { + + } +} diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestSession.java b/test/src/main/java/com/developmentontheedge/be5/test/TestSession.java new file mode 100644 index 000000000..865fcc772 --- /dev/null +++ b/test/src/main/java/com/developmentontheedge/be5/test/TestSession.java @@ -0,0 +1,63 @@ +package com.developmentontheedge.be5.test; + +import com.developmentontheedge.be5.web.Session; + +import javax.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class TestSession implements Session +{ + private Map map = new HashMap<>(); + + @Override + public String getSessionId() + { + return "test session"; + } + + @Override + public Object get(String name) + { + return map.get(name); + } + + @Override + public void set(String name, Object value) + { + map.put(name, value); + } + + @Override + public void remove(String name) + { + set(name, null); + } + + @Override + public HttpSession getRawSession() + { + return null; + } + + @Override + public List getAttributeNames() + { + return new ArrayList<>(map.keySet()); + } + + @Override + public void invalidate() + { + + } + + @Override + public Map getAttributes() + { + return map; + } +} diff --git a/server/src/main/java/com/developmentontheedge/be5/server/test/TestUtils.java b/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java similarity index 98% rename from server/src/main/java/com/developmentontheedge/be5/server/test/TestUtils.java rename to test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java index dae091ded..68fdb8272 100644 --- a/server/src/main/java/com/developmentontheedge/be5/server/test/TestUtils.java +++ b/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java @@ -1,31 +1,30 @@ -package com.developmentontheedge.be5.server.test; +package com.developmentontheedge.be5.test; -import com.developmentontheedge.be5.query.QuerySession; -import com.developmentontheedge.be5.test.BaseTestUtils; -import com.developmentontheedge.be5.web.Request; -import com.developmentontheedge.be5.server.RestApiConstants; -import com.developmentontheedge.be5.base.services.UserAwareMeta; -import com.developmentontheedge.be5.server.helpers.UserHelper; -import com.developmentontheedge.be5.web.impl.RequestImpl; -import com.developmentontheedge.be5.server.services.CategoriesService; +import com.developmentontheedge.be5.base.model.UserInfo; import com.developmentontheedge.be5.base.services.CoreUtils; -import com.developmentontheedge.be5.database.DbService; import com.developmentontheedge.be5.base.services.Meta; -import com.developmentontheedge.be5.operation.services.OperationExecutor; -import com.developmentontheedge.be5.server.services.OperationService; +import com.developmentontheedge.be5.base.services.UserAwareMeta; +import com.developmentontheedge.be5.base.util.Utils; +import com.developmentontheedge.be5.database.DbService; import com.developmentontheedge.be5.databasemodel.DatabaseModel; -import com.developmentontheedge.be5.server.model.beans.QRec; -import com.developmentontheedge.be5.base.model.UserInfo; import com.developmentontheedge.be5.operation.model.Operation; import com.developmentontheedge.be5.operation.model.OperationContext; import com.developmentontheedge.be5.operation.model.OperationInfo; import com.developmentontheedge.be5.operation.model.OperationResult; +import com.developmentontheedge.be5.operation.services.OperationExecutor; +import com.developmentontheedge.be5.server.RestApiConstants; +import com.developmentontheedge.be5.server.helpers.UserHelper; +import com.developmentontheedge.be5.server.model.beans.QRec; +import com.developmentontheedge.be5.server.services.CategoriesService; +import com.developmentontheedge.be5.server.services.OperationService; import com.developmentontheedge.be5.server.servlet.UserInfoHolder; -import com.developmentontheedge.be5.server.test.mocks.CategoriesServiceForTest; -import com.developmentontheedge.be5.test.mocks.CoreUtilsForTest; import com.developmentontheedge.be5.server.util.Either; import com.developmentontheedge.be5.server.util.ParseRequestUtils; -import com.developmentontheedge.be5.base.util.Utils; +import com.developmentontheedge.be5.test.BaseTestUtils; +import com.developmentontheedge.be5.test.mocks.CategoriesServiceForTest; +import com.developmentontheedge.be5.test.mocks.CoreUtilsForTest; +import com.developmentontheedge.be5.web.Request; +import com.developmentontheedge.be5.web.impl.RequestImpl; import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; import com.google.inject.Scopes; @@ -35,8 +34,6 @@ import org.mockito.Mockito; import javax.inject.Inject; -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.util.ArrayList; diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java b/test/src/main/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java new file mode 100644 index 000000000..ded4d05c0 --- /dev/null +++ b/test/src/main/java/com/developmentontheedge/be5/test/mocks/CategoriesServiceForTest.java @@ -0,0 +1,29 @@ +package com.developmentontheedge.be5.test.mocks; + +import com.developmentontheedge.be5.server.services.CategoriesService; +import com.developmentontheedge.be5.server.services.model.Category; + +import java.util.Collections; +import java.util.List; + + +public class CategoriesServiceForTest implements CategoriesService +{ + @Override + public List getCategoriesForest(String entity, boolean hideEmpty) + { + return Collections.emptyList(); + } + + @Override + public List getRootCategory(String entityName) + { + return Collections.emptyList(); + } + + @Override + public List getCategoryNavigation(String entityName, long categoryID) + { + return Collections.emptyList(); + } +} From 6e748dce6e3d8cfb8f6120b61fc075afef3d6d5f Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 17:38:29 +0700 Subject: [PATCH 4/6] move test package - to new test module --- .../be5/base/services/impl/Be5CachesImpl.java | 9 +++- .../DatabaseModelProjectDbTest.java | 2 +- .../DatabaseModelSqlMockProjectTest.java | 2 +- .../core/groovy/DataSourceQueryTest.groovy | 26 ---------- .../modules/core/groovy/QueriesTest.groovy | 49 ------------------- .../core/services/CoreUtilsTest.groovy | 39 +++++++++++++-- .../modules/core/CoreBe5ProjectDBTest.java | 25 +--------- .../be5/modules/core/CoreBe5ProjectTest.java | 12 +---- .../modules/system/SystemBe5ProjectTest.java | 4 +- .../OperationsSqlMockProjectTest.java | 2 +- .../be5/query/QueryBe5ProjectDBTest.java | 2 +- .../be5/server/RequestTest.groovy | 4 +- .../impl/OperationServiceImplTest.groovy | 4 +- .../be5/server/model/UserInfoTest.java | 4 +- .../operations/StandardOperationsDBTest.java | 4 +- .../be5/test/ServerBe5ProjectDBTest.java | 15 ++---- .../be5/test/ServerBe5ProjectTest.java | 7 +-- .../{TestUtils.java => ServerTestUtils.java} | 8 +-- .../test/mocks/ServerTestQuerySession.java | 16 ++++++ .../ServerTestRequest.java} | 10 ++-- .../ServerTestSession.java} | 6 +-- .../be5/test/BaseTestUtils.java | 5 +- .../be5/test/TestUtils.java | 27 +++++++++- .../be5/test/mocks/TestQuerySession.java | 18 +++++++ .../be5/test/{ => mocks}/TestRequest.java | 2 +- .../be5/test/{ => mocks}/TestSession.java | 4 +- 26 files changed, 144 insertions(+), 162 deletions(-) delete mode 100644 modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/DataSourceQueryTest.groovy delete mode 100644 modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/QueriesTest.groovy rename server/src/test/java/com/developmentontheedge/be5/test/{TestUtils.java => ServerTestUtils.java} (97%) create mode 100644 server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestQuerySession.java rename server/src/test/java/com/developmentontheedge/be5/test/{TestRequest.java => mocks/ServerTestRequest.java} (88%) rename server/src/test/java/com/developmentontheedge/be5/test/{TestSession.java => mocks/ServerTestSession.java} (89%) create mode 100644 test/src/main/java/com/developmentontheedge/be5/test/mocks/TestQuerySession.java rename test/src/main/java/com/developmentontheedge/be5/test/{ => mocks}/TestRequest.java (97%) rename test/src/main/java/com/developmentontheedge/be5/test/{ => mocks}/TestSession.java (93%) diff --git a/base/src/main/java/com/developmentontheedge/be5/base/services/impl/Be5CachesImpl.java b/base/src/main/java/com/developmentontheedge/be5/base/services/impl/Be5CachesImpl.java index c2917423b..01c7bbb9d 100644 --- a/base/src/main/java/com/developmentontheedge/be5/base/services/impl/Be5CachesImpl.java +++ b/base/src/main/java/com/developmentontheedge/be5/base/services/impl/Be5CachesImpl.java @@ -15,11 +15,16 @@ public class Be5CachesImpl implements Be5Caches, Configurable { - private Config config = new Config(); + private Config config; - class Config + public static class Config { Map cacheSizes = new HashMap<>(); + + public Config(Map cacheSizes) + { + this.cacheSizes = cacheSizes; + } } private Map caches = new ConcurrentHashMap<>(); diff --git a/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelProjectDbTest.java b/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelProjectDbTest.java index 189eb7824..33b6271b4 100644 --- a/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelProjectDbTest.java +++ b/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelProjectDbTest.java @@ -13,7 +13,7 @@ public abstract class DatabaseModelProjectDbTest extends BaseTestUtils @Inject protected DatabaseModel database; private static final Injector injector = initInjector( - Modules.override(new BaseModule()).with(new TestProjectProviderModule()) + Modules.override(new BaseModule()).with(new BaseDbTestModule()) ); static { diff --git a/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelSqlMockProjectTest.java b/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelSqlMockProjectTest.java index 25639d4e1..fe44a0d75 100644 --- a/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelSqlMockProjectTest.java +++ b/database-model/src/test/java/com/developmentontheedge/be5/databasemodel/DatabaseModelSqlMockProjectTest.java @@ -13,7 +13,7 @@ public abstract class DatabaseModelSqlMockProjectTest extends BaseTestUtils @Inject protected DatabaseModel database; private static final Injector injector = initInjector( - Modules.override(new BaseModule()).with(new SqlMockModule()) + Modules.override(new BaseModule()).with(new BaseDbMockTestModule()) ); @Override diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/DataSourceQueryTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/DataSourceQueryTest.groovy deleted file mode 100644 index 6409a7a74..000000000 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/DataSourceQueryTest.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package com.developmentontheedge.be5.modules.core.groovy - -import com.developmentontheedge.be5.base.services.Meta -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDBTest - -import javax.inject.Inject -import org.junit.Test - -class DataSourceQueryTest extends CoreBe5ProjectDBTest -{ - @Inject Meta meta - - @Test - void get() throws Exception - { - meta.getQuery("_system_", "DataSource"); -// TableModel tableModel = new DataSource().initialize( -// injector.getMeta().getQuery("_system_", "DataSource Parameters"), -// new HashMap<>(), -// getMockRequest(""), -// injector -// ).get(); -// assertTrue(tableModel.getRows().size() > 0); - } - -} \ No newline at end of file diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/QueriesTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/QueriesTest.groovy deleted file mode 100644 index 894748f18..000000000 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/groovy/QueriesTest.groovy +++ /dev/null @@ -1,49 +0,0 @@ -package com.developmentontheedge.be5.modules.core.groovy - -import com.developmentontheedge.be5.base.services.Meta -import com.developmentontheedge.be5.server.services.DocumentGenerator -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDBTest -import com.developmentontheedge.be5.query.model.CellModel -import com.developmentontheedge.be5.metadata.model.Query -import javax.inject.Inject -import org.junit.Test - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertTrue - - -class QueriesTest extends CoreBe5ProjectDBTest -{ - @Inject DocumentGenerator documentGenerator - @Inject Meta meta - - @Test - void getEntities() - { - Query query = meta.getQuery("_system_", "Entities") - - def table = documentGenerator.getTablePresentation(query, Collections.emptyMap()) - - assertTrue(table.getRows().stream() - .filter({ x -> ((CellModel)x.cells.get(0)).getContent() == "users"}) - .findFirst().present) - } - - @Test - void getSessionVariables() - { - setSession("test", "value") - Query query = meta.getQuery("_system_", "Session variables") - - def table = documentGenerator.getTablePresentation(query, Collections.emptyMap()) - - assertEquals(true, table.getRows().stream() - .map({x -> x.id}) - .filter({x -> x.equals("test")}) - .findFirst().isPresent()) - -// assertEquals("test", ((TableModel.CellModel)table.getRows().get(0).cells.get(0)).content) -// assertEquals("value", ((TableModel.CellModel)table.getRows().get(0).cells.get(1)).content) - } - -} \ No newline at end of file diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy index 7424b1f86..003077d62 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy @@ -2,19 +2,50 @@ package com.developmentontheedge.be5.modules.core.services import com.developmentontheedge.be5.base.services.Be5Caches import com.developmentontheedge.be5.base.services.CoreUtils +import com.developmentontheedge.be5.base.services.ProjectProvider import com.developmentontheedge.be5.database.DbService import com.developmentontheedge.be5.databasemodel.DatabaseModel -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDBTest +import com.developmentontheedge.be5.modules.core.CoreModule import com.developmentontheedge.be5.modules.core.services.impl.CoreUtilsImpl -import javax.inject.Inject +import com.developmentontheedge.be5.server.ServerModule +import com.developmentontheedge.be5.test.TestProjectProvider +import com.developmentontheedge.be5.test.TestUtils +import com.google.inject.AbstractModule +import com.google.inject.Injector +import com.google.inject.Scopes +import com.google.inject.util.Modules import org.junit.Before import org.junit.Test -import static org.junit.Assert.* +import javax.inject.Inject + +import static org.junit.Assert.assertEquals -class CoreUtilsTest extends CoreBe5ProjectDBTest +class CoreUtilsTest extends TestUtils { + private static final Injector injector = initInjector( + Modules.override( + new ServerModule(), + new CoreModule() + ).with(new Module()) + ) + + @Override + Injector getInjector() + { + return injector + } + + static class Module extends AbstractModule + { + @Override + protected void configure() + { + bind(ProjectProvider.class).to(TestProjectProvider.class).in(Scopes.SINGLETON) + } + } + @Inject DatabaseModel database @Inject DbService db @Inject CoreUtils utils diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java index 609404284..b43916d4d 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java @@ -1,10 +1,7 @@ package com.developmentontheedge.be5.modules.core; -import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; -import com.developmentontheedge.be5.modules.core.CoreModule; import com.developmentontheedge.be5.test.TestUtils; -import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; @@ -15,7 +12,7 @@ public abstract class CoreBe5ProjectDBTest extends TestUtils Modules.override( new ServerModule(), new CoreModule() - ).with(new ServerDBTestModule()) + ).with(new DbTestModule()) ); static { @@ -27,24 +24,4 @@ public Injector getInjector() { return injector; } - - - private static class ServerDBTestModule extends AbstractModule - { - @Override - protected void configure() - { - install(new TestProjectProviderModule()); - bind(QuerySession.class).to(QuerySessionForTest.class); - } - } - - public static class QuerySessionForTest implements QuerySession - { - @Override - public Object get(String name) - { - return null; - } - } } diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java index aafe38d57..f7870d6e5 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java @@ -14,7 +14,7 @@ public abstract class CoreBe5ProjectTest extends TestUtils Modules.override( new ServerModule(), new CoreModule() - ).with(new ServerTestModule()) + ).with(new DbMockTestModule()) ); @Override @@ -22,14 +22,4 @@ public Injector getInjector() { return injector; } - - private static class ServerTestModule extends AbstractModule - { - @Override - protected void configure() - { - install(new SqlMockModule()); - bind(QuerySession.class).to(CoreBe5ProjectDBTest.QuerySessionForTest.class); - } - } } diff --git a/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java b/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java index 47e0a7b16..fa8eed191 100644 --- a/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java +++ b/modules/system/src/test/java/com/developmentontheedge/be5/modules/system/SystemBe5ProjectTest.java @@ -12,8 +12,8 @@ public abstract class SystemBe5ProjectTest extends TestUtils Modules.override( new ServerModule(), new SystemModule(), - new CoreModuleForTest() - ).with(new SqlMockModule()) + new CoreTestModule() + ).with(new DbMockTestModule()) ); @Override diff --git a/operation/src/test/java/com/developmentontheedge/be5/operation/OperationsSqlMockProjectTest.java b/operation/src/test/java/com/developmentontheedge/be5/operation/OperationsSqlMockProjectTest.java index 8dfca8c4a..ccd9d5eca 100644 --- a/operation/src/test/java/com/developmentontheedge/be5/operation/OperationsSqlMockProjectTest.java +++ b/operation/src/test/java/com/developmentontheedge/be5/operation/OperationsSqlMockProjectTest.java @@ -36,7 +36,7 @@ public static void setUp() throws Exception initProjectWithOperation(); injector = initInjector( - Modules.override(new BaseModule()).with(new SqlMockModule()), + Modules.override(new BaseModule()).with(new BaseDbMockTestModule()), new OperationModule() ); diff --git a/query/src/test/java/com/developmentontheedge/be5/query/QueryBe5ProjectDBTest.java b/query/src/test/java/com/developmentontheedge/be5/query/QueryBe5ProjectDBTest.java index 67a7d698c..04a2e7f24 100644 --- a/query/src/test/java/com/developmentontheedge/be5/query/QueryBe5ProjectDBTest.java +++ b/query/src/test/java/com/developmentontheedge/be5/query/QueryBe5ProjectDBTest.java @@ -12,7 +12,7 @@ public abstract class QueryBe5ProjectDBTest extends BaseTestUtils { private static final Injector injector = initInjector( - Modules.override(new BaseModule()).with(new TestProjectProviderModule()), + Modules.override(new BaseModule()).with(new BaseDbTestModule()), new QueryModule(), new TestQueryModule() ); diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy index 8f391ff75..55d0be256 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/RequestTest.groovy @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.server import com.developmentontheedge.be5.server.model.Base64File -import com.developmentontheedge.be5.test.TestUtils +import com.developmentontheedge.be5.test.ServerTestUtils import com.developmentontheedge.be5.server.util.ParseRequestUtils import com.developmentontheedge.be5.web.Request import com.google.common.collect.ImmutableMap @@ -16,7 +16,7 @@ import static org.mockito.Mockito.mock import static org.mockito.Mockito.when -class RequestTest extends TestUtils +class RequestTest extends ServerTestUtils { HttpServletRequest rawRequest diff --git a/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy b/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy index c3b68a21d..5b705c2dd 100644 --- a/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy +++ b/server/src/test/groovy/com/developmentontheedge/be5/server/services/impl/OperationServiceImplTest.groovy @@ -1,13 +1,13 @@ package com.developmentontheedge.be5.server.services.impl -import com.developmentontheedge.be5.test.TestUtils +import com.developmentontheedge.be5.test.ServerTestUtils import com.developmentontheedge.beans.DynamicPropertySetSupport import org.junit.Test import static org.junit.Assert.* -class OperationServiceImplTest extends TestUtils +class OperationServiceImplTest extends ServerTestUtils { @Test void replaceValuesToStringDigitsAndDate() diff --git a/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java b/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java index 6ae2d8e70..fcf02ecfb 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/model/UserInfoTest.java @@ -5,7 +5,7 @@ import com.developmentontheedge.be5.base.model.UserInfo; import com.developmentontheedge.be5.test.ServerBe5ProjectTest; import com.developmentontheedge.be5.server.servlet.UserInfoHolder; -import com.developmentontheedge.be5.test.TestSession; +import com.developmentontheedge.be5.test.mocks.ServerTestSession; import com.developmentontheedge.be5.server.helpers.UserHelper; import org.junit.Before; import org.junit.Test; @@ -26,7 +26,7 @@ public class UserInfoTest extends ServerBe5ProjectTest public void setUpTestUser() { List roles = Arrays.asList("1", "2"); - ui = userHelper.saveUser("test", roles, roles, Locale.US, "", new TestSession()); + ui = userHelper.saveUser("test", roles, roles, Locale.US, "", new ServerTestSession()); assertEquals(roles, ui.getCurrentRoles()); } diff --git a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java index 7fece440c..1168229e6 100644 --- a/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/server/operations/StandardOperationsDBTest.java @@ -3,7 +3,7 @@ import com.developmentontheedge.be5.metadata.RoleType; import com.developmentontheedge.be5.operation.model.OperationResult; import com.developmentontheedge.be5.test.ServerBe5ProjectDBTest; -import com.developmentontheedge.be5.test.TestUtils; +import com.developmentontheedge.be5.test.ServerTestUtils; import com.developmentontheedge.beans.json.JsonFactory; import com.google.common.collect.ImmutableMap; import org.junit.Before; @@ -43,7 +43,7 @@ public void editInvoke() operationResult); assertEquals("EditName,123", - db.select("SELECT name, value FROM testtableAdmin WHERE id = ?", TestUtils::resultSetToString, id)); + db.select("SELECT name, value FROM testtableAdmin WHERE id = ?", ServerTestUtils::resultSetToString, id)); } @Test diff --git a/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java index 89d38f0b4..0a986c0c3 100644 --- a/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectDBTest.java @@ -2,12 +2,13 @@ import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; +import com.developmentontheedge.be5.test.mocks.ServerTestQuerySession; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; -public abstract class ServerBe5ProjectDBTest extends TestUtils +public abstract class ServerBe5ProjectDBTest extends ServerTestUtils { private static final Injector injector = initInjector( Modules.override(new ServerModule()).with(new ServerDBTestModule()), @@ -29,17 +30,9 @@ private static class ServerDBTestModule extends AbstractModule @Override protected void configure() { - install(new TestProjectProviderModule()); - bind(QuerySession.class).to(QuerySessionForTest.class); + install(new BaseDbTestModule()); + bind(QuerySession.class).to(ServerTestQuerySession.class); } } - public static class QuerySessionForTest implements QuerySession - { - @Override - public Object get(String name) - { - return null; - } - } } diff --git a/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java index 50ec69bec..223a7f27c 100644 --- a/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/ServerBe5ProjectTest.java @@ -3,12 +3,13 @@ import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; import com.developmentontheedge.be5.server.servlet.TemplateModule; +import com.developmentontheedge.be5.test.mocks.ServerTestQuerySession; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; -public abstract class ServerBe5ProjectTest extends TestUtils +public abstract class ServerBe5ProjectTest extends ServerTestUtils { private static final Injector injector = initInjector( Modules.override(new ServerModule(), new TemplateModule()).with(new ServerTestModule()), @@ -26,8 +27,8 @@ private static class ServerTestModule extends AbstractModule @Override protected void configure() { - install(new SqlMockModule()); - bind(QuerySession.class).to(ServerBe5ProjectDBTest.QuerySessionForTest.class); + install(new BaseDbMockTestModule()); + bind(QuerySession.class).to(ServerTestQuerySession.class); } } } diff --git a/server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java b/server/src/test/java/com/developmentontheedge/be5/test/ServerTestUtils.java similarity index 97% rename from server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java rename to server/src/test/java/com/developmentontheedge/be5/test/ServerTestUtils.java index 46147f36e..1d69d1527 100644 --- a/server/src/test/java/com/developmentontheedge/be5/test/TestUtils.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/ServerTestUtils.java @@ -1,5 +1,7 @@ package com.developmentontheedge.be5.test; +import com.developmentontheedge.be5.test.mocks.ServerTestRequest; +import com.developmentontheedge.be5.test.mocks.ServerTestSession; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.server.RestApiConstants; import com.developmentontheedge.be5.base.services.UserAwareMeta; @@ -50,7 +52,7 @@ import static org.mockito.Mockito.when; -public abstract class TestUtils extends BaseTestUtils +public abstract class ServerTestUtils extends BaseTestUtils { public static final Logger log = Logger.getLogger(BaseTestUtils.class.getName()); @@ -66,11 +68,11 @@ public abstract class TestUtils extends BaseTestUtils protected void initUserWithRoles(String... roles) { - TestSession testSession = new TestSession(); + ServerTestSession testSession = new ServerTestSession(); UserInfo userInfo = getInjector().getInstance(UserHelper.class).saveUser(TEST_USER, Arrays.asList(roles), Arrays.asList(roles), Locale.US, "", testSession); - UserInfoHolder.setRequest(new TestRequest(testSession)); + UserInfoHolder.setRequest(new ServerTestRequest(testSession)); UserInfoProviderForTest.userInfo = userInfo; } diff --git a/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestQuerySession.java b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestQuerySession.java new file mode 100644 index 000000000..aa1f43f5c --- /dev/null +++ b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestQuerySession.java @@ -0,0 +1,16 @@ +package com.developmentontheedge.be5.test.mocks; + +import com.developmentontheedge.be5.query.QuerySession; + +import java.util.HashMap; +import java.util.Map; + + +public class ServerTestQuerySession implements QuerySession +{ + @Override + public Object get(String name) + { + return null; + } +} diff --git a/server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestRequest.java similarity index 88% rename from server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java rename to server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestRequest.java index 3339a7d68..f34d99e0e 100644 --- a/server/src/test/java/com/developmentontheedge/be5/test/TestRequest.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestRequest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.test; +package com.developmentontheedge.be5.test.mocks; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Session; @@ -10,23 +10,23 @@ import java.util.Map; -public class TestRequest implements Request +public class ServerTestRequest implements Request { private Session session = null; - public TestRequest(Session session) + public ServerTestRequest(Session session) { this.session = session; } - public TestRequest() + public ServerTestRequest() { } @Override public Session getSession() { - return session == null ? new TestSession() : session; + return session == null ? new ServerTestSession() : session; } @Override diff --git a/server/src/test/java/com/developmentontheedge/be5/test/TestSession.java b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestSession.java similarity index 89% rename from server/src/test/java/com/developmentontheedge/be5/test/TestSession.java rename to server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestSession.java index 865fcc772..2c721d891 100644 --- a/server/src/test/java/com/developmentontheedge/be5/test/TestSession.java +++ b/server/src/test/java/com/developmentontheedge/be5/test/mocks/ServerTestSession.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.test; +package com.developmentontheedge.be5.test.mocks; import com.developmentontheedge.be5.web.Session; @@ -9,7 +9,7 @@ import java.util.Map; -public class TestSession implements Session +public class ServerTestSession implements Session { private Map map = new HashMap<>(); @@ -52,7 +52,7 @@ public List getAttributeNames() @Override public void invalidate() { - + map.clear(); } @Override diff --git a/test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java b/test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java index 743d57a07..c84f07af1 100644 --- a/test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java +++ b/test-base/src/main/java/com/developmentontheedge/be5/test/BaseTestUtils.java @@ -189,7 +189,7 @@ protected static void initDb(Injector injector) } } - public static class SqlMockModule extends AbstractModule + public static class BaseDbMockTestModule extends AbstractModule { @Override protected void configure() @@ -214,13 +214,14 @@ public UserInfo get() } } - public static class TestProjectProviderModule extends AbstractModule + public static class BaseDbTestModule extends AbstractModule { @Override protected void configure() { bind(ProjectProvider.class).to(TestProjectProvider.class).in(Scopes.SINGLETON); bind(UserInfoProvider.class).to(UserInfoProviderForTest.class).in(Scopes.SINGLETON); + bind(Be5Caches.class).to(Be5CachesForTest.class).in(Scopes.SINGLETON); } } diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java b/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java index 68fdb8272..938667e63 100644 --- a/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java +++ b/test/src/main/java/com/developmentontheedge/be5/test/TestUtils.java @@ -12,6 +12,7 @@ import com.developmentontheedge.be5.operation.model.OperationInfo; import com.developmentontheedge.be5.operation.model.OperationResult; import com.developmentontheedge.be5.operation.services.OperationExecutor; +import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.RestApiConstants; import com.developmentontheedge.be5.server.helpers.UserHelper; import com.developmentontheedge.be5.server.model.beans.QRec; @@ -20,9 +21,11 @@ import com.developmentontheedge.be5.server.servlet.UserInfoHolder; import com.developmentontheedge.be5.server.util.Either; import com.developmentontheedge.be5.server.util.ParseRequestUtils; -import com.developmentontheedge.be5.test.BaseTestUtils; import com.developmentontheedge.be5.test.mocks.CategoriesServiceForTest; import com.developmentontheedge.be5.test.mocks.CoreUtilsForTest; +import com.developmentontheedge.be5.test.mocks.TestQuerySession; +import com.developmentontheedge.be5.test.mocks.TestRequest; +import com.developmentontheedge.be5.test.mocks.TestSession; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.impl.RequestImpl; import com.google.common.collect.ImmutableMap; @@ -294,7 +297,7 @@ private String extension(Operation o) } } - public static class CoreModuleForTest extends AbstractModule + public static class CoreTestModule extends AbstractModule { @Override protected void configure() @@ -304,4 +307,24 @@ protected void configure() } } + public static class DbMockTestModule extends AbstractModule + { + @Override + protected void configure() + { + install(new BaseDbMockTestModule()); + bind(QuerySession.class).to(TestQuerySession.class); + } + } + + public static class DbTestModule extends AbstractModule + { + @Override + protected void configure() + { + install(new BaseDbTestModule()); + bind(QuerySession.class).to(TestQuerySession.class); + } + } + } diff --git a/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestQuerySession.java b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestQuerySession.java new file mode 100644 index 000000000..d6e608003 --- /dev/null +++ b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestQuerySession.java @@ -0,0 +1,18 @@ +package com.developmentontheedge.be5.test.mocks; + +import com.developmentontheedge.be5.query.QuerySession; + +import java.util.HashMap; +import java.util.Map; + + +public class TestQuerySession implements QuerySession +{ + public static final Map map = new HashMap<>(); + + @Override + public Object get(String name) + { + return map.get(name); + } +} diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestRequest.java similarity index 97% rename from test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java rename to test/src/main/java/com/developmentontheedge/be5/test/mocks/TestRequest.java index 3339a7d68..63f9134a7 100644 --- a/test/src/main/java/com/developmentontheedge/be5/test/TestRequest.java +++ b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestRequest.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.test; +package com.developmentontheedge.be5.test.mocks; import com.developmentontheedge.be5.web.Request; import com.developmentontheedge.be5.web.Session; diff --git a/test/src/main/java/com/developmentontheedge/be5/test/TestSession.java b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestSession.java similarity index 93% rename from test/src/main/java/com/developmentontheedge/be5/test/TestSession.java rename to test/src/main/java/com/developmentontheedge/be5/test/mocks/TestSession.java index 865fcc772..50ede5a06 100644 --- a/test/src/main/java/com/developmentontheedge/be5/test/TestSession.java +++ b/test/src/main/java/com/developmentontheedge/be5/test/mocks/TestSession.java @@ -1,4 +1,4 @@ -package com.developmentontheedge.be5.test; +package com.developmentontheedge.be5.test.mocks; import com.developmentontheedge.be5.web.Session; @@ -52,7 +52,7 @@ public List getAttributeNames() @Override public void invalidate() { - + map.clear(); } @Override From 90004c072b6515251f20fca5340b2874ee93afad Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 18:25:02 +0700 Subject: [PATCH 5/6] refactor GdslGenerator to Be5Mojo (and rename GroovyDSLGenerator) --- ...Generator.java => GroovyDSLGenerator.java} | 58 +++++++++++-------- .../be5/maven/gdsl/README.md | 47 ++++++--------- .../be5/maven/gdsl/Utils.java | 13 +++-- ...rTest.java => GroovyDSLGeneratorTest.java} | 12 ++-- 4 files changed, 67 insertions(+), 63 deletions(-) rename maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/{GdslGenerator.java => GroovyDSLGenerator.java} (56%) rename maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/{GdslGeneratorTest.java => GroovyDSLGeneratorTest.java} (66%) diff --git a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GdslGenerator.java b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGenerator.java similarity index 56% rename from maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GdslGenerator.java rename to maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGenerator.java index 5810f2caa..cc627f2b9 100644 --- a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GdslGenerator.java +++ b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGenerator.java @@ -1,51 +1,60 @@ package com.developmentontheedge.be5.maven.gdsl; +import com.developmentontheedge.be5.maven.Be5Mojo; import com.developmentontheedge.be5.metadata.exception.ProjectLoadException; import com.developmentontheedge.be5.metadata.model.Entity; import com.developmentontheedge.be5.metadata.model.Project; import com.developmentontheedge.be5.metadata.serialization.ModuleLoader2; import freemarker.template.Configuration; import freemarker.template.Template; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import java.io.File; import java.io.IOException; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.logging.Logger; -public class GdslGenerator +@Mojo( name = "generate-groovy-dsl") +public class GroovyDSLGenerator extends Be5Mojo { - private static final Logger log = Logger.getLogger(GdslGenerator.class.getName()); + private static final Logger log = Logger.getLogger(GroovyDSLGenerator.class.getName()); private int entityCount = 0; - public static void main(String[] args) throws IOException + @Parameter(property = "FILE_NAME") + protected String fileName; + + @Override + public void execute() throws MojoFailureException { - String generatedSourcesPath = args[0]; - String packageName = args[1]; - if(packageName == null){ - packageName = ""; - }else{ - if(!packageName.endsWith("."))packageName += "."; + try + { + generate(fileName.replace(".", "/") + "GroovyDSL"); + } + catch (IOException e) + { + throw new RuntimeException(e); } - - String serviceClassName = args[2] + "DatabaseModel"; - - new GdslGenerator(generatedSourcesPath, packageName, serviceClassName); } - public GdslGenerator(String generatedSourcesPath, String packageName, String serviceClassName) throws IOException + public void generate(String fileName) throws IOException { Configuration cfg = new Configuration(); - cfg.setClassForTemplateLoading(GdslGenerator.class, "/gdsl"); + cfg.setClassForTemplateLoading(GroovyDSLGenerator.class, "/gdsl"); cfg.setDefaultEncoding("UTF-8"); - File file = Paths.get(generatedSourcesPath + packageName.replace(".", "/") + serviceClassName + ".gdsl").toFile(); + File file = Paths.get(fileName + ".gdsl").toFile(); if(file.exists() && !file.isDirectory()) { - log.info("Generate skipped, file exists: " + packageName + "." + serviceClassName); + log.info("Generate skipped, file exists: " + fileName); return; } @@ -53,18 +62,17 @@ public GdslGenerator(String generatedSourcesPath, String packageName, String ser try { - createService(generatedSourcesPath, packageName, serviceClassName, cfg); + createDSL(fileName, cfg); } catch (ProjectLoadException e) { e.printStackTrace(); } - log.info("Generate successful: " + entityCount + " entities added.\n" + packageName + serviceClassName); + log.info("Generate successful: " + entityCount + " entities added.\n" + file.getAbsolutePath()); } - private void createService(String generatedSourcesPath, String packageName, - String serviceClassName, Configuration cfg) throws IOException, ProjectLoadException + private void createDSL(String fileName, Configuration cfg) throws IOException, ProjectLoadException { Template serviceTpl = cfg.getTemplate("/entities.ftl"); @@ -84,8 +92,10 @@ private void createService(String generatedSourcesPath, String packageName, entityNames.add(entity.getName()); } input.put("entityNames", entityNames); - Utils.createFile(generatedSourcesPath, packageName, serviceClassName+ ".gdsl", serviceTpl, input); + Utils.createFile(fileName + ".gdsl", serviceTpl, input); } - + @Override protected GroovyDSLGenerator me() { + return this; + } } diff --git a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/README.md b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/README.md index c9d388b7a..2e234a115 100644 --- a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/README.md +++ b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/README.md @@ -1,5 +1,5 @@ -### GdslGenegator +### GroovyDSLGenerator Генерирует GroovyDSL для таблиц в проекте GroovyDSL - добавляет поддержку мета классов для groovy: ```groovy @@ -16,36 +16,27 @@ contribute(context(ctype: "com.developmentontheedge.be5.databasemodel.EntityMode ``` Добавление в проект: -```xml - - com.developmentontheedge.be5 - be5-maven-plugin - 0.1.1-SNAPSHOT - -``` ```xml - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - GdslGenegator - - java - - compile - - com.developmentontheedge.be5.maven.gdsl.GdslGenegator - - ${project.build.directory}/generated-sources/java/ - - ${project.artifactId} - - - - + com.developmentontheedge.be5 + be5-maven-plugin + 0.1.1-SNAPSHOT + + ./ + + + + generate-groovy-dsl + compile + + generate-groovy-dsl + + + ${project.build.directory}/generated-sources/java/${project.artifactId} + + + org.codehaus.mojo diff --git a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/Utils.java b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/Utils.java index ae2fb4541..da47f748b 100644 --- a/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/Utils.java +++ b/maven/src/main/java/com/developmentontheedge/be5/maven/gdsl/Utils.java @@ -12,21 +12,22 @@ public class Utils { - public static void createFile(String generatedSourcesPath, String packageName, String fileName, - Template template, Map input) + public static void createFile(String fileName, Template template, Map input) { try { - Paths.get(generatedSourcesPath + packageName.replace(".", "/")).toFile().mkdirs(); - Writer fileWriter = new FileWriter(new File(generatedSourcesPath + packageName.replace(".", "/") + "/" + fileName)); + Paths.get(fileName.substring(0, fileName.lastIndexOf("/"))).toFile().mkdirs(); + Writer fileWriter = new FileWriter(new File(fileName)); try { template.process(input, fileWriter); - } catch (TemplateException e) + } + catch (TemplateException e) { e.printStackTrace(); - } finally + } + finally { fileWriter.close(); } diff --git a/maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GdslGeneratorTest.java b/maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGeneratorTest.java similarity index 66% rename from maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GdslGeneratorTest.java rename to maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGeneratorTest.java index f7f9a7055..701d6255e 100644 --- a/maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GdslGeneratorTest.java +++ b/maven/src/test/java/com/developmentontheedge/be5/maven/gdsl/GroovyDSLGeneratorTest.java @@ -3,6 +3,7 @@ import com.developmentontheedge.be5.maven.TestUtils; import com.google.common.base.Charsets; import com.google.common.io.Resources; +import org.apache.maven.plugin.MojoFailureException; import org.junit.Test; import java.io.IOException; @@ -14,15 +15,16 @@ import static org.junit.Assert.assertEquals; -public class GdslGeneratorTest extends TestUtils +public class GroovyDSLGeneratorTest extends TestUtils { @Test - public void test() throws IOException + public void test() throws IOException, MojoFailureException { - GdslGenerator.main(new String[]{tpmProjectPath.toAbsolutePath().toString() + "/", - "", ""}); + GroovyDSLGenerator groovyDSLGenerator = new GroovyDSLGenerator(); + groovyDSLGenerator.fileName = tpmProjectPath.toAbsolutePath().toString() + "/"; + groovyDSLGenerator.execute(); - String result = readFile(tpmProjectPath.toAbsolutePath().toString() + "/DatabaseModel.gdsl", Charsets.UTF_8); + String result = readFile(tpmProjectPath.toAbsolutePath().toString() + "/GroovyDSL.gdsl", Charsets.UTF_8); URL url = Resources.getResource("gdsl/test.txt"); String test = Resources.toString(url, Charsets.UTF_8); From 7e01e72b97e188d1d86efb6460f13ad0a731feec Mon Sep 17 00:00:00 2001 From: uuinnk Date: Thu, 31 May 2018 19:01:08 +0700 Subject: [PATCH 6/6] use one DBTest config --- .../be5/modules/core/LoadTest.groovy | 2 +- .../core/operations/users/LoginTest.groovy | 4 +-- .../core/operations/users/LogoutTest.groovy | 4 +-- .../core/services/CoreUtilsTest.groovy | 34 ++----------------- .../services/impl/LoginServiceImplTest.groovy | 4 +-- .../modules/core/CoreBe5ProjectDBTest.java | 20 ++++++++++- ...est.java => CoreBe5ProjectDbMockTest.java} | 4 +-- .../controllers/CategoriesControllerTest.java | 4 +-- .../controllers/UserInfoControllerTest.java | 4 +-- .../src/test/resources/logging.properties | 12 ------- 10 files changed, 33 insertions(+), 59 deletions(-) rename modules/core/src/test/java/com/developmentontheedge/be5/modules/core/{CoreBe5ProjectTest.java => CoreBe5ProjectDbMockTest.java} (77%) delete mode 100644 modules/core/src/test/resources/logging.properties diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/LoadTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/LoadTest.groovy index 31ac77944..946d0d95b 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/LoadTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/LoadTest.groovy @@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals import static org.junit.Assert.assertNotNull -class LoadTest extends CoreBe5ProjectTest +class LoadTest extends CoreBe5ProjectDbMockTest { @Inject ProjectProvider projectProvider diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LoginTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LoginTest.groovy index cefd010e5..b61eee596 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LoginTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LoginTest.groovy @@ -6,7 +6,7 @@ import com.developmentontheedge.be5.server.servlet.UserInfoHolder import com.developmentontheedge.be5.database.sql.ResultSetParser import com.developmentontheedge.be5.metadata.DatabaseConstants import com.developmentontheedge.be5.metadata.RoleType -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectTest +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDbMockTest import com.developmentontheedge.be5.server.model.FrontendAction import com.developmentontheedge.be5.modules.core.api.CoreFrontendActions import com.developmentontheedge.be5.modules.core.model.UserInfoModel @@ -24,7 +24,7 @@ import static org.mockito.Mockito.mock import static org.mockito.Mockito.when -class LoginTest extends CoreBe5ProjectTest +class LoginTest extends CoreBe5ProjectDbMockTest { @Before void init(){ diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LogoutTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LogoutTest.groovy index 83f1234f9..34adc08b0 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LogoutTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/operations/users/LogoutTest.groovy @@ -4,7 +4,7 @@ import com.developmentontheedge.be5.web.Request import com.developmentontheedge.be5.web.Session import com.developmentontheedge.be5.server.servlet.UserInfoHolder import com.developmentontheedge.be5.metadata.RoleType -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectTest +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDbMockTest import com.developmentontheedge.be5.server.model.FrontendAction import com.developmentontheedge.be5.modules.core.api.CoreFrontendActions import com.developmentontheedge.be5.modules.core.model.UserInfoModel @@ -17,7 +17,7 @@ import static org.mockito.Mockito.verify import static org.mockito.Mockito.when -class LogoutTest extends CoreBe5ProjectTest +class LogoutTest extends CoreBe5ProjectDbMockTest { @Test void logout() diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy index 003077d62..8a5d6411c 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/CoreUtilsTest.groovy @@ -2,18 +2,10 @@ package com.developmentontheedge.be5.modules.core.services import com.developmentontheedge.be5.base.services.Be5Caches import com.developmentontheedge.be5.base.services.CoreUtils -import com.developmentontheedge.be5.base.services.ProjectProvider import com.developmentontheedge.be5.database.DbService import com.developmentontheedge.be5.databasemodel.DatabaseModel -import com.developmentontheedge.be5.modules.core.CoreModule +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDBTest import com.developmentontheedge.be5.modules.core.services.impl.CoreUtilsImpl -import com.developmentontheedge.be5.server.ServerModule -import com.developmentontheedge.be5.test.TestProjectProvider -import com.developmentontheedge.be5.test.TestUtils -import com.google.inject.AbstractModule -import com.google.inject.Injector -import com.google.inject.Scopes -import com.google.inject.util.Modules import org.junit.Before import org.junit.Test @@ -22,30 +14,8 @@ import javax.inject.Inject import static org.junit.Assert.assertEquals -class CoreUtilsTest extends TestUtils +class CoreUtilsTest extends CoreBe5ProjectDBTest { - private static final Injector injector = initInjector( - Modules.override( - new ServerModule(), - new CoreModule() - ).with(new Module()) - ) - - @Override - Injector getInjector() - { - return injector - } - - static class Module extends AbstractModule - { - @Override - protected void configure() - { - bind(ProjectProvider.class).to(TestProjectProvider.class).in(Scopes.SINGLETON) - } - } - @Inject DatabaseModel database @Inject DbService db @Inject CoreUtils utils diff --git a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/impl/LoginServiceImplTest.groovy b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/impl/LoginServiceImplTest.groovy index 154fe698b..f56545b21 100644 --- a/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/impl/LoginServiceImplTest.groovy +++ b/modules/core/src/test/groovy/com/developmentontheedge/be5/modules/core/services/impl/LoginServiceImplTest.groovy @@ -1,7 +1,7 @@ package com.developmentontheedge.be5.modules.core.services.impl import com.developmentontheedge.be5.server.servlet.UserInfoHolder -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectTest +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDbMockTest import com.developmentontheedge.be5.modules.core.services.LoginService import javax.inject.Inject import org.junit.Before @@ -10,7 +10,7 @@ import org.junit.Test import static org.junit.Assert.* -class LoginServiceImplTest extends CoreBe5ProjectTest +class LoginServiceImplTest extends CoreBe5ProjectDbMockTest { @Inject LoginService loginService diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java index b43916d4d..5b14086e8 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDBTest.java @@ -1,8 +1,15 @@ package com.developmentontheedge.be5.modules.core; +import com.developmentontheedge.be5.base.UserInfoProvider; +import com.developmentontheedge.be5.base.services.ProjectProvider; +import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; +import com.developmentontheedge.be5.test.TestProjectProvider; import com.developmentontheedge.be5.test.TestUtils; +import com.developmentontheedge.be5.test.mocks.TestQuerySession; +import com.google.inject.AbstractModule; import com.google.inject.Injector; +import com.google.inject.Scopes; import com.google.inject.util.Modules; @@ -12,13 +19,24 @@ public abstract class CoreBe5ProjectDBTest extends TestUtils Modules.override( new ServerModule(), new CoreModule() - ).with(new DbTestModule()) + ).with(new ServerDBTestModule()) ); static { initDb(injector); } + private static class ServerDBTestModule extends AbstractModule + { + @Override + protected void configure() + { + bind(ProjectProvider.class).to(TestProjectProvider.class).in(Scopes.SINGLETON); + bind(UserInfoProvider.class).to(UserInfoProviderForTest.class).in(Scopes.SINGLETON); + bind(QuerySession.class).to(TestQuerySession.class); + } + } + @Override public Injector getInjector() { diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDbMockTest.java similarity index 77% rename from modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java rename to modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDbMockTest.java index f7870d6e5..406346584 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/CoreBe5ProjectDbMockTest.java @@ -1,14 +1,12 @@ package com.developmentontheedge.be5.modules.core; -import com.developmentontheedge.be5.query.QuerySession; import com.developmentontheedge.be5.server.ServerModule; import com.developmentontheedge.be5.test.TestUtils; -import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.util.Modules; -public abstract class CoreBe5ProjectTest extends TestUtils +public abstract class CoreBe5ProjectDbMockTest extends TestUtils { private static final Injector injector = initInjector( Modules.override( diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/CategoriesControllerTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/CategoriesControllerTest.java index 745dc16f4..e8b2dd4fe 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/CategoriesControllerTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/CategoriesControllerTest.java @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.modules.core.controllers; -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectTest; +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDbMockTest; import com.developmentontheedge.be5.web.Response; import javax.inject.Inject; import org.junit.Test; @@ -12,7 +12,7 @@ import static org.mockito.Mockito.verify; -public class CategoriesControllerTest extends CoreBe5ProjectTest +public class CategoriesControllerTest extends CoreBe5ProjectDbMockTest { @Inject private CategoriesController component; diff --git a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/UserInfoControllerTest.java b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/UserInfoControllerTest.java index 6ce2f8951..a1c8f6250 100644 --- a/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/UserInfoControllerTest.java +++ b/modules/core/src/test/java/com/developmentontheedge/be5/modules/core/controllers/UserInfoControllerTest.java @@ -1,6 +1,6 @@ package com.developmentontheedge.be5.modules.core.controllers; -import com.developmentontheedge.be5.modules.core.CoreBe5ProjectTest; +import com.developmentontheedge.be5.modules.core.CoreBe5ProjectDbMockTest; import com.developmentontheedge.be5.web.Response; import javax.inject.Inject; import com.developmentontheedge.be5.metadata.RoleType; @@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify; -public class UserInfoControllerTest extends CoreBe5ProjectTest +public class UserInfoControllerTest extends CoreBe5ProjectDbMockTest { @Inject private UserInfoController component; diff --git a/modules/core/src/test/resources/logging.properties b/modules/core/src/test/resources/logging.properties deleted file mode 100644 index 558e8d700..000000000 --- a/modules/core/src/test/resources/logging.properties +++ /dev/null @@ -1,12 +0,0 @@ -handlers= java.util.logging.ConsoleHandler -#.level=FINE -#java.util.logging.ConsoleHandler.level=FINE - - -#handlers = java.util.logging.FileHandler -#java.util.logging.FileHandler.pattern=condo-lk2-log.txt -#java.util.logging.FileHandler.limit=1000000 -#java.util.logging.FileHandler.count=5 -#java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter - -