| | |
| | | import com.tourguide.modules.user.entity.GuideScenicConfig; |
| | | import com.tourguide.modules.user.entity.GuideUser; |
| | | import com.tourguide.modules.user.mapper.GuideAutoDisableConfigMapper; |
| | | import com.tourguide.modules.user.mapper.GuideApplicationMapper; |
| | | import com.tourguide.modules.user.mapper.GuideScenicConfigMapper; |
| | | import com.tourguide.modules.user.mapper.GuideTeamMapper; |
| | | import com.tourguide.modules.user.mapper.GuideTeamScenicConfigMapper; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | |
| | | class GuideUserScenicConfigServiceTest { |
| | | private GuideUserMapper userMapper; |
| | | private GuideScenicConfigMapper scenicConfigMapper; |
| | | private GuideTeamScenicConfigMapper teamScenicConfigMapper; |
| | | private OperationScenicSpotMapper scenicSpotMapper; |
| | | private OperationCityMapper cityMapper; |
| | | private GuideUserService service; |
| | |
| | | void setUp() { |
| | | userMapper = mock(GuideUserMapper.class); |
| | | scenicConfigMapper = mock(GuideScenicConfigMapper.class); |
| | | teamScenicConfigMapper = mock(GuideTeamScenicConfigMapper.class); |
| | | scenicSpotMapper = mock(OperationScenicSpotMapper.class); |
| | | cityMapper = mock(OperationCityMapper.class); |
| | | service = new GuideUserService( |
| | | userMapper, |
| | | mock(GuideTeamMapper.class), |
| | | mock(GuideApplicationMapper.class), |
| | | teamScenicConfigMapper, |
| | | scenicConfigMapper, |
| | | mock(GuideAutoDisableConfigMapper.class), |
| | | scenicSpotMapper, |
| | |
| | | } |
| | | |
| | | @Test |
| | | void addScenicConfigShouldRejectScenicOutsideGuidesTeam() { |
| | | GuideUser guide = new GuideUser(); |
| | | guide.setId(12L); |
| | | guide.setTeamId(51L); |
| | | when(userMapper.selectById(12L)).thenReturn(guide); |
| | | |
| | | OperationScenicSpot scenicSpot = new OperationScenicSpot(); |
| | | scenicSpot.setId(21L); |
| | | scenicSpot.setScenicName("青城山景区"); |
| | | scenicSpot.setCityId(31L); |
| | | scenicSpot.setStatus(1); |
| | | when(scenicSpotMapper.selectById(21L)).thenReturn(scenicSpot); |
| | | |
| | | OperationCity city = new OperationCity(); |
| | | city.setId(31L); |
| | | city.setCityName("成都市"); |
| | | when(cityMapper.selectById(31L)).thenReturn(city); |
| | | |
| | | assertThatThrownBy(() -> service.addScenicConfig(12L, 21L)) |
| | | .isInstanceOf(com.tourguide.common.exception.BusinessException.class) |
| | | .hasMessage("只能配置所属讲解队下的景区"); |
| | | verify(scenicConfigMapper, never()).upsert(any(GuideScenicConfig.class)); |
| | | } |
| | | |
| | | @Test |
| | | void deleteScenicConfigShouldRejectAnotherGuidesConfig() { |
| | | GuideScenicConfig config = new GuideScenicConfig(); |
| | | config.setId(41L); |