Skip to content

Commit

Permalink
Merge pull request Kernel360#95 from mooncw/feature/Kernel360#94-add-…
Browse files Browse the repository at this point in the history
…leveldata

[setting] data.sql에 모든 level 데이터 추가
  • Loading branch information
mooncw authored Jan 11, 2024
2 parents 541a3b7 + 883ec5d commit 9e28819
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ public class Level extends BaseEntity {
@Column(nullable = false, name = "image_url", columnDefinition = "varchar(100)")
private String imageUrl;

@Column(nullable = false, name = "level_upper_limit", columnDefinition = "bigint")
private Long levelUpperLimit = 500L;

@Builder
public Level(Long id, Long name, String imageUrl) {
public Level(Long id, Long name, String imageUrl, Long levelUpperLimit) {
this.id = id;
this.name = name;
this.imageUrl = imageUrl;
this.levelUpperLimit = levelUpperLimit;
}

public void update(Long name, String imageUrl) {
Expand Down
39 changes: 33 additions & 6 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ INSERT INTO member (created_date, experience, level_id, modified_date, email, im
VALUES ('2023-12-19T09:00:00', 0, 1, '2023-12-19T09:00:00', '[email protected]', 'member/1e47ea4d-a2cb-4de7-b7e4-a0f7bd1fa24cduck.png',
'자바덕', '$2a$10$OiSze5PH.QQ1uH7xWp.trOAbmv6rbi6foM7HsyDrVxn8RtZDMfWs.', 'introduction');

INSERT INTO authority (authority_type)
VALUES ('ROLE_USER');

INSERT INTO member_authority (member_id, authority_id)
VALUES (1, 1);

INSERT INTO question (closed_status, created_date, id, member_id, modified_date, view_count, content, image_url, title)
VALUES (1, '2023-12-19T09:00:00', 1, 1, '2023-12-21T09:00:00', 20, 'No content', 'question/d1c27379-2d08-4a6a-9d97-368124a50900thumb.jpg', '시간복잡도 사진');

Expand All @@ -12,11 +18,32 @@ VALUES ('2023-12-19T09:00:00', '2023-12-19T09:00:00', 'JavaScript');
INSERT INTO tech_stack (created_date, modified_date, skill)
VALUES ('2023-12-19T09:00:00', '2023-12-19T09:00:00', 'Python');

INSERT INTO level (created_date, modified_date, image_url, name)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level1to2.png', 1);
INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level1to2.png', 1, 200);

INSERT INTO authority (authority_type)
VALUES ('ROLE_USER');
INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level1to2.png', 2, 500);

INSERT INTO member_authority (member_id, authority_id)
VALUES (1, 1)
INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level3to4.png', 3, 1800);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level3to4.png', 4, 2500);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level5.png', 5, 5000);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level6.png', 6, 10000);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level7.png', 7, 20000);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level8.png', 8, 45000);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level9.png', 9, 100000);

INSERT INTO level (created_date, modified_date, image_url, name, level_upper_limit)
VALUES ('2023-12-12T09:00:00', '2023-12-12T09:00:00', 'level/level10.png', 10, 9223372036854775807);
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ void testFindAllLevel() throws Exception {
@DisplayName("레벨 삭제 성공 시 200 OK와 메시지를 반환한다")
void testDeleteLevel() throws Exception {
// Given
Level level = new Level(1L, 11L, "image9.jpg");
Level level = Level.builder()
.id(1L)
.name(11L)
.imageUrl("image9.jpg")
.build();

doNothing()
.when(levelService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void testFindLevelByName() {
.id(1L)
.name(1L)
.imageUrl("level/level1.png")
.levelUpperLimit(200L)
.build();

levelRepository.save(level);
Expand All @@ -41,6 +42,7 @@ void testFindLevelByName() {
assertThat(findLevel.getId()).isEqualTo(level.getId());
assertThat(findLevel.getName()).isEqualTo(level.getName());
assertThat(findLevel.getImageUrl()).isEqualTo(level.getImageUrl());
assertThat(findLevel.getLevelUpperLimit()).isEqualTo(level.getLevelUpperLimit());
}

@Test
Expand All @@ -51,6 +53,7 @@ void testFindByNameAndIdNot() {
.id(1L)
.name(1L)
.imageUrl("level/level1.png")
.levelUpperLimit(200L)
.build();

levelRepository.save(level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ void testFindAllLevel() {
@DisplayName("등급 삭제 테스트")
void testDeleteLevel() {
// Given
Level level = new Level(1L, 11L, "image1.jpg");
Level level = Level.builder()
.id(1L)
.name(11L)
.imageUrl("image9.jpg")
.build();

doNothing().when(levelRepository).deleteById(level.getId());
// When
Expand All @@ -89,7 +93,11 @@ void testDeleteLevel() {
@DisplayName("등급 수정 테스트")
void testUpdateLevel() {
// Given
Level level = new Level(1L, 1L, "image1.jpg");
Level level = Level.builder()
.id(1L)
.name(1L)
.imageUrl("image1.jpg")
.build();
UpdateLevelRequest updateLevelRequest = new UpdateLevelRequest(1L, 2L, "image2.jpg");
given(levelRepository.findById(anyLong())).willReturn(Optional.of(level));

Expand Down

0 comments on commit 9e28819

Please sign in to comment.