Yavuz Tas 609c4db4fb BAEL-3828 Where Should @Service Annotation Be Kept? (#10430)
* BAEL-3828 add code samples and tests for the article

* BAEL-3828 fix maven test folder structure and test executions

* BAEL-3828 fix indentation in continuation lines
2021-01-26 09:10:30 -06:00

24 lines
1.1 KiB
Java

package com.baeldung.annotations;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertAll;
public class EmployeeApplicationUnitTest {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withUserConfiguration(EmployeeApplication.class);
@Test
void whenApplicationContextRuns_thenContainAllDefinedBeans() {
contextRunner.run(context -> assertAll(
() -> assertTrue(context.containsBeanDefinition("employee")),
() -> assertTrue(context.containsBeanDefinition("seniorEmployee")),
() -> assertTrue(context.containsBeanDefinition("doctor")),
() -> assertTrue(context.containsBeanDefinition("hospital")),
() -> assertFalse(context.containsBeanDefinition("student")),
() -> assertTrue(context.containsBeanDefinition("teacher"))));
}
}