longz
2026-07-30 e2ec753e232106f336894f58d585e58c27bf1f29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.ruoyi.chargingPile.controller;
 
import com.ruoyi.chargingPile.api.dto.TParkingLotDTO;
import com.ruoyi.chargingPile.service.TCarportService;
import com.ruoyi.chargingPile.service.TParkingLotService;
import com.ruoyi.chargingPile.service.TVehicleRampService;
import com.ruoyi.common.core.exception.ServiceException;
import org.junit.jupiter.api.Test;
 
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
 
class TParkingLotControllerTest {
 
    private final TParkingLotController controller = new TParkingLotController(
            mock(TParkingLotService.class),
            mock(TVehicleRampService.class),
            mock(TCarportService.class)
    );
 
    @Test
    void rejectsShunjieForCooperativeParkingLot() {
        TParkingLotDTO dto = new TParkingLotDTO();
        dto.setType(2);
        dto.setBarrierBrand(1);
 
        assertThrows(ServiceException.class, () -> controller.add(dto));
    }
 
    @Test
    void allowsShunjieForDirectParkingLot() {
        TParkingLotDTO dto = new TParkingLotDTO();
        dto.setType(1);
        dto.setBarrierBrand(1);
 
        assertDoesNotThrow(() -> controller.add(dto));
    }
}