We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
Found a way:
package io.github.jabrena.userbeans; import static org.assertj.core.api.Assertions.assertThat; import io.github.jabrena.support.SupportController; import io.github.jabrena.support.TestApplication; import java.util.Comparator; import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; @SpringBootTest( classes = { TestApplication.class }, properties = { "management.endpoints.web.exposure.include=beans,userbeans" } ) class UserBeansServiceTests { @Autowired private UserBeansService userBeansService; @Autowired private ApplicationContext applicationContext; @Test void shouldRetrieveAllBeans() { //Given var beanCounter = 0; record BeanDocument(String beanName, String beanPackage) {} //When var beanList = userBeansService .getBeansDocuments() .stream() .filter(bd -> bd.dependencies().size() > 0) .flatMap(bd -> bd.dependencies().stream()) .distinct() .map(str -> { try { Class<?> myClass = applicationContext.getBean(str).getClass(); String beanName = (myClass.getSimpleName().length() == 0) ? myClass.getName() : myClass.getSimpleName(); String beanPackage = myClass.getPackageName(); return new BeanDocument(beanName, beanPackage); } catch (NoSuchBeanDefinitionException e) { //Empty on purpose } return new BeanDocument(str, "UNKNOWN"); }) .sorted(Comparator.comparing(BeanDocument::beanName)) .peek(System.out::println) .toList(); //Then assertThat(beanList).hasSizeGreaterThan(beanCounter); } }
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: