Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: additional sample test for both transactionManager work together. #1848

Merged
merged 9 commits into from
May 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;

Expand All @@ -31,7 +32,7 @@
@ExtendWith(SpringExtension.class)
@EnabledIfSystemProperty(named = "it.multisample", matches = "true")
@TestPropertySource("classpath:application-test.properties")
@EnableAutoConfiguration
@SpringBootTest
class MultipleDataModuleIntegrationTest {

// The Spanner Repo
Expand All @@ -40,6 +41,10 @@ class MultipleDataModuleIntegrationTest {
// The Datastore Repo
@Autowired PersonRepository datastorePersonRepository;

@Autowired TraderService traderService;

@Autowired PersonService personService;

@Test
void testMultipleModulesTogether() {

Expand All @@ -55,4 +60,20 @@ void testMultipleModulesTogether() {
assertThat(this.traderRepository.count()).isEqualTo(1L);
assertThat(this.datastorePersonRepository.count()).isEqualTo(1L);
}

@Test
void testMultipleModulesTogetherWithTransaction() {

this.traderService.deleteAll();
this.personService.deleteAll();

assertThat(this.traderService.count()).isZero();
assertThat(this.personService.count()).isZero();

this.traderService.save(new Trader("id1", "trader", "one"));
this.personService.save(new Person(1L, "person1"));

assertThat(this.traderService.count()).isEqualTo(1L);
assertThat(this.personService.count()).isEqualTo(1L);
}
}