2019-09-27 01:07:06 +05:30
|
|
|
package com.baeldung;
|
2016-07-16 00:48:09 +03:00
|
|
|
|
2017-11-05 18:32:37 +02:00
|
|
|
import org.baeldung.boot.Application;
|
|
|
|
|
import org.baeldung.boot.domain.GenericEntity;
|
|
|
|
|
import org.baeldung.boot.repository.GenericEntityRepository;
|
2016-07-16 00:48:09 +03:00
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2017-02-09 02:51:21 +08:00
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
2017-05-05 16:11:00 +02:00
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
2016-07-16 00:48:09 +03:00
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
|
2017-05-05 16:11:00 +02:00
|
|
|
@RunWith(SpringRunner.class)
|
2017-02-09 02:51:21 +08:00
|
|
|
@SpringBootTest(classes = Application.class)
|
2016-10-20 13:44:16 +02:00
|
|
|
public class SpringBootJPAIntegrationTest {
|
2016-07-16 00:48:09 +03:00
|
|
|
@Autowired
|
|
|
|
|
private GenericEntityRepository genericEntityRepository;
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void givenGenericEntityRepository_whenSaveAndRetreiveEntity_thenOK() {
|
|
|
|
|
GenericEntity genericEntity = genericEntityRepository.save(new GenericEntity("test"));
|
2018-05-06 21:19:41 +03:00
|
|
|
GenericEntity foundEntity = genericEntityRepository.findById(genericEntity.getId()).orElse(null);
|
2017-04-07 23:30:29 +03:00
|
|
|
assertNotNull(foundEntity);
|
|
|
|
|
assertEquals(genericEntity.getValue(), foundEntity.getValue());
|
2016-07-16 00:48:09 +03:00
|
|
|
}
|
|
|
|
|
}
|