@Test(expected = TagsApplyNotAllowedException.class)
public void testApplyInvalidTag() throws MediaWikiApiErrorException, IOException {

	WikibaseDataEditor wde = new WikibaseDataEditor(this.con,
			Datamodel.SITE_WIKIDATA);
	ItemIdValue id = Datamodel.makeWikidataItemIdValue("Q1234");
	Statement s1 = StatementBuilder.forSubjectAndProperty(id, P31)
			.withValue(Q5).withId("ID-s1").build();
	MonolingualTextValue description = Datamodel.makeMonolingualTextValue("My description", "en");
	ItemDocument itemDocument = ItemDocumentBuilder.forItemId(id)
			.withStatement(s1)
			.withRevisionId(1234)
			.build();
	Map<String, String> params = new HashMap<>();
	params.put("action", "wbsetdescription");
	params.put("id", "Q1234");
	params.put("summary", "testing tags");
	params.put("tags", "tag_which_does_not_exist");
	params.put("token", "42307b93c79b0cb558d2dfb4c3c92e0955e06041+\\");
	params.put("format", "json");
	params.put("baserevid", "1234");
	params.put("maxlag", "5");
	params.put("language", "en");
	params.put("value", "My description");
	String expectedResult = "{\"error\":"
			+ "{\"code\":\"tags-apply-not-allowed-one\","
			+ "\"info\":\"The tag \\\"tag_which_does_not_exist\\\" is not allowed to be manually applied.\","
			+ "\"*\":\"See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.\"},"
			+ "\"servedby\":\"mw1276\"}";
	con.setWebResource(params, expectedResult);
	wde.updateTermsStatements(itemDocument, Collections.<MonolingualTextValue>emptyList(),
			Collections.singletonList(description),	Collections.<MonolingualTextValue>emptyList(),
			Collections.<MonolingualTextValue>emptyList(), Collections.<Statement>emptyList(),
			Collections.<Statement>emptyList(), "testing tags", Collections.singletonList("tag_which_does_not_exist"));
}