2017-04-07 23:30:29 +03:00
|
|
|
package org.baeldung;
|
|
|
|
|
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;
|
2017-04-07 23:30:29 +03:00
|
|
|
import org.baeldung.config.H2TestProfileJPAConfig;
|
|
|
|
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.test.context.ActiveProfiles;
|
2017-05-05 07:06:09 +02:00
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
2017-04-07 23:30:29 +03:00
|
|
|
|
2017-05-05 07:06:09 +02:00
|
|
|
@RunWith(SpringRunner.class)
|
2017-04-07 23:30:29 +03:00
|
|
|
@SpringBootTest(classes = { Application.class, H2TestProfileJPAConfig.class })
|
|
|
|
@ActiveProfiles("test")
|
|
|
|
public class SpringBootProfileIntegrationTest {
|
|
|
|
@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());
|
|
|
|
}
|
|
|
|
}
|