Last active
September 16, 2019 13:33
-
-
Save thanglequoc/04a89c6ee41d7dbe9c063daaf98c9821 to your computer and use it in GitHub Desktop.
Revisions
-
thanglequoc revised this gist
Sep 16, 2019 . 1 changed file with 70 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ package vn.nextlogix.service.util; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import vn.nextlogix.base.H2DatabaseContextConfiguration; import vn.nextlogix.config.OrderStateMachineConfiguration; import vn.nextlogix.repository.search.OrderMainSearchRepository; import vn.nextlogix.service.CompanyProfileService; import vn.nextlogix.service.OrderService; import vn.nextlogix.service.SequenceService; import vn.nextlogix.service.impl.OrderServiceImpl; import vn.nextlogix.service.mapper.*; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import static org.junit.Assert.assertTrue; @SpringBootTest(classes = {OrderService.class, OrderServiceImpl.class}, webEnvironment = SpringBootTest.WebEnvironment.NONE) @RunWith(SpringRunner.class) @ContextConfiguration(classes = { H2DatabaseContextConfiguration.class, OrderStateMachineConfiguration.class}) //@EnableAutoConfiguration @TestPropertySource(locations = "classpath:/application-test.properties") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) // public class OrderServiceIntegrationTestV2 { @PersistenceContext EntityManager entityManager; /* Mock Beans */ @MockBean OrderMainSearchRepository orderMainSearchRepository; @MockBean CompanyProfileService companyProfileService; @MockBean SequenceService sequenceService; /* Mock Mapper Class */ @MockBean OrderMapper orderMapper; @MockBean OrderJourneyMapper orderJourneyMapper; @MockBean OrderMainMapper orderMainMapper; @MockBean PostOfficeMapper postOfficeMapper; @MockBean CompanyMapper companyMapper; @MockBean OrderStatusGroupMapper orderStatusGroupMapper; @MockBean CustomerMapper customerMapper; @MockBean QuotationMapper quotationMapper; @MockBean OrderMediaMapper orderMediaMapper; @MockBean CallHistoryMapper callHistoryMapper; @MockBean OrderProductMapper orderProductMapper; @MockBean ProductMapper productMapper; @MockBean DistrictMapper districtMapper; @Autowired OrderService orderService; @Test @Ignore // @Sql("classpath:/testScript/baseScript/baseDistrict.sql") public void testSaveNewDistrict() { // District district = new District(); assertTrue(true); } } -
thanglequoc created this gist
Sep 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ //@ContextConfiguration(classes = { H2ContextConfiguration.class }) //@EnableAutoConfiguration //@TestPropertySource(locations = "classpath:/application-test.properties") //@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) //@EnableAutoConfiguration //@SpringBootTest(classes = OrderServiceIntegrationTestContext.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) //@RunWith(SpringRunner.class) //@ContextConfiguration(classes = { H2ContextConfiguration.class }) //@EnableAutoConfiguration //@TestPropertySource(locations = "classpath:/application-test.properties") //@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @RunWith(SpringRunner.class) @ComponentScan( includeFilters = { @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { OrderService.class, OrderServiceImpl.class}) }, excludeFilters = { @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { DatabaseConfiguration.class, ActivitiBPMConfiguration.class, ElasticsearchConfiguration.class, ElasticSearchUpdater.class, CacheConfiguration.class, MetricsConfiguration.class}), @ComponentScan.Filter(type = FilterType.REGEX, pattern = {"vn.nextlogix.repository.search.*"})}) public class OrderServiceIntegrationTestContext { }