Skip to content

Commit

Permalink
Hacking.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Aug 7, 2023
1 parent a204610 commit 17daa8c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.modulith.events.externalize;

import org.springframework.modulith.events.externalize.EventExternalizationConfiguration.RoutingTarget;

/**
* @author Oliver Drotbohm
*/
@FunctionalInterface
public interface ExternalizationCallback<T> {
void send(T infrastructure, RoutingTarget target, Object payload);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.modulith.events.config;

import static org.assertj.core.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

/**
* @author Oliver Drotbohm
*/
public class FooTest {

@Test
void detectsGenericFromBeanDefinitionForLambdaDeclaration() {

try (var context = new AnnotationConfigApplicationContext(MyConfiguration.class)) {

var factory = context.getBeanFactory();
var names = factory.getBeanNamesForType(MyGeneric.class);

var definition = factory.getBeanDefinition(names[0]);
var type = definition.getResolvableType();

assertThat(type.as(MyGeneric.class).getGeneric(0).resolve(Object.class))
.isEqualTo(String.class);
}
}

interface MyGeneric<T> {
void myMethod(T parameter);
}

static class MyConfiguration {

@Bean
MyGeneric<String> foo() {
return (parameter) -> {};
}
}
}

0 comments on commit 17daa8c

Please sign in to comment.