forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute: fix regression for optimized generated value resolvers
- fix regression introduced in quarkusio#33984 - if there are multiple type-safe templates with the same parameter declaration then _no_ or _incomplete_ value resolver may be generated (cherry picked from commit ba3f62a)
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
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
61 changes: 61 additions & 0 deletions
61
...c/test/java/io/quarkus/qute/deployment/generatedresolvers/ImplicitValueResolversTest.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,61 @@ | ||
package io.quarkus.qute.deployment.generatedresolvers; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.CheckedTemplate; | ||
import io.quarkus.qute.Engine; | ||
import io.quarkus.qute.TemplateInstance; | ||
import io.quarkus.qute.ValueResolver; | ||
import io.quarkus.qute.generator.ValueResolverGenerator; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ImplicitValueResolversTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addAsResource(new StringAsset("{name.toUpperCase}"), "templates/hello.html") | ||
.addAsResource(new StringAsset("{name}"), "templates/bye.html") | ||
.addAsResource(new StringAsset("{name}"), "templates/zero.html")); | ||
|
||
@CheckedTemplate(basePath = "") | ||
record hello(String name) implements TemplateInstance { | ||
}; | ||
|
||
@CheckedTemplate(basePath = "") | ||
record bye(String name) implements TemplateInstance { | ||
}; | ||
|
||
@CheckedTemplate(basePath = "") | ||
record zero(String name) implements TemplateInstance { | ||
}; | ||
|
||
@Inject | ||
Engine engine; | ||
|
||
@Test | ||
public void testImplicitResolvers() { | ||
assertEquals("FOO", new hello("Foo").render()); | ||
assertEquals("Bar", new bye("Bar").render()); | ||
assertEquals("Baz", new zero("Baz").render()); | ||
List<ValueResolver> resolvers = engine.getValueResolvers(); | ||
ValueResolver stringResolver = null; | ||
for (ValueResolver valueResolver : resolvers) { | ||
if (valueResolver.getClass().getName().endsWith(ValueResolverGenerator.SUFFIX) | ||
&& valueResolver.getClass().getName().contains("String")) { | ||
stringResolver = valueResolver; | ||
} | ||
} | ||
assertNotNull(stringResolver); | ||
} | ||
|
||
} |