This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 293e83ca6b ISIS-3120: adds JUnit test: validate demo domain (JPA)
293e83ca6b is described below

commit 293e83ca6b67a6b50695a5a14331bd4f46e95c21
Author: andi-huber <[email protected]>
AuthorDate: Sun Aug 14 11:59:48 2022 +0200

    ISIS-3120: adds JUnit test: validate demo domain (JPA)
---
 bom/pom.xml                                        |  1 +
 examples/demo/domain-tests/pom.xml                 | 86 +++++++++++++++++++++
 .../domain/tests/conf/Configuration_usingJpa.java  | 53 +++++++++++++
 .../domain/tests/DomainIntrospectionTestJpa.java   | 90 ++++++++++++++++++++++
 tooling/pom.xml                                    |  1 -
 valuetypes/asciidoc/pom.xml                        |  1 -
 6 files changed, 230 insertions(+), 2 deletions(-)

diff --git a/bom/pom.xml b/bom/pom.xml
index af1c425ad2..d51e6f9d78 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -345,6 +345,7 @@ under the License.
 
         <!-- LIBRARY DEPENDENCIES -->
                <archunit.version>0.23.1</archunit.version>
+               <asciidoctorj.version>2.5.5</asciidoctorj.version>
                <asm.version>9.3</asm.version> <!-- keep in sync with 
org.eclipse.persistence:org.eclipse.persistence.asm -->
                <approvaltests.version>18.0.0</approvaltests.version>
 
diff --git a/examples/demo/domain-tests/pom.xml 
b/examples/demo/domain-tests/pom.xml
new file mode 100644
index 0000000000..62c3af4f22
--- /dev/null
+++ b/examples/demo/domain-tests/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+       license agreements. See the NOTICE file distributed with this work for 
additional
+       information regarding copyright ownership. The ASF licenses this file to
+       you under the Apache License, Version 2.0 (the "License"); you may not 
use
+       this file except in compliance with the License. You may obtain a copy 
of
+       the License at http://www.apache.org/licenses/LICENSE-2.0 Unless 
required
+       by applicable law or agreed to in writing, software distributed under 
the
+       License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS
+       OF ANY KIND, either express or implied. See the License for the specific
+       language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+
+       <parent>
+               <groupId>org.apache.isis.examples.apps</groupId>
+               <artifactId>demo-parent</artifactId>
+               <version>2.0.0-SNAPSHOT</version>
+       </parent>
+
+       <artifactId>demo-domain-tests</artifactId>
+       <name>Demo - Domain Tests</name>
+       <description>Introduced to allow for JUnit integration tests with the 
demo-domain.</description>
+
+       <properties>
+       </properties>
+
+    <build>
+        <resources>
+            <resource>
+                <filtering>true</filtering>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>application.yml</include>
+                </includes>
+            </resource>
+            <resource>
+                <filtering>false</filtering>
+                <directory>src/main/resources</directory>
+            </resource>
+            <resource>
+                <filtering>false</filtering>
+                <directory>src/main/java</directory>
+                <includes>
+                    <!-- we include all .java too, so that we can reference it 
from the descriptions -->
+                    <include>**</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+
+       <dependencies>
+
+               <!-- DEMO DOMAIN -->
+
+               <dependency>
+                       <groupId>org.apache.isis.examples.apps</groupId>
+                       <artifactId>demo-domain</artifactId>
+               </dependency>
+               
+               <dependency>
+                       <groupId>org.apache.isis.examples.apps</groupId>
+                       <artifactId>demo-web</artifactId>
+               </dependency>
+
+               <!-- DEMO DOMAIN ADDITIONAL DEPENDENCIES -->
+
+               <!-- TODO: this should be pulled in by eg. --> 
+               <dependency>
+                       <groupId>org.apache.isis.valuetypes</groupId>
+                       <artifactId>isis-valuetypes-asciidoc-ui</artifactId>
+                       <version>2.0.0-SNAPSHOT</version>
+               </dependency> 
+
+               <!-- provides DomainObjectTesterFactory -->
+               <dependency>
+                       <groupId>org.apache.isis.regressiontests</groupId>
+                       <artifactId>isis-regressiontests-stable</artifactId>
+                       <version>2.0.0-SNAPSHOT</version>
+               </dependency>
+               
+       </dependencies>
+
+</project>
diff --git 
a/examples/demo/domain-tests/src/main/java/demoapp/dom/domain/tests/conf/Configuration_usingJpa.java
 
b/examples/demo/domain-tests/src/main/java/demoapp/dom/domain/tests/conf/Configuration_usingJpa.java
new file mode 100644
index 0000000000..ef51df013e
--- /dev/null
+++ 
b/examples/demo/domain-tests/src/main/java/demoapp/dom/domain/tests/conf/Configuration_usingJpa.java
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package demoapp.dom.domain.tests.conf;
+
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.Profile;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
+
+import org.apache.isis.core.config.presets.IsisPresets;
+import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices;
+import 
org.apache.isis.persistence.jpa.eclipselink.IsisModulePersistenceJpaEclipselink;
+import org.apache.isis.testing.fixtures.applib.IsisModuleTestingFixturesApplib;
+
+import demoapp.web.DemoAppManifestJpa;
+
+@SpringBootConfiguration
+@EnableAutoConfiguration
+@Import({
+    IsisModuleCoreRuntimeServices.class,
+    IsisModulePersistenceJpaEclipselink.class,
+    IsisModuleTestingFixturesApplib.class,
+
+    // demo domain
+    DemoAppManifestJpa.class,
+    //DemoModuleJpa.class,
+})
+@PropertySources({
+    @PropertySource(IsisPresets.NoTranslations),
+    @PropertySource(IsisPresets.H2InMemory_withUniqueSchema),
+})
+@Profile("demo-jpa")
+public class Configuration_usingJpa {
+
+}
diff --git 
a/examples/demo/domain-tests/src/test/java/demoapp/dom/domain/tests/DomainIntrospectionTestJpa.java
 
b/examples/demo/domain-tests/src/test/java/demoapp/dom/domain/tests/DomainIntrospectionTestJpa.java
new file mode 100644
index 0000000000..1ca7992a97
--- /dev/null
+++ 
b/examples/demo/domain-tests/src/test/java/demoapp/dom/domain/tests/DomainIntrospectionTestJpa.java
@@ -0,0 +1,90 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package demoapp.dom.domain.tests;
+
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.TestPropertySource;
+
+import org.apache.isis.applib.services.registry.ServiceRegistry;
+import org.apache.isis.core.config.presets.IsisPresets;
+import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+import 
org.apache.isis.testing.integtestsupport.applib.validate.DomainModelValidator;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import demoapp.dom.domain.tests.conf.Configuration_usingJpa;
+import lombok.val;
+
+@SpringBootTest(
+        classes = {
+                Configuration_usingJpa.class,
+        },
+        properties = {
+                "isis.core.meta-model.introspector.mode=FULL",
+                
"isis.core.config.configuration-property-visibility-policy=ALWAYS_SHOW",
+                "isis.applib.annotation.domain-object.editing=TRUE",
+                "isis.core.meta-model.validator.explicit-object-type=FALSE", 
// does not override any of the imports
+                "logging.level.DependentArgUtils=DEBUG"
+        })
+@TestPropertySource({
+    IsisPresets.SilenceMetaModel,
+    IsisPresets.SilenceProgrammingModel
+})
+@ActiveProfiles(profiles = "demo-jpa")
+class DomainIntrospectionTestJpa {
+
+    //@Inject private MetaModelService metaModelService;
+    //@Inject private JaxbService jaxbService;
+    @Inject private ServiceRegistry serviceRegistry;
+    @Inject private SpecificationLoader specificationLoader;
+    //@Inject private TitleService titleService;
+    //@Inject private IsisConfiguration isisConfig;
+    //@Inject private DomainObjectTesterFactory testerFactory;
+
+    @Test
+    void domain_shouldPassValidation() {
+
+        //debug();
+        assertFalse(specificationLoader.snapshotSpecifications().isEmpty());
+
+        val validateDomainModel = new DomainModelValidator(serviceRegistry);
+
+        // guard against left overs from shared context
+        val validationFailures = validateDomainModel.getFailures().stream()
+                .filter(f->!f.getOrigin().getClassName().contains("bad"))
+                .collect(Collectors.toSet());
+
+        if(!validationFailures.isEmpty()) {
+
+            fail(String.format("%d problems found:\n%s",
+                    validationFailures.size(),
+                    validationFailures.stream()
+                    .map(validationFailure->validationFailure.getMessage())
+                    .collect(Collectors.joining("\n"))));
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 91d6efc083..770e9c9e10 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -39,7 +39,6 @@
 
                
<jar-plugin.automaticModuleName>org.apache.isis.tooling</jar-plugin.automaticModuleName>
                
<git-plugin.propertiesDir>org/apache/isis/tooling</git-plugin.propertiesDir>
-               <asciidoctorj.version>2.5.5</asciidoctorj.version>
                <gradle-tooling.version>7.1.1</gradle-tooling.version>
                <maven-model-builder.version>3.8.6</maven-model-builder.version>
                <picocli.version>4.6.3</picocli.version>
diff --git a/valuetypes/asciidoc/pom.xml b/valuetypes/asciidoc/pom.xml
index 4991840598..c2fd89b3bd 100644
--- a/valuetypes/asciidoc/pom.xml
+++ b/valuetypes/asciidoc/pom.xml
@@ -29,7 +29,6 @@
        <packaging>pom</packaging>
 
        <properties>
-               <asciidoctorj.version>2.5.5</asciidoctorj.version>
        </properties>
 
        <modules>

Reply via email to