use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class ImportStrategyTests method shouldDeleteWithDeleteStrategy.
@ParameterizedTest
@ValueSource(strings = { "src/test/resources/tracker/importer/teis/teisWithEnrollmentsAndEvents.json", "src/test/resources/tracker/importer/teis/teiAndEnrollment.json", "src/test/resources/tracker/importer/teis/teis.json", "src/test/resources/tracker/importer/events/events.json" })
public void shouldDeleteWithDeleteStrategy(String fileName) throws Exception {
// arrange
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File(fileName));
trackerActions.postAndGetJobReport(teiBody).validateSuccessfulImport();
teiBody = new FileReaderUtils().readJsonAndGenerateData(new File(fileName));
// act
ApiResponse response = trackerActions.postAndGetJobReport(teiBody, new QueryParamsBuilder().add("importStrategy=DELETE"));
// assert
response.validate().statusCode(200).body("status", equalTo("OK")).body("stats.deleted", Matchers.greaterThanOrEqualTo(1));
}
use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class TrackedEntityInstanceAclReadTests method testUserDataAndOrgUnitScopeReadAccess.
@ParameterizedTest
@ValueSource(strings = { "O2PajOxjJSa", "aDy67f9ijOe", "CKrrGm5Be8O", "Lpa5INiC3Qf", "GTqb3WOZMop" })
public void testUserDataAndOrgUnitScopeReadAccess(String userUid) {
User user = users.stream().filter(_user -> _user.getUid().equals(userUid)).findFirst().orElseThrow(() -> new RuntimeException("User UID not found for test"));
new LoginActions().loginAsUser(user.getUsername(), user.getPassword());
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll("filter=pyNnf3UaOOg:NE:zz", "trackedEntityType=YDzXLdCvV4h", "ouMode=ACCESSIBLE", "fields=*");
ApiResponse response = teiActions.get("/", queryParamsBuilder);
response.validate().statusCode(200);
response.validate().body("trackedEntityInstances", Matchers.not(Matchers.emptyArray()));
JsonObject json = response.getBody();
json.getAsJsonArray("trackedEntityInstances").iterator().forEachRemaining((teiJson) -> assertTrackedEntityInstance(user, teiJson.getAsJsonObject()));
}
use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class SideEffectsTests method shouldSendNotificationIfNotSkipSideEffects.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldSendNotificationIfNotSkipSideEffects(Boolean shouldSkipSideEffects) {
JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, trackerProgramStageId, "COMPLETED");
ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
int size = response.getBody().getAsJsonArray("messageConversations").size();
trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("skipSideEffects=" + shouldSkipSideEffects)).validateSuccessfulImport();
int expectedCount = (shouldSkipSideEffects) ? size : size + 1;
response = messageConversationsActions.waitForNotification(expectedCount);
response.validate().statusCode(200).body("messageConversations", hasSize(expectedCount));
if (shouldSkipSideEffects) {
return;
}
response.validate().body("messageConversations.subject", hasItem("TA program stage completion"));
}
use of org.junit.jupiter.params.provider.ValueSource 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.junit.jupiter.params.provider.ValueSource 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