| | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import java.lang.reflect.Method; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | |
| | | class TTestControllerContractTest |
| | |
| | | assertPermission("getInfo", "@ss.hasPermi('system:test:query')", Long.class); |
| | | assertPermission("add", "@ss.hasPermi('system:test:add')", com.ruoyi.system.domain.TTest.class); |
| | | assertPermission("edit", "@ss.hasPermi('system:test:edit')", com.ruoyi.system.domain.TTest.class); |
| | | assertPermission("startReception", "@ss.hasPermi('system:test:start')", Long.class); |
| | | Method startReception = TTestController.class.getMethod("startReception", Long.class); |
| | | assertEquals("/{testId}/reception/start", startReception.getAnnotation(PostMapping.class).value()[0]); |
| | | assertPermission("pauseReception", "@ss.hasPermi('system:test:pause')", Long.class); |
| | | assertEquals("/{testId}/reception/pause", TTestController.class.getMethod("pauseReception", Long.class) |
| | | .getAnnotation(PostMapping.class).value()[0]); |
| | | assertPermission("resumeReception", "@ss.hasPermi('system:test:resume')", Long.class); |
| | | assertEquals("/{testId}/reception/resume", TTestController.class.getMethod("resumeReception", Long.class) |
| | | .getAnnotation(PostMapping.class).value()[0]); |
| | | assertEquals("/{testId}/reception/intervals", TTestController.class.getMethod("receptionIntervals", Long.class) |
| | | .getAnnotation(GetMapping.class).value()[0]); |
| | | } |
| | | |
| | | private void assertPermission(String methodName, String permission, Class<?>... parameterTypes) throws Exception |