From 3cdb0f353c0043940c9a360d285553de8521db6e Mon Sep 17 00:00:00 2001 From: kokodak Date: Thu, 5 Oct 2023 10:48:36 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=ED=96=89=EC=9C=84=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=83=81=ED=83=9C=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../place/application/PlaceServiceTest.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java b/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java index 980704ea1..c1543b507 100644 --- a/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java +++ b/backend/src/test/java/com/now/naaga/place/application/PlaceServiceTest.java @@ -3,11 +3,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import com.now.naaga.common.builder.PlaceBuilder; import com.now.naaga.common.builder.PlayerBuilder; +import com.now.naaga.common.builder.TemporaryPlaceBuilder; import com.now.naaga.common.exception.BaseExceptionType; import com.now.naaga.place.application.dto.CreatePlaceCommand; import com.now.naaga.place.domain.Place; @@ -15,13 +14,13 @@ import com.now.naaga.place.exception.PlaceException; import com.now.naaga.place.exception.PlaceExceptionType; import com.now.naaga.player.domain.Player; -import com.now.naaga.temporaryplace.application.TemporaryPlaceService; +import com.now.naaga.temporaryplace.domain.TemporaryPlace; +import com.now.naaga.temporaryplace.repository.TemporaryPlaceRepository; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.jdbc.Sql; import org.springframework.transaction.annotation.Transactional; @@ -33,12 +32,15 @@ @SpringBootTest class PlaceServiceTest { - @MockBean - private TemporaryPlaceService temporaryPlaceService; + @Autowired + private TemporaryPlaceRepository temporaryPlaceRepository; @Autowired private PlaceService placeService; + @Autowired + private TemporaryPlaceBuilder temporaryPlaceBuilder; + @Autowired private PlaceBuilder placeBuilder; @@ -52,7 +54,10 @@ class PlaceServiceTest { final Player player = playerBuilder.init() .build(); - final Long temporaryPlaceId = 1L; + final TemporaryPlace temporaryPlace = temporaryPlaceBuilder.init() + .build(); + + final Long temporaryPlaceId = temporaryPlace.getId(); final CreatePlaceCommand createPlaceCommand = new CreatePlaceCommand("루터회관", "이곳은 루터회관이다 알겠냐", @@ -71,11 +76,14 @@ class PlaceServiceTest { createPlaceCommand.imageUrl(), player); + final TemporaryPlace found = temporaryPlaceRepository.findById(temporaryPlaceId) + .orElse(null); + assertSoftly(softAssertions -> { assertThat(actual).usingRecursiveComparison() .ignoringExpectedNullFields() .isEqualTo(expected); - verify(temporaryPlaceService, times(1)).deleteById(temporaryPlaceId); + assertThat(found).isNull(); }); }