mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-06 02:49:56 +00:00
test: cover method-level RequestMapping routes
Add Spring fixture coverage for method-level RequestMapping variants with and without an explicit RequestMethod to lock in route extraction behavior. Made-with: Cursor
This commit is contained in:
parent
a86ed50bfd
commit
d8df203cf7
3 changed files with 25 additions and 0 deletions
|
|
@ -6,6 +6,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
@RestController
|
||||
public class HealthController {
|
||||
@RequestMapping("/status")
|
||||
public String status() {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/health", method = RequestMethod.GET)
|
||||
public String health() {
|
||||
return "ok";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
|
|
@ -23,4 +24,9 @@ public class UserController {
|
|||
public String updateProfile() {
|
||||
return "updated";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/users/search", method = RequestMethod.POST)
|
||||
public String searchUsers() {
|
||||
return "search";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,18 +20,26 @@ describe('Spring route mapping', () => {
|
|||
expect(routes).toContain('/api/users');
|
||||
expect(routes).toContain('/api/users/create');
|
||||
expect(routes).toContain('/api/users/profile');
|
||||
expect(routes).toContain('/api/users/search');
|
||||
expect(routes).toContain('/health');
|
||||
expect(routes).toContain('/status');
|
||||
});
|
||||
|
||||
it('creates HANDLES_ROUTE edges from controller files', () => {
|
||||
const edges = getRelationships(result, 'HANDLES_ROUTE');
|
||||
const usersRoute = edges.find((edge) => edge.target === '/api/users');
|
||||
const searchRoute = edges.find((edge) => edge.target === '/api/users/search');
|
||||
const healthRoute = edges.find((edge) => edge.target === '/health');
|
||||
const statusRoute = edges.find((edge) => edge.target === '/status');
|
||||
|
||||
expect(usersRoute).toBeDefined();
|
||||
expect(usersRoute!.sourceFilePath).toContain('UserController.java');
|
||||
expect(searchRoute).toBeDefined();
|
||||
expect(searchRoute!.sourceFilePath).toContain('UserController.java');
|
||||
expect(healthRoute).toBeDefined();
|
||||
expect(healthRoute!.sourceFilePath).toContain('HealthController.java');
|
||||
expect(statusRoute).toBeDefined();
|
||||
expect(statusRoute!.sourceFilePath).toContain('HealthController.java');
|
||||
});
|
||||
|
||||
it('creates framework CALLS edges from controller files to handler methods', () => {
|
||||
|
|
@ -39,8 +47,14 @@ describe('Spring route mapping', () => {
|
|||
expect(
|
||||
edges.some((edge) => edge.source === 'UserController.java' && edge.target === 'listUsers'),
|
||||
).toBe(true);
|
||||
expect(
|
||||
edges.some((edge) => edge.source === 'UserController.java' && edge.target === 'searchUsers'),
|
||||
).toBe(true);
|
||||
expect(
|
||||
edges.some((edge) => edge.source === 'HealthController.java' && edge.target === 'health'),
|
||||
).toBe(true);
|
||||
expect(
|
||||
edges.some((edge) => edge.source === 'HealthController.java' && edge.target === 'status'),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue