-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36921 from mkouba/qute-param-declarations-fix
Qute: consider synthetic parameter declarations during validation
- Loading branch information
Showing
10 changed files
with
204 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...nsions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TemplateAnalysisTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.quarkus.qute.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.qute.Expression; | ||
import io.quarkus.qute.ParameterDeclaration; | ||
import io.quarkus.qute.TemplateNode.Origin; | ||
import io.quarkus.qute.Variant; | ||
import io.quarkus.qute.deployment.TemplatesAnalysisBuildItem.TemplateAnalysis; | ||
|
||
public class TemplateAnalysisTest { | ||
|
||
@Test | ||
public void testSortedParamDeclarations() { | ||
TemplateAnalysis analysis = new TemplateAnalysis(null, null, null, List.of(paramDeclaration("foo", -1), | ||
paramDeclaration("bar", -1), paramDeclaration("qux", 10), paramDeclaration("baz", 1)), null, null); | ||
List<ParameterDeclaration> sorted = analysis.getSortedParameterDeclarations(); | ||
assertEquals(4, sorted.size()); | ||
assertEquals("baz", sorted.get(0).getKey()); | ||
assertEquals("qux", sorted.get(1).getKey()); | ||
assertTrue(sorted.get(2).getKey().equals("foo") || sorted.get(2).getKey().equals("bar")); | ||
assertTrue(sorted.get(3).getKey().equals("foo") || sorted.get(3).getKey().equals("bar")); | ||
} | ||
|
||
ParameterDeclaration paramDeclaration(String key, int line) { | ||
return new ParameterDeclaration() { | ||
|
||
@Override | ||
public String getTypeInfo() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Origin getOrigin() { | ||
return new Origin() { | ||
|
||
@Override | ||
public Optional<Variant> getVariant() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public String getTemplateId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getTemplateGeneratedId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getLineCharacterStart() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLineCharacterEnd() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getLine() { | ||
return line; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public String getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public Expression getDefaultValue() { | ||
return null; | ||
} | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.