Search in sources :

Example 1 with TestInfoLogger

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);
    }
}
Also used : ScanResult(io.github.classgraph.ScanResult) TestInfoLogger(org.vividus.log.TestInfoLogger) ClassGraph(io.github.classgraph.ClassGraph) Test(org.junit.jupiter.api.Test)

Example 2 with TestInfoLogger

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);
    }
}
Also used : TestInfoLogger(org.vividus.log.TestInfoLogger) Vividus(org.vividus.configuration.Vividus) BeanFactory(org.vividus.configuration.BeanFactory) Properties(java.util.Properties)

Example 3 with 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));
    }
}
Also used : TestInfoLogger(org.vividus.log.TestInfoLogger) Vividus(org.vividus.configuration.Vividus) BeanFactory(org.vividus.configuration.BeanFactory) Embedder(org.jbehave.core.embedder.Embedder) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Aggregations

TestInfoLogger (org.vividus.log.TestInfoLogger)3 Properties (java.util.Properties)2 Test (org.junit.jupiter.api.Test)2 BeanFactory (org.vividus.configuration.BeanFactory)2 Vividus (org.vividus.configuration.Vividus)2 ClassGraph (io.github.classgraph.ClassGraph)1 ScanResult (io.github.classgraph.ScanResult)1 Embedder (org.jbehave.core.embedder.Embedder)1