Skip to content
Snippets Groups Projects
Commit 56e61e5c authored by Alžbeta Hajná's avatar Alžbeta Hajná
Browse files

Merge branch 'seed-clear' into 'develop'

feat(DBManagement): Added function to seed(also during init) and clear data

See merge request !43
parents 4082dc7c 34a4e7ca
No related branches found
No related tags found
2 merge requests!54Merge develop into main,!43feat(DBManagement): Added function to seed(also during init) and clear data
Pipeline #
Showing
with 388 additions and 4 deletions
...@@ -8,6 +8,7 @@ servers: ...@@ -8,6 +8,7 @@ servers:
- url: "http://localhost:8081" - url: "http://localhost:8081"
tags: tags:
- name: ApplicationService - name: ApplicationService
- name: DBManagementService
components: components:
schemas: schemas:
ApplicationStatus: ApplicationStatus:
...@@ -100,6 +101,16 @@ components: ...@@ -100,6 +101,16 @@ components:
properties: properties:
message: message:
type: string type: string
Successful:
description: Successfully processed
content:
application/json:
schema:
type: object
title: Successfully processed
properties:
message:
type: string
paths: paths:
/application: /application:
...@@ -179,5 +190,28 @@ paths: ...@@ -179,5 +190,28 @@ paths:
$ref: '#/components/schemas/ApplicationDto' $ref: '#/components/schemas/ApplicationDto'
"404": "404":
$ref: '#/components/responses/NotFound' $ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
/seed:
post:
tags:
- DBManagementService
summary: Seed DB with data
operationId: seedDB
responses:
"200":
$ref: '#/components/responses/Successful'
default:
$ref: '#/components/responses/Unexpected'
/clear:
post:
tags:
- DBManagementService
summary: Clear DB
operationId: clearDB
responses:
"200":
$ref: '#/components/responses/Successful'
default: default:
$ref: '#/components/responses/Unexpected' $ref: '#/components/responses/Unexpected'
\ No newline at end of file
package cz.muni.pa165.rest;
import cz.muni.pa165.generated.api.DbManagementServiceApiDelegate;
import cz.muni.pa165.generated.model.SuccessfullyProcessed;
import cz.muni.pa165.service.DBManagementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
/**
* @author Michal Badin
*/
@Profile("dev")
@Component
public class DBManagementController implements DbManagementServiceApiDelegate {
private static final Logger log = LoggerFactory.getLogger(DBManagementController.class);
private final DBManagementService dbManagementService;
@Autowired
public DBManagementController(DBManagementService dbManagementService) {
this.dbManagementService = dbManagementService;
}
@Override
public ResponseEntity<SuccessfullyProcessed> seedDB() {
log.debug("seedDB() called");
dbManagementService.seed();
return new ResponseEntity<>(HttpStatus.OK);
}
@Override
public ResponseEntity<SuccessfullyProcessed> clearDB() {
log.debug("clearDB() called");
dbManagementService.clear();
return new ResponseEntity<>(HttpStatus.OK);
}
}
package cz.muni.pa165.service;
import cz.muni.pa165.data.enums.ApplicationStatusEnum;
import cz.muni.pa165.data.model.Application;
import cz.muni.pa165.data.repository.ApplicationRepository;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
/**
* @author Michal Badin
*/
@Service
@Profile("dev")
public class DBManagementService {
private final ApplicationRepository applicationRepository;
@Autowired
public DBManagementService(ApplicationRepository applicationRepository) {
this.applicationRepository = applicationRepository;
}
@Transactional
@PostConstruct
public void seed() {
saveApplication(ApplicationStatusEnum.PENDING,
"Marek",
"Mrkvicka",
"marek.mrkvicka@example.com",
LocalDate.of(1999, 3, 8),
LocalDate.now());
saveApplication(ApplicationStatusEnum.ACCEPTED,
"Anuja",
"Ankska",
"ankska.anuja@example.com",
LocalDate.of(2000, 1, 30),
LocalDate.of(2010, 7, 18));
saveApplication(ApplicationStatusEnum.ACCEPTED,
"Xiao",
"Chen",
"xiao.chen@example.com",
LocalDate.of(1995, 7, 29),
LocalDate.of(2012, 10, 9));
saveApplication(ApplicationStatusEnum.REJECTED,
"Gertruda",
"Fialkova",
"gertruda.fialkova@example.com",
LocalDate.of(1965, 6, 2),
LocalDate.of(2023, 4, 26));
}
private void saveApplication(ApplicationStatusEnum status, String name, String surname, String email, LocalDate birthday, LocalDate fillingOutDate) {
Application application = new Application(status, name, surname, birthday, email, fillingOutDate);
applicationRepository.save(application);
}
@Transactional
public void clear() {
applicationRepository.deleteAll();
}
}
...@@ -10,4 +10,5 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect ...@@ -10,4 +10,5 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=true spring.jpa.show-sql=true
spring.jackson.property-naming-strategy=SNAKE_CASE spring.jackson.property-naming-strategy=SNAKE_CASE
spring.cache.type=NONE spring.cache.type=NONE
spring.profiles.active=dev
appconfig.enablecache=false appconfig.enablecache=false
\ No newline at end of file
...@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; ...@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.test.context.ActiveProfiles;
class ApplicationControllerTest { class ApplicationControllerTest {
......
...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -21,6 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -21,6 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*/ */
@SpringBootTest @SpringBootTest
@AutoConfigureMockMvc @AutoConfigureMockMvc
@ActiveProfiles("test")
class IntegrationTests { class IntegrationTests {
private static final Logger log = LoggerFactory.getLogger(IntegrationTests.class); private static final Logger log = LoggerFactory.getLogger(IntegrationTests.class);
......
...@@ -6,6 +6,7 @@ import cz.muni.pa165.data.repository.ApplicationRepository; ...@@ -6,6 +6,7 @@ import cz.muni.pa165.data.repository.ApplicationRepository;
import cz.muni.pa165.exceptions.ResourceNotFoundException; import cz.muni.pa165.exceptions.ResourceNotFoundException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -20,7 +21,7 @@ class ApplicationServiceTest { ...@@ -20,7 +21,7 @@ class ApplicationServiceTest {
RestTemplate restTemplate = Mockito.mock(RestTemplate.class); RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
ApplicationService service = new ApplicationService(applicationRepository, restTemplate); ApplicationService service = new ApplicationService(applicationRepository, restTemplate);
Application application = new Application(ApplicationStatusEnum.ACCEPTED, "John", "Doe", Application application = new Application(ApplicationStatusEnum.ACCEPTED, "John", "Doe",
LocalDate.now().minusYears(20), "john.doe@aaa.com", LocalDate.now()); LocalDate.now().minusYears(20), "john.doe@example.com", LocalDate.now());
@Test @Test
...@@ -36,7 +37,7 @@ class ApplicationServiceTest { ...@@ -36,7 +37,7 @@ class ApplicationServiceTest {
@Test @Test
void setStatus() { void setStatus() {
Application expected = new Application(ApplicationStatusEnum.REJECTED, "John", "Doe", Application expected = new Application(ApplicationStatusEnum.REJECTED, "John", "Doe",
LocalDate.now().minusYears(20), "john.doe@aaa.com", LocalDate.now()); LocalDate.now().minusYears(20), "john.doe@example.com", LocalDate.now());
when(applicationRepository.save(application)).thenReturn(expected); when(applicationRepository.save(application)).thenReturn(expected);
when(applicationRepository.findById(application.getId())).thenReturn(java.util.Optional.ofNullable(application)); when(applicationRepository.findById(application.getId())).thenReturn(java.util.Optional.ofNullable(application));
......
spring.datasource.url=jdbc:h2:mem:testApplicationdb;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE spring.datasource.url=jdbc:h2:mem:testApplicationdb;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;
spring.datasource.username=formulky-application-test spring.datasource.username=formulky-application-test
spring.datasource.password= spring.datasource.password=
spring.datasource.driverClassName=org.h2.Driver spring.datasource.driverClassName=org.h2.Driver
spring.jpa.hibernate.ddl-auto=create spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.properties.hibernate.generate_statistics=true spring.jpa.properties.hibernate.generate_statistics=true
spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.format_sql=true
......
...@@ -347,6 +347,16 @@ components: ...@@ -347,6 +347,16 @@ components:
properties: properties:
message: message:
type: string type: string
Successful:
description: Successfully processed
content:
application/json:
schema:
type: object
title: Successfully processed
properties:
message:
type: string
paths: paths:
/driver: /driver:
...@@ -949,3 +959,26 @@ paths: ...@@ -949,3 +959,26 @@ paths:
$ref: '#/components/responses/NotFound' $ref: '#/components/responses/NotFound'
default: default:
$ref: '#/components/responses/Unexpected' $ref: '#/components/responses/Unexpected'
/seed:
post:
tags:
- DBManagementService
summary: Seed DB with data
operationId: seedDB
responses:
"200":
$ref: '#/components/responses/Successful'
default:
$ref: '#/components/responses/Unexpected'
/clear:
post:
tags:
- DBManagementService
summary: Clear DB
operationId: clearDB
responses:
"200":
$ref: '#/components/responses/Successful'
default:
$ref: '#/components/responses/Unexpected'
package cz.muni.pa165.rest;
import cz.muni.pa165.generated.core.api.DbManagementServiceApiDelegate;
import cz.muni.pa165.generated.core.model.SuccessfullyProcessed;
import cz.muni.pa165.service.DBManagementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
/**
* @author Michal Badin
*/
@Profile("dev")
@Component
public class DBManagementController implements DbManagementServiceApiDelegate {
private static final Logger log = LoggerFactory.getLogger(DBManagementController.class);
private final DBManagementService dbManagementService;
@Autowired
public DBManagementController(DBManagementService dbManagementService) {
this.dbManagementService = dbManagementService;
}
@Override
public ResponseEntity<SuccessfullyProcessed> seedDB() {
log.debug("seedDB() called");
dbManagementService.seed();
return new ResponseEntity<>(HttpStatus.OK);
}
@Override
public ResponseEntity<SuccessfullyProcessed> clearDB() {
log.debug("clearDB() called");
dbManagementService.clear();
return new ResponseEntity<>(HttpStatus.OK);
}
}
package cz.muni.pa165.service;
import cz.muni.pa165.data.enums.ComponentTypeEnum;
import cz.muni.pa165.data.model.*;
import cz.muni.pa165.data.repository.*;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.Set;
import static cz.muni.pa165.data.enums.CharacteristicsEnum.*;
/**
* @author Michal Badin
*/
@Service
@Profile("dev")
public class DBManagementService {
private final CarComponentRepository carComponentRepository;
private final CarRepository carRepository;
private final DepartmentRepository departmentRepository;
private final DriverRepository driverRepository;
private final EngineerRepository engineerRepository;
@Autowired
public DBManagementService(CarComponentRepository carComponentRepository,
CarRepository carRepository,
DepartmentRepository departmentRepository,
DriverRepository driverRepository,
EngineerRepository engineerRepository) {
this.carComponentRepository = carComponentRepository;
this.carRepository = carRepository;
this.departmentRepository = departmentRepository;
this.driverRepository = driverRepository;
this.engineerRepository = engineerRepository;
}
@Transactional
@PostConstruct
public void seed() {
//region First car
Car car = new Car();
Driver driver = new Driver();
driver.setName("Xiao");
driver.setSurname("Chen");
driver.setBirthday(LocalDate.of(1995, 7, 29));
driver.setHeight(189);
driver.setNationality("Slovak");
driver.setCharacteristics(Set.of(AGGRESSIVENESS, EXCELLENT_STARTER, EXCELLENT_IN_THE_CORNERS, REACT_QUICKLY));
driverRepository.save(driver);
car.setDriver(driver);
carRepository.save(car);
saveCarComponent(ComponentTypeEnum.FRONTWING, 50.5, "Lightweight front wing v2 (black)", car);
saveCarComponent(ComponentTypeEnum.CHASSIS, 365.9, "Lightweight chassis", car);
saveCarComponent(ComponentTypeEnum.ENGINE, 300.5, "Lightweight V10 engine", car);
saveCarComponent(ComponentTypeEnum.SUSPENSION, 5.0, "Lightweight suspension v3 (black)", car);
//endregion
//region Second car
car = new Car();
driver = new Driver();
driver.setName("Marek");
driver.setSurname("Pilkovic");
driver.setBirthday(LocalDate.of(1987, 1, 1));
driver.setHeight(189);
driver.setNationality("British");
driver.setCharacteristics(Set.of(AGGRESSIVENESS, DRIVING_ON_THE_WET, EXCELLENT_IN_THE_CORNERS, REACT_QUICKLY));
driverRepository.save(driver);
car.setDriver(driver);
carRepository.save(car);
saveCarComponent(ComponentTypeEnum.FRONTWING, 57.5, "Lightweight front wing v3 (black)", car);
saveCarComponent(ComponentTypeEnum.CHASSIS, 325.9, "Lightweight chassis v5", car);
saveCarComponent(ComponentTypeEnum.ENGINE, 500.5, "V18 engine", car);
saveCarComponent(ComponentTypeEnum.SUSPENSION, 6.5, "Lightweight suspension v5 (white)", car);
//endregion
//region Test driver
Driver testDriver = new Driver();
testDriver.setName("Anuja");
testDriver.setSurname("Ankska");
testDriver.setNationality("Czech");
testDriver.setBirthday(LocalDate.of(2000, 1, 30));
testDriver.setHeight(175);
testDriver.setCharacteristics(Set.of(DRIVING_ON_THE_WET, REMAIN_COMPLETELY_FOCUSED, EFFICIENT_CARDIOVASCULAR_SYSTEMS));
driverRepository.save(testDriver);
//endregion
//region Car components
saveCarComponent(ComponentTypeEnum.FRONTWING, 70.5, "Front wing v7 (red)", null);
saveCarComponent(ComponentTypeEnum.CHASSIS, 500.9, "Medium weight chassis v2", null);
saveCarComponent(ComponentTypeEnum.ENGINE, 581.5, "V12 engine", null);
saveCarComponent(ComponentTypeEnum.SUSPENSION, 9.5, "Lightweight suspension v5 (white)", null);
//endregion
//region Department and engineers
Department department = new Department();
department.setSpecialization("Engine department");
departmentRepository.save(department);
Engineer engineer1 = new Engineer();
engineer1.setName("Michal");
engineer1.setSurname("Pekarik");
engineer1.setDepartment(department);
engineerRepository.save(engineer1);
Engineer engineer2 = new Engineer();
engineer2.setName("Andrej");
engineer2.setSurname("Uzasny");
engineer2.setDepartment(department);
engineerRepository.save(engineer2);
Engineer engineer3 = new Engineer();
engineer3.setName("Jitka");
engineer3.setSurname("Dlouha");
engineer3.setDepartment(department);
engineerRepository.save(engineer3);
Engineer engineer4 = new Engineer();
engineer4.setName("Betka");
engineer4.setSurname("Muslova");
engineer4.setDepartment(department);
engineerRepository.save(engineer4);
//endregion
}
private void saveCarComponent(ComponentTypeEnum type, double weight, String information, Car car) {
CarComponent carComponentFrontWing = new CarComponent(type, weight, information, car);
carComponentRepository.save(carComponentFrontWing);
}
@Transactional
public void clear() {
carComponentRepository.deleteAll();
carRepository.deleteAll();
driverRepository.deleteAll();
departmentRepository.deleteAll();
engineerRepository.deleteAll();
}
}
...@@ -10,4 +10,5 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect ...@@ -10,4 +10,5 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=true spring.jpa.show-sql=true
spring.jackson.property-naming-strategy=SNAKE_CASE spring.jackson.property-naming-strategy=SNAKE_CASE
spring.cache.type=NONE spring.cache.type=NONE
spring.profiles.active=dev
appconfig.enablecache=false appconfig.enablecache=false
\ No newline at end of file
...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -31,6 +32,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -31,6 +32,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*/ */
@SpringBootTest @SpringBootTest
@AutoConfigureMockMvc @AutoConfigureMockMvc
@ActiveProfiles("test")
class IntegrationTests { class IntegrationTests {
private static final Logger log = LoggerFactory.getLogger(IntegrationTests.class); private static final Logger log = LoggerFactory.getLogger(IntegrationTests.class);
......
...@@ -9,6 +9,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -9,6 +9,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -18,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -18,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest @SpringBootTest
@Transactional @Transactional
@ActiveProfiles("test")
class CarComponentRepositoryTest { class CarComponentRepositoryTest {
@Autowired @Autowired
......
...@@ -11,6 +11,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -11,6 +11,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.HashSet; import java.util.HashSet;
...@@ -26,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -26,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.*;
*/ */
@SpringBootTest @SpringBootTest
@Transactional @Transactional
@ActiveProfiles("test")
public class CarRepositoryTest { public class CarRepositoryTest {
@Autowired @Autowired
private EntityManager entityManager; private EntityManager entityManager;
......
...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest @SpringBootTest
@Transactional @Transactional
@ActiveProfiles("test")
class DepartmentRepositoryTest { class DepartmentRepositoryTest {
@Autowired @Autowired
......
...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest @SpringBootTest
@Transactional @Transactional
@ActiveProfiles("test")
class DriverRepositoryTest { class DriverRepositoryTest {
@Autowired @Autowired
......
...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -17,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest @SpringBootTest
@Transactional @Transactional
@ActiveProfiles("test")
class EngineerRepositoryTest { class EngineerRepositoryTest {
@Autowired @Autowired
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment