@QueryValue
@Get(value = "/fruits")
public void stuff(@QueryValue @Format("yyyy-MM-dd") LocalDate from){
...
@EventListener
public void eventListener(ApplicationStartupEvent startupEvent){
...
}
@Context
public String someBean() {
return "";
}
Ele permite que quem usa spring possa migrar facilmente para o micronaut, basicamente ele vai entender as anotações do spring e injeta-las como beans micronaut ao subir
export MICRONAUT_ENVIRONMENTS=prod
@MicronautTest
class MathMockServiceTest {
@Inject
MathService mathService;
@ParameterizedTest
@CsvSource({"2,4", "3,9"})
void testComputeNumToSquare(Integer num, Integer square) {
when(mathService.compute(10))
.then(invocation -> Long.valueOf(Math.round(Math.pow(num, 2))).intValue());
final Integer result = mathService.compute(10);
Assertions.assertEquals(
square,
result
);
verify(mathService).compute(10);
}
@MockBean(MathServiceImpl.class)
MathService mathService() {
return mock(MathService.class);
}
}
@Get("/swaggerui")
public HttpResponse swaggerUi(){
return HttpResponse.redirect(URI.create("/swagger-ui?docExpansion=none"));
}
@Context // make sure bean will be injected
public class JobTrigger {
public JobTrigger(
@Named(TaskExecutors.SCHEDULED) TaskScheduler taskScheduler
) {
taskScheduler.schedule("0 */30 * * * *", () -> System.println("Something!"));
}
}
@Data
@NoArgsConstructor
@ConfigurationProperties(value = "mg.steampowered.api.retry")
public class SteamProps {
private int maxAttempts;
}