доделал тесты
This commit is contained in:
parent
1db0e84d89
commit
17214648a2
@ -50,31 +50,34 @@ public class DemoApplication implements CommandLineRunner {
|
|||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
log.info("start");
|
log.info("start");
|
||||||
|
|
||||||
log.info("Create default user values");
|
// log.info("Create default user values");
|
||||||
final var admin = new UserEntity("admin", "admin@mail.com", "admin");
|
// final var admin = new UserEntity("admin", "admin@mail.com", "admin");
|
||||||
admin.setRole(UserRole.ADMIN);
|
// admin.setRole(UserRole.ADMIN);
|
||||||
userService.create(admin);
|
// userService.create(admin);
|
||||||
final var user1 = userService.create(new UserEntity("user", "user@gmail.com", Constants.DEFAULT_PASSWORD));
|
// final var user1 = userService.create(new UserEntity("user", "user@gmail.com",
|
||||||
|
// Constants.DEFAULT_PASSWORD));
|
||||||
|
|
||||||
final var type1 = typeService.create(new TypeEntity("ААА"));
|
// final var type1 = typeService.create(new TypeEntity("ААА"));
|
||||||
final var type2 = typeService.create(new TypeEntity("АА"));
|
// final var type2 = typeService.create(new TypeEntity("АА"));
|
||||||
|
|
||||||
final var genre1 = genreService.create(new GenreEntity("Приключения"));
|
// final var genre1 = genreService.create(new GenreEntity("Приключения"));
|
||||||
final var genre2 = genreService.create(new GenreEntity("Симулятор"));
|
// final var genre2 = genreService.create(new GenreEntity("Симулятор"));
|
||||||
|
|
||||||
final List<GenreEntity> genres1 = new ArrayList<GenreEntity>();
|
// final List<GenreEntity> genres1 = new ArrayList<GenreEntity>();
|
||||||
genres1.add(genre1);
|
// genres1.add(genre1);
|
||||||
genres1.add(genre2);
|
// genres1.add(genre2);
|
||||||
|
|
||||||
final List<GenreEntity> genres2 = new ArrayList<GenreEntity>();
|
// final List<GenreEntity> genres2 = new ArrayList<GenreEntity>();
|
||||||
genres2.add(genre2);
|
// genres2.add(genre2);
|
||||||
|
|
||||||
final var game1 = gameService.create(new GameEntity(type1, "Game1", 2100.0, "good game", genres1));
|
// final var game1 = gameService.create(new GameEntity(type1, "Game1", 2100.0,
|
||||||
final var game2 = gameService.create(new GameEntity(type2, "Game2", 1200.0, "bad game", genres2));
|
// "good game", genres1));
|
||||||
final List<GameEntity> games = new ArrayList<GameEntity>();
|
// final var game2 = gameService.create(new GameEntity(type2, "Game2", 1200.0,
|
||||||
games.add(game1);
|
// "bad game", genres2));
|
||||||
games.add(game2);
|
// final List<GameEntity> games = new ArrayList<GameEntity>();
|
||||||
|
// games.add(game1);
|
||||||
|
// games.add(game2);
|
||||||
|
|
||||||
orderService.create(user1.getId(), new OrderEntity(games));
|
// orderService.create(user1.getId(), new OrderEntity(games));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class TypeServiceTests {
|
|||||||
void createData() {
|
void createData() {
|
||||||
removeData();
|
removeData();
|
||||||
|
|
||||||
|
|
||||||
type2 = typeService.create(new TypeEntity("Программа"));
|
type2 = typeService.create(new TypeEntity("Программа"));
|
||||||
|
|
||||||
type1 = typeService.create(new TypeEntity("Игра"));
|
type1 = typeService.create(new TypeEntity("Игра"));
|
||||||
@ -42,23 +41,23 @@ class TypeServiceTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
void getTest(){
|
void getTest() {
|
||||||
Assertions.assertThrows(NotFoundException.class, () -> typeService.get(0L));
|
Assertions.assertThrows(NotFoundException.class, () -> typeService.get(0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
@Transactional
|
@Transactional
|
||||||
void createTest(){
|
void createTest() {
|
||||||
final TypeEntity last = typeService.create(new TypeEntity("Игра2"));
|
final TypeEntity last = typeService.create(new TypeEntity("Игра2"));
|
||||||
Assertions.assertEquals(3, typeService.getAll().size());
|
Assertions.assertEquals(3, typeService.getAll().size());
|
||||||
Assertions.assertEquals(last, typeService.get(3L));
|
Assertions.assertEquals(last, typeService.get(29L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@Transactional
|
@Transactional
|
||||||
void updateTest(){
|
void updateTest() {
|
||||||
final String test = "TEST";
|
final String test = "TEST";
|
||||||
final TypeEntity newEntity = typeService.update(type1.getId(), new TypeEntity(test));
|
final TypeEntity newEntity = typeService.update(type1.getId(), new TypeEntity(test));
|
||||||
Assertions.assertEquals(2, typeService.getAll().size());
|
Assertions.assertEquals(2, typeService.getAll().size());
|
||||||
@ -68,10 +67,10 @@ class TypeServiceTests {
|
|||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
@Transactional
|
@Transactional
|
||||||
void deleteTest(){
|
void deleteTest() {
|
||||||
typeService.delete(type1.getId());
|
typeService.delete(type1.getId());
|
||||||
Assertions.assertEquals(1, typeService.getAll().size());
|
Assertions.assertEquals(1, typeService.getAll().size());
|
||||||
final TypeEntity last = typeService.get(type2.getId());
|
final TypeEntity last = typeService.get(type2.getId());
|
||||||
Assertions.assertEquals(6L, last.getId());
|
Assertions.assertEquals(type2.getId(), last.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user