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();  }
@Test(expected = IOException.class) public void testOffineErrors() throws IOException, MediaWikiApiErrorException { MockBasicApiConnection con = new MockBasicApiConnection(); WbEditingAction weea = new WbEditingAction(con, Datamodel.SITE_WIKIDATA); EntityDocument result = weea.wbEditEntity("Q42", null, null, null, "{}", true, false, 0, null, null); assertNull(result); }
@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); }
@Test(expected = TokenErrorException.class) public void testNoTokenInReponse() throws IOException, MediaWikiApiErrorException { MockBasicApiConnection con = new MockBasicApiConnection(); Map<String, String> params = new HashMap<>(); params.put("action", "query"); params.put("meta", "tokens"); params.put("format", "json"); params.put("type", "csrf"); con.setWebResource(params, "{}"); 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); }
@Test(expected = IllegalArgumentException.class) public void testIdAndSite() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity("Q1234", "enwiki", null, null, "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testIdAndTitle() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity("Q1234", null, "Title", null, "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testTitleNoSite() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity(null, null, "Title", null, "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testNewAndId() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity("Q1234", null, null, "item", "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testNewAndSite() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity(null, "enwiki", null, "item", "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testNewAndTitle() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity(null, null, "Title", "item", "{}", false, false, 0, null, null); }
@Test(expected = IllegalArgumentException.class) public void testNoTask() throws IOException, MediaWikiApiErrorException { WbEditingAction weea = new WbEditingAction( new MockBasicApiConnection(), Datamodel.SITE_WIKIDATA); weea.wbEditEntity(null, null, null, null, "{}", false, false, 0, null, null); }