Search in sources :

Example 1 with OrgUnit

use of org.hisp.dhis.dto.OrgUnit in project dhis2-core by dhis2.

the class OrgUnitsTest method shouldAddWithoutLevel.

@Test
public void shouldAddWithoutLevel() {
    OrgUnit orgUnit = orgUnitActions.generateDummy();
    orgUnit.setLevel(null);
    ApiResponse response = orgUnitActions.post(orgUnit);
    ResponseValidationHelper.validateObjectCreation(response);
    String uid = response.extractUid();
    assertNotNull(uid, "Org unit id was not returned.");
    response = orgUnitActions.get(uid);
    // todo create validation helper to check the similarity.
    response.validate().statusCode(200).body("shortName", equalTo(orgUnit.getShortName())).body("name", equalTo(orgUnit.getName())).body("openingDate", equalTo(orgUnit.getOpeningDate()));
}
Also used : OrgUnit(org.hisp.dhis.dto.OrgUnit) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 2 with OrgUnit

use of org.hisp.dhis.dto.OrgUnit in project dhis2-core by dhis2.

the class OrgUnitActions method generateDummy.

public OrgUnit generateDummy() {
    String randomString = DataGenerator.randomString();
    OrgUnit orgUnit = new OrgUnit();
    orgUnit.setName("AutoTest OrgUnit" + randomString);
    orgUnit.setShortName("AutoTest orgUnit short name " + randomString);
    orgUnit.setOpeningDate("2017-09-11T00:00:00.000");
    return orgUnit;
}
Also used : OrgUnit(org.hisp.dhis.dto.OrgUnit)

Example 3 with OrgUnit

use of org.hisp.dhis.dto.OrgUnit in project dhis2-core by dhis2.

the class OrgUnitActions method createOrgUnitWithParent.

public String createOrgUnitWithParent(String parentId) {
    OrgUnit orgUnit = generateDummy();
    orgUnit.setParent(parentId);
    return create(orgUnit);
}
Also used : OrgUnit(org.hisp.dhis.dto.OrgUnit)

Example 4 with OrgUnit

use of org.hisp.dhis.dto.OrgUnit in project dhis2-core by dhis2.

the class OrgUnitActions method createOrgUnit.

public String createOrgUnit(int level) {
    OrgUnit orgUnit = generateDummy();
    orgUnit.setLevel(level);
    return create(orgUnit);
}
Also used : OrgUnit(org.hisp.dhis.dto.OrgUnit)

Example 5 with OrgUnit

use of org.hisp.dhis.dto.OrgUnit in project dhis2-core by dhis2.

the class EventImportIdSchemeTests method setupData.

private void setupData() {
    ATTRIBUTE_ID = attributeActions.createUniqueAttribute("TEXT", "organisationUnit", "program");
    // programAttributeId = attributeActions.createUniqueAttribute(
    // "program", "TEXT" );
    assertNotNull(ATTRIBUTE_ID, "Failed to setup attribute");
    OrgUnit orgUnit = orgUnitActions.generateDummy();
    orgUnit.setCode(OU_CODE);
    orgUnit.setName(OU_NAME);
    orgUnitId = orgUnitActions.create(orgUnit);
    assertNotNull(orgUnitId, "Failed to setup org unit");
    programActions.addOrganisationUnits(PROGRAM_ID, orgUnitId).validate().statusCode(200);
    orgUnitActions.update(orgUnitId, addAttributeValuePayload(orgUnitActions.get(orgUnitId).getBody(), ATTRIBUTE_ID, ATTRIBUTE_VALUE)).validate().statusCode(200);
    programActions.update(PROGRAM_ID, addAttributeValuePayload(programActions.get(PROGRAM_ID).getBody(), ATTRIBUTE_ID, ATTRIBUTE_VALUE)).validate().statusCode(200);
}
Also used : OrgUnit(org.hisp.dhis.dto.OrgUnit)

Aggregations

OrgUnit (org.hisp.dhis.dto.OrgUnit)8 ApiResponse (org.hisp.dhis.dto.ApiResponse)3 ApiTest (org.hisp.dhis.ApiTest)2 Test (org.junit.jupiter.api.Test)2 LoginActions (org.hisp.dhis.actions.LoginActions)1 RestApiActions (org.hisp.dhis.actions.RestApiActions)1 Me (org.hisp.dhis.dto.Me)1 UserGroup (org.hisp.dhis.dto.UserGroup)1