title: No results while using save of JPA in unit testing
body: <p>I am having a weird situation while doing some unit testing. When I am using save method of JPA it's not returning anything, neither it's throwing any error.</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @DataJpaTest
  @SpringBootTest
  @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
  public class MerchantRepoTest {
  
      private Long personID = 12333333l;
      @Mock
      private ABC abcRepo;
      @Mock
      private Person personRepo;
      @Autowired
      private TestEntityManager testEntityManager;
      private Gson gson = new Gson();
  
      @Test
      public void testPerson() {
  
          System.out.println("Starting................");
          Person person = new Person();
  
          TxnLimit txnLimit = new TxnLimit();
          txnLimit.setType("MONTHY");
          txnLimit.setValue(1000000000l);
          List&lt;TxnLimit&gt; txnLimits = new ArrayList&lt;&gt;();
          txnLimits.add(txnLimit);
          person.setTxnLimits(gson.toJson(txnLimits));
  
          ABC abc = new ABC();
          abc.setPersonId(personId);
          Metadata metaData = new Metadata();
          metaData.setDescription("DESC");
          metaData.setName("MUKUL");
          person.setMetadata(metaData);
          person.setId(personId);
          person.setType("Food");
          person.accountToken("hgh-hhjds-hdbhj");
  
          try {
              Person per1=  personRepo.save(merchant);
              ABC savedA = abcRepo.save(abc);
              Thread.sleep(1000);
              System.out.println("SAVED @@@@@@@@@@@@@@@@@@");
              System.out.println("ID1 + " + per1.getId());
              System.out.println("###############");
          }  catch (Throwable t) {
              t.printStackTrace();
          }
  
          Person found = personRepo.findOne(personID);
          System.out.println("FOUND..." + found);
          String name = found.getMetadata().getName();
          Assert.assertEquals(name, "MUKUL");
      }
  }
  </code></pre>
  
  <p>My test case is failing and I am getting NullPointerException at             <code>String name = found.getMetadata().getName();</code>, As I am getting found as null. I have tried to print middle steps and out of my surprise, something is wrong, while saving the details.</p>
  
  <p>I am able to print                 <code>System.out.println("SAVED @@@@@@@@@@@@@@@@@@");</code> line but after that line I am not getting next two lines. i am also not getting any exception in <strong>catch</strong> block. The next message I am getting on my screen is roll-back of transaction.</p>
  
  <pre><code>2018-10-31 18:17:14.759 [] [] [Test worker] INFO  t.context.transaction.TransactionContext:106 - Began transaction (1) for test context [DefaultTestContext@780636f3 testClass = MerchantRepoTest, testInstance = com.paytm.paylite.merchant.repo.MerchantRepoTest@735dc46, testMethod = testOK1@MerchantRepoTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@8006101 testClass = MerchantRepoTest, locations = '{}', classes = '{class com.paytm.paylite.merchant.MerchantServiceApp}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@503407f6, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@73b73c3d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6bc7795, [ImportsContextCustomizer@4342f78e key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.SpringBootTestContextCustomizer@67aa907e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@50394650, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@63f5badc, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@40ec0c87]; rollback [true]
  Starting................
  ...
  ...
  ..
  SAVED @@@@@@@@@@@@@@@@@@
  FOUND...null
  2018-10-31 18:17:15.829 [] [] [Test worker] INFO  t.context.transaction.TransactionContext:140 - Rolled back transaction for test: [DefaultTestContext@780636f3 testClass = MerchantRepoTest, testInstance = com.paytm.paylite.merchant.repo.MerchantRepoTest@735dc46, testMethod = testOK1@MerchantRepoTest, testException = java.lang.NullPointerException, mergedContextConfiguration = [WebMergedContextConfiguration@8006101 testClass = MerchantRepoTest, locations = '{}', classes = '{class com.paytm.paylite.merchant.MerchantServiceApp}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@503407f6, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@73b73c3d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6bc7795, [ImportsContextCustomizer@4342f78e key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.SpringBootTestContextCustomizer@67aa907e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@50394650, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@63f5badc, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]
  </code></pre>
  
  <p>I am unable to figure out what may be the reason behind this?</p>