Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Spring configuration class for integration tests.
- */
- @Configuration
- @EnableAutoConfiguration
- @ComponentScan
- @EnableJpaAuditing
- public class PopcornCoreTestApplication {}
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = PopcornCoreTestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
- @TestExecutionListeners(
- {
- DependencyInjectionTestExecutionListener.class,
- DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class,
- TransactionDbUnitTestExecutionListener.class
- }
- )
- @ActiveProfiles(
- {
- "db-h2",
- "mail"
- }
- )
- public abstract class DBUnitTestBase {}
- @Category(IntegrationTest.class)
- @DatabaseSetup("MoviePersistenceServiceImplIntegrationTests/init.xml")
- @DatabaseTearDown("cleanup.xml")
- public class MoviePersistenceServiceImplIntegrationTests extends DBUnitTestBase {
- @Autowired
- private MoviePersistenceService moviePersistenceService;
- @Autowired
- private MovieSearchService movieSearchService;
- @PersistenceContext
- private EntityManager entityManager;
- /**
- * Test the createOtherTitle method.
- *
- * @throws ResourceException For any problem
- */
- @Test
- public void canCreateOtherTitle() throws ResourceException {
- final OtherTitle otherTitle = new OtherTitle.Builder(
- UUID.randomUUID().toString(),
- CountryType.USA
- ).build();
- final List<MovieOtherTitleEntity> resultList =
- this.entityManager.createQuery(
- "select e from " + MovieOtherTitleEntity.class.getSimpleName() + " e where e.status = :status",
- MovieOtherTitleEntity.class
- ).setParameter("status", DataStatus.WAITING).getResultList();
- Assert.assertEquals(0, resultList.size());
- this.moviePersistenceService.createOtherTitle(
- otherTitle,
- this.movieRepository.findByIdAndStatus(MOV_1_ID, DataStatus.ACCEPTED)
- .orElseThrow(IllegalArgumentException::new)
- );
- Assert.assertEquals(1, resultList.size());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement