Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HttpTriggerWorkflow ValidateQueries #79

Closed
wants to merge 1 commit into from

Conversation

wnsgml7267
Copy link

관련 이슈 : 엔드포인트 리팩토링 #63
작업 사항 : nt-sms 내부의 Triggers 폴더에 있는 엔드포인트들의 동일한 워크플로우를 가진 Query 메소드를 하나의 서비스 레이어를 생성하여 Fluent API 형태로 리팩토링

@wnsgml7267
Copy link
Author

쿼리 단위테스트에서 RequestQueryNotValidException을 던지는 것을 테스트 해보고 싶어 질문이 있습니다.
아래 메소드를 참고해서 쿼리 단위테스트에서 RequestQueryNotValidException을 던지고 싶은데 result.isValid가 False일 때 예외를 던지는 것으로 이해하면 될까요??
nhn-toast-notification-service-custom-connector/src/nt-sms/Validators/GetMessageRequestQueryValidator.cs

    public static class GetMessageRequestQueryValidatorExtension
    {
        /// <summary>
        /// Validates the request query parameters against GetMessage.
        /// </summary>
        /// <param name="headers"><see cref="GetMessageRequestQueries"/> instance.</param>
        /// <returns>Returns the <see cref="GetMessageRequestQueries"/> instance.</returns>
        public static async Task<GetMessageRequestQueries> Validate(this Task<GetMessageRequestQueries> queries, IValidator<GetMessageRequestQueries> validator)
        {
            var instance = await queries.ConfigureAwait(false);

            var result = validator.Validate(instance);
            if (result.IsValid)
            {
                return instance;
            }

            throw new RequestQueryNotValidException("Invalid Query Parameters") { StatusCode = HttpStatusCode.BadRequest };
        }
    }

@justinyoo
Copy link
Contributor

@wnsgml7267 우선은 닫아두고 나중에 다시 리뷰하겠습니다!

@justinyoo justinyoo closed this Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants