hufscheer / spectator-server

7 stars 0 forks source link

[FEAT] ๋Œ€ํšŒ ์ˆ˜์ • #193

Closed hodadako closed 2 months ago

hodadako commented 3 months ago

๐ŸŒ ์ด์Šˆ ๋ฒˆํ˜ธ

close #170

๐Ÿ“ ๊ตฌํ˜„ ๋‚ด์šฉ

๐Ÿ€ ํ™•์ธํ•ด์•ผ ํ•  ๋ถ€๋ถ„

๋„๋ฉ”์ธ ํ…Œ์ŠคํŠธ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ๊ทธ๋ƒฅ @ParameterizedTest๋ฅผ ์“ฐ์ง€ ์•Š๋Š”๊ฒŒ ๋” ์ข‹์„๊นŒ?


    @ParameterizedTest(name = "{0}")
    @MethodSource("leagueUpdateRequestStream")
    @DisplayName("๋ฆฌ๊ทธ ์ •๋ณด ์ˆ˜์ • ํ…Œ์ŠคํŠธ")
    void ๋ฆฌ๊ทธ_์ •๋ณด_์ˆ˜์ •(LeagueRequestDto.Update request, List<Function<League, Executable>> assertions) throws Exception {
        // given
        League sut = new League(
            manager,
            organization,
            nameArbitrary().sample(),
            LocalDateTime.of(20, 12, 11, 0, 0, 0),
            LocalDateTime.of(20, 12, 12, 0, 0, 0),
            Round.from("8๊ฐ•")
        );

        // when
        sut.updateInfo(request.name(), request.startAt(), request.endAt(), Round.from(request.maxRound()));

        // then
        assertAll(
            assertions.stream().map(assertion -> assertion.apply(sut))
        );
    }

    private static Stream<Arguments> leagueUpdateRequestStream() {
        String emptyName = "";
        String newName = "๋ ˆ๋ชฌ์ฆ™ ์ž…์— ๋ฌผ๊ณ  ์ฐธ๊ธฐ ๋Œ€ํšŒ";
        LocalDateTime startAt = LocalDateTime.of(20, 12, 20, 0, 0, 0);
        LocalDateTime endAt = LocalDateTime.of(20, 12, 21, 0, 0, 0);
        String maxRound = "16๊ฐ•";
        return Stream.of(
            leagueUpdateRequestArgument(
                "์ด๋ฆ„์ด ๋นˆ ๊ฐ’์ด ์•„๋‹ ๊ฒฝ์šฐ, ๋Œ€ํšŒ ์ด๋ฆ„, ์‹œ์ž‘ ์‹œ๊ฐ„, ์ข…๋ฃŒ ์‹œ๊ฐ„, ์ด ๋ผ์šด๋“œ ์ˆ˜๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค.",
                new LeagueRequestDto.Update(newName, startAt, endAt, maxRound),
                List.of(
                    (league) -> () -> assertThat(league.getName()).isEqualTo(newName),
                    (league) -> () -> assertThat(league.getStartAt()).isEqualTo(startAt),
                    (league) -> () -> assertThat(league.getEndAt()).isEqualTo(endAt),
                    (league) -> () -> assertThat(league.getMaxRound().getDescription()).isEqualTo(maxRound)
                )
            ),
            leagueUpdateRequestArgument(
                "์ด๋ฆ„์ด ๋นˆ ๊ฐ’์ธ ๊ฒฝ์šฐ, ์ด๋ฆ„์„ ์ œ์™ธํ•œ ์‹œ์ž‘ ์‹œ๊ฐ„, ์ข…๋ฃŒ ์‹œ๊ฐ„, ์ด ๋ผ์šด๋“œ ์ˆ˜๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค.",
                new LeagueRequestDto.Update(emptyName, startAt, endAt, maxRound),
                List.of(
                    (league) -> () -> assertThat(league.getName()).isNotEqualTo(emptyName),
                    (league) -> () -> assertThat(league.getStartAt()).isEqualTo(startAt),
                    (league) -> () -> assertThat(league.getEndAt()).isEqualTo(endAt),
                    (league) -> () -> assertThat(league.getMaxRound().getDescription()).isEqualTo(maxRound)
                )
            )
        );
    }

    private static Arguments leagueUpdateRequestArgument(
        final String testDisplayName,
        final LeagueRequestDto.Update request,
        final List<Function<League, Executable>> assertions) {
        return Arguments.of(
            named(testDisplayName, request), assertions
        );
    }