전체 글
-
[백준] 1854번 : k번째 최단경로 찾기알고리즘/백준 2022. 5. 15. 01:17
https://www.acmicpc.net/problem/1854 1854번: K번째 최단경로 찾기 첫째 줄에 n, m, k가 주어진다. (1 ≤ n ≤ 1000, 0 ≤ m ≤ 2000000, 1 ≤ k ≤ 100) n과 m은 각각 김 조교가 여행을 고려하고 있는 도시들의 개수와, 도시 간에 존재하는 도로의 수이다. 이어지는 m개의 줄에 www.acmicpc.net 문제 해석 항상 최단경로로 이동하는 것을 별로 좋아하지 않는다. 또한 너무 시간이 오래 걸리는 경로도 좋아하지 않아 적당한 타협안인 'k번째 최단경로'를 구하길 원합니다. 도시는 항상 1번부터 시작합니다. 첫째 줄에 n, m, k가 주어집니다. n은 김 조교가 여행을 고려하고 있는 도시들의 개수 m은 도시 간에 존재하는 도로의 수 입니다. ..
-
JPA로 Update를 해보자!프로젝트/게시판 프로젝트 2022. 5. 14. 00:01
회원가입 로직을 작성하던 중 회원이 정보를 수정할 수 있기 때문에 JPA를 통해 Update를 해보고자 합니다. 하지만 Spirng Data JPA에서는 update 메서드가 없습니다. 그러면 JPA에서는 어떻게 Update를 할 수 있을까요? 이를 하기 위해서는 JPA의 Dirty Checking이란 것을 먼저 알아야 합니다. Dirty Checking이란? 여기서 Dirty란 상태의 변화가 생긴 정도로 이해하면 좋습니다. 즉, 상태 변화를 확인하는 것이 바로 Dirty Checking입니다. JPA에서는 트랜잭션이 끝나는 시점에 변화가 있는 모든 엔티티 객체를 데이터베이스에 자동으로 반영해 줍니다. 변화가 있다의 기준은 최초 조회 상태입니다. JPA는 엔티티를 조회하게 되면 해당 엔티티의 조회 상태를..
-
[백준] 1600번 : 말이 되고픈 원숭이 - 자바(JAVA)알고리즘/백준 2022. 5. 14. 00:01
https://www.acmicpc.net/problem/1600 1600번: 말이 되고픈 원숭이 첫째 줄에 정수 K가 주어진다. 둘째 줄에 격자판의 가로길이 W, 세로길이 H가 주어진다. 그 다음 H줄에 걸쳐 W개의 숫자가 주어지는데, 0은 아무것도 없는 평지, 1은 장애물을 뜻한다. 장애물이 있 www.acmicpc.net 문제 해석 말은 격자판에서 체스의 나이트와 같은 이동방식을 가집니다. X 표시한 곳은 말이 갈 수 있는 위치이며 말은 장애물을 뛰어넘을 수 있습니다. 하지만 원숭이는 능력이 부족해서 k번만 말처럼 움직일 수 있고 ,그 외에는 그냥 인접한 칸으로 움직일 수 있습니다. 인접한칸은 상하좌우를 의미합니다. 원숭이는 맨 왼쪽위에서 시작해서 맨 오른쪽 아래로 가려고 합니다. 최소한의 동작으로..
-
Mock 프레임워크란? (+ Mockito 프레임워크 사용 예시)테스트코드(Test Code) 2022. 5. 13. 14:40
Mock이란? https://junuuu.tistory.com/203?category=981663 Mock 객체란? Mock 객체란? Mock은 사전적 의미로 모조품이라는 뜻을 가집니다. 즉, 제품의 외양을 흉내 낸 모조품을 말하며 소프트웨어에서는 모듈의 겉모양이 실제 모듈과 비슷하게 보이도록 만든 가짜 객체 junuuu.tistory.com Mock 프레임워크란? Mock 객체를 직접 작성해서 명시적인 클래스로 만들지 않아도 됩니다. Mock 객체에 대해서 행위까지도 테스트 케이스에 포함시킬 수 있습니다. Mock 객체를 직접 만드는 것 자체가 별로 부담은 되지 않지만 Mock 클래스 숫자가 점점 늘어나게 되면 관리에 부담이 발생합니다. 따라서 Mock 프레임워크를 사용하면 Mock 객체를 편리하게 관..
-
[백준] 2636번 : 치즈 - 자바(JAVA)알고리즘/백준 2022. 5. 13. 00:01
https://www.acmicpc.net/problem/2636 2636번: 치즈 첫째 줄에는 사각형 모양 판의 세로와 가로의 길이가 양의 정수로 주어진다. 세로와 가로의 길이는 최대 100이다. 판의 각 가로줄의 모양이 윗 줄부터 차례로 둘째 줄부터 마지막 줄까지 주어진 www.acmicpc.net 문제 해석 정사각형 칸으로 이루어진 보드가 존재합니다. 그 위에 회색으로 표시된 부분은 치즈를 의미합니다. 치즈는 공기 중에 놓으면 녹게 되며 한 시간이 지나면 녹게 됩니다. 테두리 부분인 c부분이 한 시간이 지나면 녹게 되며 다음과 같은 그림이 됩니다. 이때 치즈가 모두 녹아 없어지는데 걸리는 시간과 모두 녹기 한 시간 전에 남아있는 치즈 조각이 놓여있는 칸의 개수를 구하세요 문제 풀이 전 설계 공기와 ..
-
컨트롤러를 테스트해보자!프로젝트/게시판 프로젝트 2022. 5. 13. 00:01
Service나 Repository에 대해 테스트 코드를 작성하는 것은 익숙했습니다. 하지만 Controller를 테스트하기 위해서는? 어떻게 해야 하는지 감이 잘 오지 않습니다. 직접 Web UI로 하거나 아니면 조금 더 편리하게 Postman을 사용하여 테스트를 진행했습니다. 지금부터는 직접 테스트 코드를 작성해서 Controller를 테스트해보고자 합니다. 목표 컨트롤러를 테스트해보자 컨트롤러에서 인자로 받는 @Valid MemberRequestDTO가 제대로 검증되는지 테스트해보자 Controller Test 다음은 현재 Controller의 코드입니다. @RestController @RequiredArgsConstructor @RequestMapping("/members") public clas..
-
[백준] 1516번 : 게임 개발 - 자바(JAVA)알고리즘/백준 2022. 5. 12. 00:01
https://www.acmicpc.net/problem/1516 1516번: 게임 개발 첫째 줄에 건물의 종류 수 N(1 ≤ N ≤ 500)이 주어진다. 다음 N개의 줄에는 각 건물을 짓는데 걸리는 시간과 그 건물을 짓기 위해 먼저 지어져야 하는 건물들의 번호가 주어진다. 건물의 번호는 1부 www.acmicpc.net 문제 해석 모든 건물이 완성되기 위한 시간을 구해야 합니다. 건물에는 순서가 존재할 수 있습니다. 예를 들어 A건물을 지어야지 B건물을 지을 수 있는 경우가 존재하기 때문에 이점을 고려해야 합니다. 건물의 수와 각 건물의 짓는 데 걸리는 시간과 해당 건물을 짓기 위해 지어져야 하는 건물들의 번호가 주어집니다. 짓기 위해 지어야 하는 건물은 여러 개가 존재할 수 있습니다. 각 줄은 -1으..
-
[에러 해결 완료] Type definition error , InvalidDefinitionException프로젝트/게시판 프로젝트 2022. 5. 12. 00:01
@Valid 애노테이션을 활용하여 데이터 검증을 테스트하기 위해서 POSTMAN으로 회원가입 POST 요청을 보내는 과정에서 400 BAD REQUEST를 기대하였으나 500 에러가 발생하였습니다. 왜 그럴까 하고 실제로 에러 메시지를 출력해보았습니다. 다음과 같은 에러가 발생했습니다. Type definition error: [simple type, class anthill.Anthill.dto.member.MemberRequestDTO]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `anthill.Anthill.dto.member.MemberRe..