fernando88to commented on code in PR #433:
URL: 
https://github.com/apache/grails-intellij-plugin/pull/433#discussion_r4177424835


##########
plugin/src/test/java/org/apache/grails/intellij/plugin/domain/GormWhereQueryTest.java:
##########
@@ -0,0 +1,241 @@
+/*
+ * 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
+ *
+ *   https://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.grails.intellij.plugin.domain;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.testFramework.UsefulTestCase;
+import org.apache.grails.intellij.lib.testFramework.GrailsTestCase;
+import 
org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+
+/**
+ * Where queries ({@code Person.where { active == true }}) refer to the domain 
properties by their bare names. The
+ * GORM 5+ {@code GormEntity} trait only gives the closure a raw {@code 
DetachedCriteria} delegate, so those names
+ * are resolved by WhereQueryClosureMemberContributor. The GORM the other 
tests run against is older than that,
+ * hence the stubs below.
+ */
+public class GormWhereQueryTest extends GrailsTestCase {
+  private PsiFile myDomainFile;
+
+  /** GormTraitContributor only picks GormEntity when {@code 
org.hibernate.Hibernate} is on the classpath. */
+  @Override
+  protected boolean needHibernate() {
+    return true;
+  }
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+
+    
myFixture.addFileToProject("src/groovy/grails/gorm/DetachedCriteria.groovy", """
+      package grails.gorm
+
+      class DetachedCriteria<T> {
+        DetachedCriteria(Class<T> targetClass) {}
+        DetachedCriteria<T> build(@DelegatesTo(DetachedCriteria) Closure 
callable) { this }
+        DetachedCriteria<T> where(@DelegatesTo(DetachedCriteria) Closure 
callable) { this }
+        DetachedCriteria<T> eq(String propertyName, Object value) { this }
+        List<T> list(Map args) { null }
+      }
+      """);
+
+    // The Groovy the tests run against predates @CompileStatic; the Groovy 
plugin keys off the annotation name only.
+    myFixture.addFileToProject("src/java/groovy/transform/CompileStatic.java", 
"""
+      package groovy.transform;
+
+      public @interface CompileStatic {
+      }
+      """);
+
+    // GormVersion.IS_5 is the lowest version GormTraitContributor injects the 
trait for.
+    myFixture.addFileToProject("src/java/grails/gorm/annotation/Entity.java", 
"""
+      package grails.gorm.annotation;
+
+      public @interface Entity {
+      }
+      """);
+
+    // #CHECK# org.grails.datastore.gorm.GormEntity
+    
myFixture.addFileToProject("src/groovy/org/grails/datastore/gorm/GormEntity.groovy",
 """
+      package org.grails.datastore.gorm
+
+      import grails.gorm.DetachedCriteria
+
+      trait GormEntity<D> {
+        static DetachedCriteria<D> where(@DelegatesTo(DetachedCriteria) 
Closure callable) { null }
+        static DetachedCriteria<D> whereAny(@DelegatesTo(DetachedCriteria) 
Closure callable) { null }
+        static D find(@DelegatesTo(DetachedCriteria) Closure callable) { null }
+        static List<D> findAll(@DelegatesTo(DetachedCriteria) Closure 
callable) { null }
+      }
+      """);
+
+    myDomainFile = addDomain("""
+
+                class Pessoa {

Review Comment:
   Renamed to English identifiers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to