Search in sources :

Example 1 with JsonTranslation

use of org.hisp.dhis.webapi.json.domain.JsonTranslation in project dhis2-core by dhis2.

the class AbstractCrudControllerTest method replaceTranslationsOk.

@Test
public void replaceTranslationsOk() {
    String id = assertStatus(HttpStatus.CREATED, POST("/dataSets/", "{'name':'My data set', 'periodType':'Monthly'}"));
    JsonArray translations = GET("/dataSets/{id}/translations", id).content().getArray("translations");
    assertTrue(translations.isEmpty());
    PUT("/dataSets/" + id + "/translations", "{'translations': [{'locale':'sv', 'property':'name', 'value':'name sv'}]}").content(HttpStatus.NO_CONTENT);
    JsonResponse content = GET("/dataSets/{id}", id).content();
    translations = GET("/dataSets/{id}/translations", id).content().getArray("translations");
    assertEquals(1, translations.size());
    JsonTranslation translation = translations.get(0, JsonTranslation.class);
    assertEquals("sv", translation.getLocale());
    assertEquals("name", translation.getProperty());
    assertEquals("name sv", translation.getValue());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonResponse(org.hisp.dhis.jsontree.JsonResponse) JsonTranslation(org.hisp.dhis.webapi.json.domain.JsonTranslation) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonArray (org.hisp.dhis.jsontree.JsonArray)1 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)1 JsonTranslation (org.hisp.dhis.webapi.json.domain.JsonTranslation)1 Test (org.junit.jupiter.api.Test)1