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/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new d3151d0b42 CAUSEWAY-2297: reinstate prompt style facet tests
d3151d0b42 is described below

commit d3151d0b4216ce3a26d0eb270ead56c89d425756
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Mon Jul 29 09:48:33 2024 +0200

    CAUSEWAY-2297: reinstate prompt style facet tests
---
 ...PromptStyleFacetFromPropertyAnnotationTest.java | 155 +++++++++++++++++++
 ...romptStyleFacetFromPropertyAnnotation_Test.java | 167 ---------------------
 2 files changed, 155 insertions(+), 167 deletions(-)

diff --git 
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotationTest.java
 
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotationTest.java
new file mode 100644
index 0000000000..c94195f65f
--- /dev/null
+++ 
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotationTest.java
@@ -0,0 +1,155 @@
+/*
+ *  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.causeway.core.metamodel.facets.properties.promptstyle;
+
+import java.util.Optional;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.causeway.applib.annotation.PromptStyle;
+import org.apache.causeway.applib.annotation.PropertyLayout;
+import org.apache.causeway.core.config.CausewayConfiguration;
+import org.apache.causeway.core.metamodel.facetapi.FacetHolder;
+import 
org.apache.causeway.core.metamodel.facets.object.promptStyle.PromptStyleFacet;
+import 
org.apache.causeway.core.metamodel.facets.object.promptStyle.PromptStyleFacetAsConfigured;
+import 
org.apache.causeway.core.metamodel.facets.properties.propertylayout.PromptStyleFacetForPropertyLayoutAnnotation;
+
+class PromptStyleFacetFromPropertyAnnotationTest {
+
+    CausewayConfiguration stubConfiguration = 
CausewayConfiguration.builder().build();
+
+    FacetHolder mockFacetHolder;
+    PropertyLayout mockPropertyLayout;
+
+    @BeforeEach
+    void setUp() throws Exception {
+        mockFacetHolder = Mockito.mock(FacetHolder.class);
+        mockPropertyLayout = Mockito.mock(PropertyLayout.class);
+    }
+
+    @Test
+    void when_annotated_with_dialog() throws Exception {
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.DIALOG);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet, 
is(anInstanceOf(PromptStyleFacetForPropertyLayoutAnnotation.class)));
+        assertThat(facet.value(), is(PromptStyle.DIALOG));
+    }
+
+    @Test
+    void when_annotated_with_inline() throws Exception {
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.INLINE);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet, 
is(anInstanceOf(PromptStyleFacetForPropertyLayoutAnnotation.class)));
+        assertThat(facet.value(), is(PromptStyle.INLINE));
+    }
+
+    @Test
+    void when_annotated_with_as_configured() throws Exception {
+
+        
stubConfiguration.getViewer().getWicket().setPromptStyle(PromptStyle.INLINE);
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.AS_CONFIGURED);
+        
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
+        .thenReturn(false);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet, 
is(anInstanceOf(PromptStyleFacetAsConfigured.class)));
+        assertThat(facet.value(), is(PromptStyle.INLINE));
+    }
+
+    @Test
+    void when_annotated_with_as_configured_but_already_has_doop_facet() throws 
Exception {
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.AS_CONFIGURED);
+        
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
+        .thenReturn(true);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet, is(nullValue()));
+    }
+
+    @Test
+    void when_not_annotated() throws Exception {
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.NOT_SPECIFIED);
+        
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
+        .thenReturn(false);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet.value(), is(PromptStyle.INLINE));
+        assertThat(facet, 
is(anInstanceOf(PromptStyleFacetAsConfigured.class)));
+    }
+
+    @Test
+    void when_not_annotated_but_already_has_doop_facet() throws Exception {
+
+        
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.NOT_SPECIFIED);
+        
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
+        .thenReturn(true);
+
+        PromptStyleFacet facet = PromptStyleFacetForPropertyLayoutAnnotation
+                .create(Optional.of(mockPropertyLayout), stubConfiguration, 
mockFacetHolder)
+                .orElse(null);
+
+        assertThat(facet, is(nullValue()));
+    }
+
+    static <T> Matcher<? super T> anInstanceOf(final Class<T> expected) {
+        return new TypeSafeMatcher<T>() {
+            @Override
+            public boolean matchesSafely(final T actual) {
+                return expected.isAssignableFrom(actual.getClass());
+            }
+
+            @Override
+            public void describeTo(final Description description) {
+                description.appendText("an instance of 
").appendValue(expected);
+            }
+        };
+    }
+
+}
diff --git 
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotation_Test.java
 
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotation_Test.java
deleted file mode 100644
index 40b93e774e..0000000000
--- 
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/properties/promptstyle/PromptStyleFacetFromPropertyAnnotation_Test.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *  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.causeway.core.metamodel.facets.properties.promptstyle;
-
-import java.util.Optional;
-
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import org.apache.causeway.applib.annotation.PromptStyle;
-import org.apache.causeway.applib.annotation.PropertyLayout;
-import org.apache.causeway.core.config.CausewayConfiguration;
-import org.apache.causeway.core.metamodel.facetapi.FacetHolder;
-import 
org.apache.causeway.core.metamodel.facets.object.promptStyle.PromptStyleFacet;
-import 
org.apache.causeway.core.metamodel.facets.object.promptStyle.PromptStyleFacetAsConfigured;
-import 
org.apache.causeway.core.metamodel.facets.properties.propertylayout.PromptStyleFacetForPropertyLayoutAnnotation;
-
-public class PromptStyleFacetFromPropertyAnnotation_Test {
-
-    CausewayConfiguration stubConfiguration = 
CausewayConfiguration.builder().build();
-
-    FacetHolder mockFacetHolder;
-    PropertyLayout mockPropertyLayout;
-
-    @BeforeEach
-    public void setUp() throws Exception {
-        mockFacetHolder = Mockito.mock(FacetHolder.class);
-        mockPropertyLayout = Mockito.mock(PropertyLayout.class);
-    }
-
-    public static class Create_Test extends 
PromptStyleFacetFromPropertyAnnotation_Test {
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void when_annotated_with_dialog() throws Exception {
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.DIALOG);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet, 
is(anInstanceOf(PromptStyleFacetForPropertyLayoutAnnotation.class)));
-            assertThat(facet.value(), is(PromptStyle.DIALOG));
-        }
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void when_annotated_with_inline() throws Exception {
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.INLINE);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet, 
is(anInstanceOf(PromptStyleFacetForPropertyLayoutAnnotation.class)));
-            assertThat(facet.value(), is(PromptStyle.INLINE));
-        }
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void when_annotated_with_as_configured() throws Exception {
-
-            
stubConfiguration.getViewer().getWicket().setPromptStyle(PromptStyle.INLINE);
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.AS_CONFIGURED);
-            
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
-            .thenReturn(false);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet, 
is(anInstanceOf(PromptStyleFacetAsConfigured.class)));
-            assertThat(facet.value(), is(PromptStyle.INLINE));
-        }
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void 
when_annotated_with_as_configured_but_already_has_doop_facet() throws Exception 
{
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.AS_CONFIGURED);
-            
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
-            .thenReturn(true);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet, is(nullValue()));
-        }
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void when_not_annotated() throws Exception {
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.NOT_SPECIFIED);
-            
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
-            .thenReturn(false);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet.value(), is(PromptStyle.INLINE));
-            assertThat(facet, 
is(anInstanceOf(PromptStyleFacetAsConfigured.class)));
-        }
-
-        @Disabled // not sure how this test ever worked ... in that Mockito 
cannot mock annotations...
-        @Test
-        public void when_not_annotated_but_already_has_doop_facet() throws 
Exception {
-
-            
Mockito.when(mockPropertyLayout.promptStyle()).thenReturn(PromptStyle.NOT_SPECIFIED);
-            
Mockito.when(mockFacetHolder.containsNonFallbackFacet(PromptStyleFacet.class))
-            .thenReturn(true);
-
-            PromptStyleFacet facet = 
PromptStyleFacetForPropertyLayoutAnnotation
-                    .create(Optional.of(mockPropertyLayout), 
stubConfiguration, mockFacetHolder)
-                    .orElse(null);
-
-            assertThat(facet, is(nullValue()));
-        }
-
-    }
-
-    static <T> Matcher<? super T> anInstanceOf(final Class<T> expected) {
-        return new TypeSafeMatcher<T>() {
-            @Override
-            public boolean matchesSafely(final T actual) {
-                return expected.isAssignableFrom(actual.getClass());
-            }
-
-            @Override
-            public void describeTo(final Description description) {
-                description.appendText("an instance of 
").appendValue(expected);
-            }
-        };
-    }
-
-
-}

Reply via email to