-
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 #33110 from matejvasek/funq-dispatch
Enable function with same name for Funqy
- Loading branch information
Showing
8 changed files
with
169 additions
and
10 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...nqy/funqy-knative-events/deployment/src/test/java/io/quarkus/funqy/test/NameConflict.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,17 @@ | ||
package io.quarkus.funqy.test; | ||
|
||
import io.quarkus.funqy.Funq; | ||
|
||
public class NameConflict { | ||
|
||
@Funq | ||
public String function(String s) { | ||
return s.toUpperCase(); | ||
} | ||
|
||
@Funq | ||
public int function(int i) { | ||
return i * 2; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...funqy-knative-events/deployment/src/test/java/io/quarkus/funqy/test/NameConflictTest.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,33 @@ | ||
package io.quarkus.funqy.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.io.*; | ||
import java.util.logging.Level; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NameConflictTest { | ||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(jar -> jar.addClass(NameConflict.class)) | ||
.setLogRecordPredicate(logRecord -> logRecord.getLevel().intValue() >= Level.WARNING.intValue() && | ||
logRecord.getLoggerName().startsWith("io.quarkus.funqy")) | ||
.assertLogRecords(logRecords -> { | ||
boolean match = logRecords | ||
.stream() | ||
.anyMatch(logRecord -> logRecord.getMessage().contains("Name conflict")); | ||
if (!match) { | ||
fail("Log does not contain message about name conflict."); | ||
} | ||
}); | ||
|
||
@Test | ||
void test() { | ||
assertTrue(true); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...unqy/funqy-knative-events/deployment/src/test/java/io/quarkus/funqy/test/Overloading.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,17 @@ | ||
package io.quarkus.funqy.test; | ||
|
||
import io.quarkus.funqy.Funq; | ||
|
||
public class Overloading { | ||
|
||
@Funq("intfun") | ||
public int function(int i) { | ||
return i * 2; | ||
} | ||
|
||
@Funq("strfun") | ||
public String function(String s) { | ||
return s.toUpperCase(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
.../funqy-knative-events/deployment/src/test/java/io/quarkus/funqy/test/OverloadingTest.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,31 @@ | ||
package io.quarkus.funqy.test; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class OverloadingTest { | ||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Overloading.class)); | ||
|
||
@Test | ||
public void testMapping() { | ||
RestAssured.given().contentType("application/json") | ||
.body("\"a\"") | ||
.post("/strfun") | ||
.then().statusCode(200) | ||
.body(equalTo("\"A\"")); | ||
|
||
RestAssured.given().contentType("application/json") | ||
.body("10") | ||
.post("/intfun") | ||
.then().statusCode(200) | ||
.body(equalTo("20")); | ||
} | ||
} |
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
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