private Action findAction(String path, String method) { final Resource resource = findResourceByPath(path); resourceUsage(usage, resource).incUses(1); final Action action = resource.getAction(method); if (action == null) { requestViolations.add("action.undefined", locator, method); throw new RamlViolationException(); } actionUsage(usage, action).incUses(1); locator.action(action); return action; }
@Test public void testEnumsTypesQueryForRaml() { processResource("RestDocEndpoint.java", "raml", "all"); Raml raml = new RamlDocumentBuilder().build(defaultApiOutput, "http://example.com"); AssertJUnit.assertNotNull("RAML not parseable", raml); Resource resource = raml.getResource("/mount/api/v1/whirlygigs"); AssertJUnit.assertNotNull("Resource /mount/api/v1/whirlygigs not found", resource); Action action = resource.getAction(ActionType.GET); AssertJUnit.assertNotNull("Method GET not found on /mount/api/v1/whirlygigs", action); QueryParameter qp = action.getQueryParameters().get("color"); AssertJUnit.assertNotNull("No color query param found on GET method of /mount/api/v1/whirlygigs", qp); List<String> enums = qp.getEnumeration(); AssertJUnit.assertNotNull("Color query param on GET method of /mount/api/v1/whirlygigs not enum", enums); AssertJUnit.assertEquals("Color query param on GET /mount/api/v1/whirlygigs is wrong size", 3, enums.size()); }
Action act = res.getAction(ActionType.GET); AssertJUnit.assertNotNull("method GET /stable1 not found", act); List<String> is = act.getIs(); act = res.getAction(ActionType.GET); AssertJUnit.assertNotNull("method GET /deprecated2 not found", act); is = act.getIs(); act = res.getAction(ActionType.GET); AssertJUnit.assertNotNull("method GET /stable3 not found", act); is = act.getIs(); act = res.getAction(ActionType.GET); AssertJUnit.assertNotNull("method GET /deprecated3 not found", act); is = act.getIs(); act = res.getAction(ActionType.GET); AssertJUnit.assertNotNull("method GET /experimentaldeprecated3 not found", act); is = act.getIs();
Resource resource = raml.getResource("/default/api/v1/default"); AssertJUnit.assertNotNull("RAML has no default controller", resource); Action action = resource.getAction(ActionType.GET); AssertJUnit.assertNotNull("RAML default controller has no get action", action); List<SecurityReference> secRef = action.getSecuredBy(); action = resource.getAction(ActionType.POST); AssertJUnit.assertNotNull("RAML twoscope controller has no get action", action); secRef = action.getSecuredBy(); AssertJUnit.assertTrue("RAML twoscope secref parameters includes two_scope_service:admin scope", !scopes.contains("two_scope_service:admin")); action = resource.getAction(ActionType.GET); AssertJUnit.assertNotNull("RAML twoscope controller has no post action", action); secRef = action.getSecuredBy();