diff --git a/cdi/src/test/java/com/baeldung/test/TestInterceptor.java b/cdi/src/test/java/com/baeldung/test/TestInterceptor.java index d1b851c94f..406296529c 100644 --- a/cdi/src/test/java/com/baeldung/test/TestInterceptor.java +++ b/cdi/src/test/java/com/baeldung/test/TestInterceptor.java @@ -1,8 +1,5 @@ package com.baeldung.test; -import com.baeldung.interceptor.Audited; -import com.baeldung.interceptor.AuditedInterceptor; -import com.baeldung.service.SuperService; import org.jboss.weld.environment.se.Weld; import org.jboss.weld.environment.se.WeldContainer; import org.junit.After; @@ -10,24 +7,21 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.InterceptionType; -import javax.enterprise.inject.spi.Interceptor; -import javax.enterprise.util.AnnotationLiteral; - -import static javafx.beans.binding.Bindings.select; +import com.baeldung.interceptor.AuditedInterceptor; +import com.baeldung.service.SuperService; public class TestInterceptor { Weld weld; WeldContainer container; + @Before - public void init(){ + public void init() { weld = new Weld(); container = weld.initialize(); } @After - public void shutdown(){ + public void shutdown() { weld.shutdown(); } diff --git a/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java b/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java index b5aedd4b76..1f3a8d83e3 100644 --- a/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java +++ b/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java @@ -1,25 +1,21 @@ package com.baeldung.test; -import com.baeldung.spring.configuration.AppConfig; -import com.baeldung.spring.service.SpringSuperService; +import static org.hamcrest.CoreMatchers.is; + +import java.util.List; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; -import org.springframework.test.context.support.DirtiesContextTestExecutionListener; -import org.springframework.test.context.transaction.TransactionalTestExecutionListener; -import javax.inject.Inject; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; +import com.baeldung.spring.configuration.AppConfig; +import com.baeldung.spring.service.SpringSuperService; @RunWith(SpringRunner.class) -@ContextConfiguration(classes = {AppConfig.class}) +@ContextConfiguration(classes = { AppConfig.class }) public class TestSpringInterceptor { @Autowired SpringSuperService springSuperService; @@ -28,11 +24,11 @@ public class TestSpringInterceptor { private List accumulator; @Test - public void givenService_whenServiceAndAspectExecuted_thenOk(){ + public void givenService_whenServiceAndAspectExecuted_thenOk() { String code = "123456"; String result = springSuperService.getInfoFromService(code); Assert.assertThat(accumulator.size(), is(2)); - Assert.assertThat(accumulator.get(0),is("Call to getInfoFromService")); - Assert.assertThat(accumulator.get(1),is("Method called successfully: getInfoFromService")); + Assert.assertThat(accumulator.get(0), is("Call to getInfoFromService")); + Assert.assertThat(accumulator.get(1), is("Method called successfully: getInfoFromService")); } }