분류 전체보기 76

JUnit5를 이용한 단위 테스트

소스 작성중 JUnit 이 임포트가 안되는 문제가 생김.그래들엔 분명 spring-boot-starter-test 의존성이 있고, 책에선 이게 JUnit5, 모키토, 어서트J 같은 테스트 라이브러리를 프로젝트로 임포트 한다고 써있는데...! package com.polarbookshop.catalogservice.domain;import jakarta.validation.Validation;import jakarta.validation.Validator;import jakarta.validation.ValidatorFactory;import org.junit.jupiter.api.BeforeAll;//Book 객체의 유효성 검사 제약조건을 검증하기 위한 단위 테스트public class BookValid..

[Java] 21. Merge Two Sorted Lists

난이도: EASY문제더보기You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4]Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = []..

[SQL50] 595. Big Countries

난이도: EASY 문제더보기Table: World +-------------+---------+ | Column Name | Type    | +-------------+---------+ | name        | varchar | | continent   | varchar | | area        | int     | | population  | int     | | gdp         | bigint  | +-------------+---------+ name is the primary key (column with unique values) for this table. Each row of this table gives information about the name of a country..

[SQL50] 584. Find Customer Referee

난이도: EASY 문제더보기Table: Customer+-------------+--------------+ | Column Name | Type | +-------------+--------------+ | id                | int          | | name         | varchar   | | referee_id  | int           | +-------------+--------------+ In SQL, id is the primary key column for this table. Each row of this table indicates the id of a customer, their name, and the id of the customer who ref..

중앙식 예외 핸들러와 이를 이용한 오류 처리

112p ~ @RestControllerAdvice 클래스는 예외와 상태 코드 사이의 매핑을 제공. 카탈로그에 이미 있는 책 생성시 422(처리할 수 없는 개체), 존재하지 않는 책을 가져오려할 때는 404(찾을 수 없음), Book 객체에서 하나 이상의 필드가 잘못되었을 때는 400(잘못된 요청) 응답 반환. package com.polarbookshop.catalogservice.web;import com.polarbookshop.catalogservice.domain.BookAlreadyExistsException;import com.polarbookshop.catalogservice.domain.BookNotFoundException;import org.springframework.http.Htt..

데이터 유효성 검사

109p ~ 111p 유효성 검사를 해야할 조건은 아래와 같다. ISBN은 올바른 형식으로 정의되어야 한다(ISBN-10 or 13)제목, 저자, 가격은 반드시 있어야하고 가격은 0보다 큰 값이어야 한다.plugins { id 'java' id 'org.springframework.boot' version '3.4.1' id 'io.spring.dependency-management' version '1.1.7'}group = 'com.polarbookshop'version = '0.0.1-SNAPSHOT'java { toolchain { languageVersion = JavaLanguageVersion.of(17) }}repositories { mavenCentral()}dependencies { ..

스프링 MVC를 이용한 REST API 구현, 그리고 Httpie 설치와의 사투

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 넘나 멍청하게 ./gradlew bootRun 치고 왜 안되지...... 이러고 있다가 윈도우터미널인걸 깨닫...하 바보가태 윈도우면 gradlew.bat bootRun 으로 실행 근데 또 오류낫쥬...? ㅎㅎ.... 더보기11:12:27.135 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here  in 'reader', line 2, column 7:     server:           ^      ..

[SQL50] 1757. Recyclable and Low Fat Products

난이도: EASY 문제문제가 너무 쉬워서 5번 다시 읽음.더보기Table: Products +-------------+---------+ | Column Name | Type    | +-------------+---------+ | product_id  | int     | | low_fats    | enum    | | recyclable  | enum    | +-------------+---------+ product_id is the primary key (column with unique values) for this table. low_fats is an ENUM (category) of type ('Y', 'N') where 'Y' means this product is low fat a..

[Java] 20. Valid Parentheses

난이도: EASY문제더보기Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: In..

스프링 MVC를 이용한 RESTful 애플리케이션 구축(2)

맨날 쓰던 어노테이션 이번 기회에 챗지에게 물어 정리 package com.polarbookshop.catalogservice;import com.polarbookshop.catalogservice.domain.Book;import com.polarbookshop.catalogservice.domain.BookRepository;import com.polarbookshop.catalogservice.domain.BookService;import org.springframework.http.HttpStatus;import org.springframework.web.bind.annotation.*;import java.util.Map;import java.util.Optional;import java.uti..