@Test(expected = TokenErrorException.class) public void testApiErrorGettingToken() throws IOException, MediaWikiApiErrorException { MockBasicApiConnection con = new MockBasicApiConnection(); Map<String, String> params = new HashMap<>(); params.put("action", "query"); params.put("meta", "tokens"); params.put("type", "csrf"); params.put("format", "json"); con.setWebResourceFromPath(params, this.getClass(), "/error-badtoken.json", CompressionType.NONE); params.clear(); params.put("action", "wbeditentity"); params.put("id", "Q42"); params.put("token", null); params.put("format", "json"); params.put("data", "{}"); params.put("maxlag", "5"); con.setWebResourceFromPath(params, this.getClass(), "/error-badtoken.json", CompressionType.NONE); WbEditingAction weea = new WbEditingAction(con, Datamodel.SITE_WIKIDATA); weea.wbEditEntity("Q42", null, null, null, "{}", false, false, 0, null, null); }
public EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException { Validate.notNull(data, "Data parameter cannot be null when editing entity data"); Map<String, String> parameters = new HashMap<>(); parameters.put("data", data); if (clear) { parameters.put("clear", ""); } JsonNode response = performAPIAction("wbeditentity", id, site, title, newEntity, parameters, summary, tags, baserevid, bot); return getEntityDocumentFromResponse(response); }
WbEditingAction { public EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException { Validate.notNull(data, "Data parameter cannot be null when editing entity data"); Map<String, String> parameters = new HashMap<>(); parameters.put("data", data); if (clear) { parameters.put("clear", ""); } JsonNode response = performAPIAction("wbeditentity", id, site, title, newEntity, parameters, summary, tags, baserevid, bot); return getEntityDocumentFromResponse(response); } }
WbEditingAction { public EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException { Validate.notNull(data, "Data parameter cannot be null when editing entity data"); Map<String, String> parameters = new HashMap<>(); parameters.put("data", data); if (clear) { parameters.put("clear", ""); } JsonNode response = performAPIAction("wbeditentity", id, site, title, newEntity, parameters, summary, tags, baserevid, bot); return getEntityDocumentFromResponse(response); } WbEditingAction(ApiConnection connection, String siteIri); }
WbEditingAction { public EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException { Validate.notNull(data, "Data parameter cannot be null when editing entity data"); Map<String, String> parameters = new HashMap<>(); parameters.put("data", data); if (clear) { parameters.put("clear", ""); } JsonNode response = performAPIAction("wbeditentity", id, site, title, newEntity, parameters, summary, tags, baserevid, bot); return getEntityDocumentFromResponse(response); } WbEditingAction(ApiConnection connection, String siteIri); int getMaxLag(); void setMaxLag(int maxLag); int getRemainingEdits(); void setRemainingEdits(int remainingEdits); int getAverageTimePerEdit(); void setAverageTimePerEdit(int milliseconds); EntityDocument wbEditEntity(String id, String site, String title,
			String newEntity, String data, boolean clear, boolean bot,
			long baserevid, String summary, List<String> tags); JsonNode wbSetLabel(String id, String site, String title,
			String newEntity, String language, String value,
			boolean bot, long baserevid, String summary, List<String> tags); JsonNode wbSetDescription(String id, String site, String title,
			String newEntity, String language, String value,
			boolean bot, long baserevid, String summary,
			List<String> tags); JsonNode wbSetAliases(String id, String site, String title,
			String newEntity, String language, List<String> add,
			List<String> remove, List<String> set,
			boolean bot, long baserevid, String summary,
			List<String> tags); JsonNode wbSetClaim(String statement,
			boolean bot, long baserevid, String summary, List<String> tags); JsonNode wbRemoveClaims(List<String> statementIds,
			boolean bot, long baserevid, String summary, List<String> tags); int getMaxLagMaxRetries(); void setMaxLagMaxRetries(int retries); int getMaxLagFirstWaitTime(); void setMaxLagFirstWaitTime(int time); double getMaxLagBackOffFactor(); void setMaxLagBackOffFactor(double value); double getCurrentLag(); }
WbEditingAction { public EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException { Validate.notNull(data, "Data parameter cannot be null when editing entity data"); Map<String, String> parameters = new HashMap<>(); parameters.put("data", data); if (clear) { parameters.put("clear", ""); } JsonNode response = performAPIAction("wbeditentity", id, site, title, newEntity, parameters, summary, tags, baserevid, bot); return getEntityDocumentFromResponse(response); } WbEditingAction(ApiConnection connection, String siteIri); int getMaxLag(); void setMaxLag(int maxLag); int getRemainingEdits(); void setRemainingEdits(int remainingEdits); int getAverageTimePerEdit(); void setAverageTimePerEdit(int milliseconds); EntityDocument wbEditEntity(String id, String site, String title,
			String newEntity, String data, boolean clear, boolean bot,
			long baserevid, String summary, List<String> tags); JsonNode wbSetLabel(String id, String site, String title,
			String newEntity, String language, String value,
			boolean bot, long baserevid, String summary, List<String> tags); JsonNode wbSetDescription(String id, String site, String title,
			String newEntity, String language, String value,
			boolean bot, long baserevid, String summary,
			List<String> tags); JsonNode wbSetAliases(String id, String site, String title,
			String newEntity, String language, List<String> add,
			List<String> remove, List<String> set,
			boolean bot, long baserevid, String summary,
			List<String> tags); JsonNode wbSetClaim(String statement,
			boolean bot, long baserevid, String summary, List<String> tags); JsonNode wbRemoveClaims(List<String> statementIds,
			boolean bot, long baserevid, String summary, List<String> tags); int getMaxLagMaxRetries(); void setMaxLagMaxRetries(int retries); int getMaxLagFirstWaitTime(); void setMaxLagFirstWaitTime(int time); double getMaxLagBackOffFactor(); void setMaxLagBackOffFactor(double value); double getCurrentLag();  }