use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class MetadataImportImportStrategyTests method shouldUpdateMetadataByIdentifier.
@ValueSource(strings = { "CODE", "UID" })
@ParameterizedTest
public void shouldUpdateMetadataByIdentifier(String identifier) throws IOException {
JsonObject ob = new JsonFileReader(new File("src/test/resources/setup/metadata.json")).get(JsonObject.class);
ApiResponse response = metadataActions.importMetadata(ob, "identifier=" + identifier);
response.validate().statusCode(200).body("stats.updated", equalTo(response.extract("stats.total")));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TeiImportTests method shouldImportTeiWithAttributes.
@Test
public void shouldImportTeiWithAttributes() throws Exception {
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/tei.json"));
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(teiBody);
// assert
response.validateSuccessfulImport().validateTeis().body("stats.created", equalTo(1)).body("objectReports", notNullValue()).body("objectReports[0].errorReports", empty());
// assert that the TEI was imported
String teiId = response.extractImportedTeis().get(0);
ApiResponse teiResponse = trackerActions.getTrackedEntity(teiId);
teiResponse.validate().statusCode(200);
assertThat(teiResponse.getBody(), matchesJSON(teiBody.get("trackedEntities").getAsJsonArray().get(0)));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TeiImportTests method shouldImportTeisWithEnrollmentsEventsAndRelationship.
@Test
public void shouldImportTeisWithEnrollmentsEventsAndRelationship() throws Exception {
// the file contains 2 teis with 1 enrollment and 1 event each
JsonObject teiPayload = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/teisWithEnrollmentsAndEvents.json"));
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(teiPayload);
response.validateSuccessfulImport().validate().body("stats.created", equalTo(7)).rootPath("bundleReport.typeReportMap").body("TRACKED_ENTITY.objectReports", hasSize(2)).body("ENROLLMENT.objectReports", hasSize(2)).body("EVENT.objectReports", hasSize(2)).body("RELATIONSHIP.objectReports", hasSize(1));
JsonObject teiBody = teiPayload.get("trackedEntities").getAsJsonArray().get(0).getAsJsonObject();
ApiResponse trackedEntityResponse = trackerActions.getTrackedEntity(teiBody.get("trackedEntity").getAsString() + "?fields=*").validateStatus(200);
assertThat(trackedEntityResponse.getBody(), matchesJSON(teiBody));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TeiImportTests method shouldImportTeiAndEnrollmentWithAttributes.
@Test
public void shouldImportTeiAndEnrollmentWithAttributes() throws Exception {
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/teiWithEnrollmentAndAttributes.json"));
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(teiBody);
// assert
response.validateSuccessfulImport().validate().body("stats.created", equalTo(2)).rootPath("bundleReport.typeReportMap").body("TRACKED_ENTITY.objectReports", hasSize(1)).body("ENROLLMENT.objectReports", hasSize(1));
// assert that the TEI was imported
String teiId = response.extractImportedTeis().get(0);
ApiResponse teiResponse = trackerActions.getTrackedEntity(teiId);
teiResponse.validate().statusCode(200);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class PotentialDuplicatesTests method shouldFilterByStatus.
@ParameterizedTest
@ValueSource(strings = { "OPEN", "INVALID", "MERGED" })
public void shouldFilterByStatus(String status) {
String teiA = createTei();
String teiB = createTei();
potentialDuplicatesActions.createPotentialDuplicate(teiA, teiB, status).validate().statusCode(200);
ApiResponse response = potentialDuplicatesActions.get("", new QueryParamsBuilder().add("status=" + status));
response.validate().body("identifiableObjects", hasSize(greaterThanOrEqualTo(1))).body("identifiableObjects.status", everyItem(equalTo(status)));
}
Aggregations