String[] languages = Locale.getISOLanguages();
final String languageId = languages[random.nextInt(languages.length)];
createPageIfDoesntExist(TestConstants.TEST_SPACE_NAME, TestConstants.TRANSLATIONS_PAGE_NAME, "Translations");
Page page = objectFactory.createPage();
page.setContent(languageId);
PutMethod putMethod =
executePutXml(getUriBuilder(PageTranslationResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
TestConstants.TRANSLATIONS_PAGE_NAME, languageId).toString(), page, "Admin", "admin");
Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_CREATED, putMethod.getStatusCode());
GetMethod getMethod =
executeGet(getUriBuilder(PageTranslationResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
TestConstants.TRANSLATIONS_PAGE_NAME, languageId).toString());
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Page modifiedPage = (Page) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Assert.assertEquals(languageId, modifiedPage.getLanguage());
Assert.assertEquals(languageId, modifiedPage.getLanguage());
}