@Test public void test_definition() { WebService.Action definition = ws.getDef(); assertThat(definition.key()).isEqualTo("current"); assertThat(definition.description()).isEqualTo("Get the details of the current authenticated user."); assertThat(definition.since()).isEqualTo("5.2"); assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isTrue(); assertThat(definition.responseExampleAsString()).isNotEmpty(); assertThat(definition.params()).isEmpty(); assertThat(definition.changelog()).hasSize(2); }
@Test public void definition() { WebService.Action definition = ws.getDef(); assertThat(definition.key()).isEqualTo("list"); assertThat(definition.isPost()).isFalse(); assertThat(definition.since()).isEqualTo("6.3"); assertThat(definition.responseExampleAsString()).isNotEmpty(); assertThat(definition.params()).hasSize(1); WebService.Param loginParam = definition.param("login"); assertThat(loginParam.since()).isEqualTo("6.4"); assertThat(loginParam.isRequired()).isFalse(); }
@Test public void test_definition() { WebService.Action webService = ws.getDef(); assertThat(webService.key()).isEqualTo("identity_providers"); assertThat(webService.responseExampleAsString()).isNotEmpty(); assertThat(webService.since()).isEqualTo("5.5"); assertThat(webService.isInternal()).isTrue(); }
@Test public void test_example() { when(pluginRepository.getPluginInfos()).thenReturn(asList( new PluginInfo("findbugs").setName("Findbugs").setVersion(Version.create("2.1")), new PluginInfo("l10nfr").setName("French Pack").setVersion(Version.create("1.10")), new PluginInfo("jira").setName("JIRA").setVersion(Version.create("1.2")))); String result = ws.newRequest().execute().getInput(); assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void test_example() { UserDto user = db.users().insertUser(u -> u .setLogin("ada.lovelace") .setEmail("ada.lovelace@noteg.com") .setName("Ada Lovelace") .setLocal(true) .setScmAccounts(singletonList("al"))); logInAsSystemAdministrator(); String json = deactivate(user.getLogin()).getInput(); assertJson(json).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void json_example() { OrganizationDto organization = db.organizations().insert(); db.users().insertDefaultGroup(organization, "default"); UserDto user = db.users().insertUser(u -> u.setLogin("ada.lovelace").setName("Ada Lovelace").setEmail("ada@lovelace.com")); String result = ws.newRequest().setParam(PARAM_ORGANIZATION, organization.getKey()).setParam("login", user.getLogin()).execute().getInput(); assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void definition() { WebService.Action definition = ws.getDef(); assertThat(definition).isNotNull(); assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isTrue(); assertThat(definition.params()).hasSize(2).extracting("key").containsOnly( "leftKey", "rightKey"); assertThat(definition.responseExampleAsString()).isNotEmpty(); }
@Test public void test_definition() { WsActionTester ws = new WsActionTester(new WorkerCountAction(userSession, workerCountProvider)); WebService.Action action = ws.getDef(); assertThat(action.key()).isEqualTo("worker_count"); assertThat(action.since()).isEqualTo("6.5"); assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).isEmpty(); }
@Test public void define_exporters_action() { WebService.Action exporters = ws.getDef(); assertThat(exporters).isNotNull(); assertThat(exporters.isPost()).isFalse(); assertThat(exporters.params()).isEmpty(); assertThat(exporters.responseExampleAsString()).isNotEmpty(); }
@Test public void json_example() { String result = ws.newRequest().execute().getInput(); assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void define_index_action() { WebService.Action action = ws.getDef(); assertThat(action).isNotNull(); assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).hasSize(8); }
@Test public void test_example_of_response() { userSession.logIn().setSystemAdministrator(); when(ceQueue.getWorkersPauseStatus()).thenReturn(CeQueue.WorkersPauseStatus.PAUSING); ws.newRequest().execute().assertJson(ws.getDef().responseExampleAsString()); }
@Test public void test_response_example() { logInAsRoot(); UserDto user = UserTesting.newUserDto().setLogin("daniel").setName("Daniel").setEmail("daniel@corp.com"); UserDto rootDto = userDao.insert(dbSession, user); userDao.setRoot(dbSession, rootDto.getLogin(), true); dbSession.commit(); TestResponse response = wsTester.newRequest().setMediaType(MediaTypes.JSON).execute(); assertJson(response.getInput()).isSimilarTo(wsTester.getDef().responseExampleAsString()); }
@Test public void response_example() { MetricWs metricWs = new MetricWs(); metricWs.define(context); WebService.Action action = context.controller("api/metric").action("create"); assertThat(action.responseExampleFormat()).isEqualTo("txt"); assertThat(action.responseExample()).isNotNull(); assertThat(StringUtils.trim(action.responseExampleAsString())).isEqualTo("example of WS response"); }
@Test public void definition() { WebService.Action definition = ws.getDef(); assertThat(definition.key()).isEqualTo("encrypt"); assertThat(definition.isPost()).isFalse(); assertThat(definition.isInternal()).isTrue(); assertThat(definition.responseExampleAsString()).isNotEmpty(); assertThat(definition.params()).hasSize(1); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("add_comment"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(2); assertThat(action.responseExampleAsString()).isNotEmpty(); }
@Test public void test_definition() { WebService.Action def = ws.getDef(); assertThat(def.key()).isEqualTo("pause"); assertThat(def.isInternal()).isTrue(); assertThat(def.isPost()).isTrue(); assertThat(def.params()).isEmpty(); assertThat(def.responseExampleAsString()).isNull(); }
@Test public void importers_nominal() { String result = ws.newRequest().execute().getInput(); assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void json_example() { ComponentDto project = db.components().insertPrivateProject(); permissionIndexer.allowOnlyAnyone(project); RuleDefinitionDto rule = db.rules().insert(); db.issues().insert(rule, project, project, issue -> issue.setAuthorLogin("luke.skywalker")); db.issues().insert(rule, project, project, issue -> issue.setAuthorLogin("leia.organa")); issueIndexer.indexOnStartup(emptySet()); userSession.logIn().addMembership(db.getDefaultOrganization()); String result = ws.newRequest().execute().getInput(); assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString()); }
@Test public void ws_parameters() { WebService.Action definition = ws.getDef(); assertThat(definition.isPost()).isTrue(); assertThat(definition.key()).isEqualTo("create_event"); assertThat(definition.responseExampleAsString()).isNotEmpty(); }