java-tutorials/spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java

29 lines
1.1 KiB
Java
Raw Normal View History

2019-09-27 01:07:06 +05:30
package com.baeldung;
2016-07-16 00:48:09 +03: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;
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)
@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"));
GenericEntity foundEntity = genericEntityRepository.findById(genericEntity.getId()).orElse(null);
assertNotNull(foundEntity);
assertEquals(genericEntity.getValue(), foundEntity.getValue());
2016-07-16 00:48:09 +03:00
}
}