You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/11/22 06:44:44 UTC
[isis] branch master updated: ISIS-2877: introduces ValueTypeSemantics tests (stubs)
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 f8a47aa ISIS-2877: introduces ValueTypeSemantics tests (stubs)
f8a47aa is described below
commit f8a47aa351f9e331819ca0b771161220ffaa1c77
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Nov 22 07:44:38 2021 +0100
ISIS-2877: introduces ValueTypeSemantics tests (stubs)
---
regressiontests/pom.xml | 1 +
regressiontests/stable-value/log4j2-test.xml | 78 +++++++++++++++++++
regressiontests/stable-value/pom.xml | 36 +++++++++
.../isis/testdomain/value/ValueSemanticsTest.java | 90 ++++++++++++++++++++++
.../valuetypes/Configuration_usingValueTypes.java | 36 +++++++++
.../model/valuetypes/ValueTypeExample.java | 50 ++++++++++++
.../model/valuetypes/ValueTypeExampleService.java | 37 +++++++++
.../model/valuetypes/ValueTypeExampleUuid.java | 39 ++++++++++
8 files changed, 367 insertions(+)
diff --git a/regressiontests/pom.xml b/regressiontests/pom.xml
index fa8c1cf..29471a2 100644
--- a/regressiontests/pom.xml
+++ b/regressiontests/pom.xml
@@ -309,6 +309,7 @@
<!-- <module>stable-publishing-jdo</module> code is still incubating -->
<module>stable-publishing-jpa</module>
<module>stable-rest</module>
+ <module>stable-value</module>
<module>stable-viewers</module>
<!-- <module>incubating</module> -->
</modules>
diff --git a/regressiontests/stable-value/log4j2-test.xml b/regressiontests/stable-value/log4j2-test.xml
new file mode 100644
index 0000000..0ed7986
--- /dev/null
+++ b/regressiontests/stable-value/log4j2-test.xml
@@ -0,0 +1,78 @@
+<?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.
+-->
+<Configuration status="WARN">
+ <Properties>
+ <Property name="PID">????</Property>
+ <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
+ <Property name="LOG_LEVEL_PATTERN">%5p</Property>
+ <Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
+ <Property name="CONSOLE_LOG_PATTERN">%clr{%d{${LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+ <Property name="FILE_LOG_PATTERN">%d{${LOG_DATEFORMAT_PATTERN}} ${LOG_LEVEL_PATTERN} ${sys:PID} --- [%t] %-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+ </Properties>
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT" follow="true">
+ <PatternLayout pattern="${sys:CONSOLE_LOG_PATTERN}" />
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.catalina.startup.DigesterFactory" level="error" />
+ <Logger name="org.apache.catalina.util.LifecycleBase" level="error" />
+ <Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" />
+ <logger name="org.apache.sshd.common.util.SecurityUtils" level="warn"/>
+ <Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" />
+ <Logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="error" />
+ <Logger name="org.hibernate.validator.internal.util.Version" level="warn" />
+ <logger name="org.springframework.boot.actuate.endpoint.jmx" level="warn"/>
+
+ <logger name="org.apache.directory" level="warn"/>
+ <logger name="org.apache.directory.api.ldap.model.entry.Value" level="off"/>
+
+ <logger name="DataNucleus.Persistence" level="info"/>
+ <logger name="DataNucleus.Transaction" level="info"/>
+ <logger name="DataNucleus.Datastore.Schema" level="info"/>
+ <logger name="DataNucleus.Datastore.Native" level="info"/>
+
+ <Root level="info">
+ <AppenderRef ref="Console" />
+ </Root>
+ </Loggers>
+</Configuration>
+
+<!-- # DataNucleus Logging Categories -->
+<!-- DataNucleus.Persistence - All messages relating to the persistence process -->
+<!-- DataNucleus.Transaction - All messages relating to transactions -->
+<!-- DataNucleus.Connection - All messages relating to Connections. -->
+<!-- DataNucleus.Query - All messages relating to queries -->
+<!-- DataNucleus.Cache - All messages relating to the DataNucleus Cache -->
+<!-- DataNucleus.MetaData - All messages relating to MetaData -->
+<!-- DataNucleus.Datastore - All general datastore messages -->
+<!-- DataNucleus.Datastore.Schema - All schema related datastore log messages -->
+<!-- DataNucleus.Datastore.Persist - All datastore persistence messages -->
+<!-- DataNucleus.Datastore.Retrieve - All datastore retrieval messages -->
+<!-- DataNucleus.Datastore.Native - Log of all 'native' statements sent to the datastore -->
+<!-- DataNucleus.General - All general operational messages -->
+<!-- DataNucleus.Lifecycle - All messages relating to object lifecycle changes -->
+<!-- DataNucleus.ValueGeneration - All messages relating to value generation -->
+<!-- DataNucleus.Enhancer - All messages from the DataNucleus Enhancer. -->
+<!-- DataNucleus.SchemaTool - All messages from DataNucleus SchemaTool -->
+<!-- DataNucleus.JDO - All messages general to JDO -->
+<!-- DataNucleus.JPA - All messages general to JPA -->
+<!-- DataNucleus.JCA - All messages relating to Connector JCA. -->
+<!-- DataNucleus.IDE - Messages from the DataNucleus IDE. -->
\ No newline at end of file
diff --git a/regressiontests/stable-value/pom.xml b/regressiontests/stable-value/pom.xml
new file mode 100644
index 0000000..d23802a
--- /dev/null
+++ b/regressiontests/stable-value/pom.xml
@@ -0,0 +1,36 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.isis.regressiontests</groupId>
+ <artifactId>isis-regressiontests</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>isis-regressiontests-stable-value</artifactId>
+
+ <name>Apache Isis - Regression Tests (stable) - Value Types</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.isis.regressiontests</groupId>
+ <artifactId>isis-regressiontests-stable</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
new file mode 100644
index 0000000..d7849ae
--- /dev/null
+++ b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.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 org.apache.isis.testdomain.value;
+
+import java.util.stream.Stream;
+
+import javax.inject.Inject;
+
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.apache.isis.core.config.presets.IsisPresets;
+import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+import org.apache.isis.testdomain.conf.Configuration_headless;
+import org.apache.isis.testdomain.model.valuetypes.Configuration_usingValueTypes;
+import org.apache.isis.testdomain.model.valuetypes.ValueTypeExample;
+import org.apache.isis.testdomain.model.valuetypes.ValueTypeExampleService;
+
+import lombok.val;
+
+@SpringBootTest(
+ classes = {
+ Configuration_headless.class,
+ Configuration_usingValueTypes.class,
+ },
+ properties = {
+ "isis.core.meta-model.introspector.mode=FULL"
+ })
+@TestPropertySource({
+ IsisPresets.SilenceMetaModel,
+ IsisPresets.SilenceProgrammingModel
+})
+@TestInstance(Lifecycle.PER_CLASS)
+class ValueSemanticsTest {
+
+ //@Inject ValueSemanticsRegistry valueSemanticsRegistry;
+ @Inject ValueTypeExampleService valueTypeExampleProvider;
+ @Inject SpecificationLoader specLoader;
+
+ @ParameterizedTest(name = "{index} {0}")
+ @MethodSource("provideValueTypeExamples")
+ void valueTypes(
+ final String name,
+ final ValueTypeExample<?> example) {
+ assertNotNull(example);
+ System.err.printf("%s%n", example);
+
+ val exampleSpec = specLoader.specForTypeElseFail(example.getClass());
+
+ val act = exampleSpec.getActionElseFail("updateValue");
+ val prop = exampleSpec.getPropertyElseFail("value");
+ val coll = exampleSpec.getCollectionElseFail("values");
+
+ assertNotNull(act);
+ assertNotNull(prop);
+ assertNotNull(coll);
+
+ }
+
+ // -- DEPENDENCIES
+
+ Stream<Arguments> provideValueTypeExamples() {
+ return valueTypeExampleProvider.streamExamples()
+ .map(x->Arguments.of(x.getValueType().getSimpleName(), x));
+ }
+
+}
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/Configuration_usingValueTypes.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/Configuration_usingValueTypes.java
new file mode 100644
index 0000000..0693539
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/Configuration_usingValueTypes.java
@@ -0,0 +1,36 @@
+/*
+ * 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 org.apache.isis.testdomain.model.valuetypes;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Configuration
+@Import({
+
+})
+@ComponentScan(
+ basePackageClasses= {
+ Configuration_usingValueTypes.class
+ })
+public class Configuration_usingValueTypes {
+
+
+}
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExample.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExample.java
new file mode 100644
index 0000000..f6717ab
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExample.java
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.isis.testdomain.model.valuetypes;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Action;
+import org.apache.isis.applib.annotation.Collection;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.Property;
+
+public abstract class ValueTypeExample<T> {
+
+ @Property
+ public abstract T getValue();
+ public abstract void setValue(T value);
+
+ @Action
+ public final void updateValue(final T value) {
+ setValue(value);
+ }
+
+ @Collection
+ public final List<T> getValues() {
+ return List.of(getValue(), getValue());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Programmatic
+ public final Class<T> getValueType() {
+ return (Class<T>) getValue().getClass();
+ }
+
+}
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleService.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleService.java
new file mode 100644
index 0000000..85e3b61
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleService.java
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.isis.testdomain.model.valuetypes;
+
+import java.util.List;
+import java.util.stream.Stream;
+
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ValueTypeExampleService {
+
+ @Inject List<ValueTypeExample<?>> examples;
+
+ public Stream<ValueTypeExample<?>> streamExamples() {
+ return examples.stream();
+ }
+
+}
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleUuid.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleUuid.java
new file mode 100644
index 0000000..c7dafae
--- /dev/null
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/model/valuetypes/ValueTypeExampleUuid.java
@@ -0,0 +1,39 @@
+/*
+ * 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 org.apache.isis.testdomain.model.valuetypes;
+
+import java.util.UUID;
+
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Property;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@DomainObject(
+ logicalTypeName = "isis.testdomain.valuetypes.ValueTypeExampleUuid",
+ nature = Nature.BEAN)
+public class ValueTypeExampleUuid
+extends ValueTypeExample<UUID> {
+
+ @Property @Getter @Setter
+ private UUID value = UUID.randomUUID();
+
+}
\ No newline at end of file