Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle void return type from Function clients (#6771)
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 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
47 changes: 47 additions & 0 deletions
47
...-suite/src/test/groovy/io/micronaut/function/web/NullReturningConsumerFunctionSpec.groovy
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,47 @@ | ||
package io.micronaut.function.web | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.context.env.Environment | ||
import io.micronaut.function.FunctionBean | ||
import io.micronaut.function.client.FunctionClient | ||
import io.micronaut.runtime.server.EmbeddedServer | ||
import jakarta.inject.Named | ||
import spock.lang.Issue | ||
import spock.lang.Specification | ||
|
||
import java.util.function.Consumer | ||
|
||
class NullReturningConsumerFunctionSpec extends Specification { | ||
|
||
@Issue("https://github.com/micronaut-projects/micronaut-core/issues/2024") | ||
def "test a client with a void return type"() { | ||
given: | ||
def embeddedServer = ApplicationContext.run(EmbeddedServer) | ||
def client = embeddedServer.applicationContext.getBean(MicronautFunctionProblemsClient) | ||
|
||
when: | ||
client.sendVoid("woo") | ||
|
||
then: | ||
PojoConsumer.LAST_VALUE == "woo" | ||
} | ||
|
||
@FunctionClient | ||
static interface MicronautFunctionProblemsClient { | ||
|
||
@Named("consumer/void") | ||
void sendVoid(String message) | ||
} | ||
|
||
@FunctionBean("consumer/void") | ||
static class PojoConsumer implements Consumer<String> { | ||
|
||
static String LAST_VALUE | ||
|
||
@Override | ||
void accept(String book) { | ||
LAST_VALUE = book | ||
} | ||
} | ||
} |