BAEL-4068 Add AspectJ DI to module spring-di-2

This commit is contained in:
Nguyen Nam Thai
2020-06-23 17:58:44 +07:00
parent 2c007f42bd
commit 580a3bb920
6 changed files with 175 additions and 0 deletions
@@ -0,0 +1,24 @@
package com.baeldung.di.aspectj;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AspectJConfig.class)
public class PersonUnitTest {
@Test
public void givenUnmanagedObjects_whenInjectingIdService_thenIdValueIsCorrectlySet() {
PersonObject personObject = new PersonObject("Baeldung");
personObject.generateId();
assertEquals(1, personObject.getId());
assertEquals("Baeldung", personObject.getName());
PersonEntity personEntity = new PersonEntity("Baeldung");
assertEquals(2, personEntity.getId());
assertEquals("Baeldung", personEntity.getName());
}
}