use of org.vividus.log.TestInfoLogger in project vividus by vividus-framework.
the class VividusTests method shouldDrawBannerAfterLoggerConfigurations.
@Test
void shouldDrawBannerAfterLoggerConfigurations() {
try (MockedStatic<BeanFactory> beanFactory = mockStatic(BeanFactory.class);
MockedStatic<TestInfoLogger> testInfoLogger = mockStatic(TestInfoLogger.class);
MockedConstruction<ClassGraph> classGraph = mockConstruction(ClassGraph.class, (mock, context) -> {
when(mock.acceptPackagesNonRecursive("")).thenReturn(mock);
ScanResult scanResult = Mockito.mock(ScanResult.class);
when(mock.scan()).thenReturn(scanResult);
when(scanResult.getAllResources()).thenReturn(ResourceList.emptyList());
})) {
Vividus.init();
List<ClassGraph> constructedScanners = classGraph.constructed();
assertThat(constructedScanners, hasSize(1));
verify(classGraph.constructed().get(0)).scan();
testInfoLogger.verify(TestInfoLogger::drawBanner);
beanFactory.verify(BeanFactory::open);
}
}
use of org.vividus.log.TestInfoLogger in project vividus by vividus-framework.
the class StoriesRunnerTests method performTest.
private void performTest(FailableConsumer<MockedStatic<TestInfoLogger>, IOException> test) throws IOException {
try (MockedStatic<Vividus> vividus = mockStatic(Vividus.class);
MockedStatic<BeanFactory> beanFactory = mockStatic(BeanFactory.class);
MockedStatic<TestInfoLogger> testInfoLogger = mockStatic(TestInfoLogger.class)) {
beanFactory.when(() -> BeanFactory.getBean(IBatchedPathFinder.class)).thenReturn(batchedPathFinder);
when(batchedPathFinder.getPaths()).thenReturn(BATCH_TO_PATHS);
beanFactory.when(() -> BeanFactory.getBean(BatchedEmbedder.class)).thenReturn(batchedEmbedder);
Properties springProperties = mock(Properties.class);
beanFactory.when(() -> BeanFactory.getBean("properties", Properties.class)).thenReturn(springProperties);
test.accept(testInfoLogger);
}
}
use of org.vividus.log.TestInfoLogger in project vividus by vividus-framework.
the class TestRunnerTests method shouldPerformInitInInstanceInitializationBlock.
@Test
void shouldPerformInitInInstanceInitializationBlock() {
try (MockedStatic<Vividus> vividus = mockStatic(Vividus.class);
MockedStatic<BeanFactory> beanFactory = mockStatic(BeanFactory.class);
MockedStatic<TestInfoLogger> testInfoLogger = mockStatic(TestInfoLogger.class)) {
Properties systemProperties = System.getProperties();
Properties springProperties = mock(Properties.class);
beanFactory.when(() -> BeanFactory.getBean("properties", Properties.class)).thenReturn(springProperties);
Embedder embedder = mock(Embedder.class);
AbstractTestRunner genericRunner = new TestRunner(embedder);
assertEquals(embedder, genericRunner.configuredEmbedder());
vividus.verify(Vividus::init);
testInfoLogger.verify(() -> TestInfoLogger.logPropertiesSecurely(systemProperties));
testInfoLogger.verify(() -> TestInfoLogger.logPropertiesSecurely(springProperties));
}
}
Aggregations