use of org.hisp.dhis.reservedvalue.ReservedValue in project dhis2-core by dhis2.
the class HibernateReservedValueStoreTest method getIfReservedValuesReturnsReservedValue.
@Test
void getIfReservedValuesReturnsReservedValue() {
ReservedValue rv = reservedValue.value(prog001).build();
reservedValueStore.save(rv);
List<ReservedValue> res = reservedValueStore.getAvailableValues(rv, Lists.newArrayList(rv.getValue()), rv.getOwnerObject());
assertEquals(rv, res.get(0));
assertEquals(1, res.size());
}
use of org.hisp.dhis.reservedvalue.ReservedValue in project dhis2-core by dhis2.
the class HibernateReservedValueStoreTest method reserveValuesMultipleValues.
@Test
void reserveValuesMultipleValues() {
ReservedValue rv = reservedValue.value(prog001).build();
reservedValueStore.save(rv);
int count = reservedValueStore.getCount();
ArrayList<String> values = new ArrayList<>();
int n = 10;
for (int i = 0; i < n; i++) {
values.add(String.format("%03d", counter++));
}
List<ReservedValue> res = reservedValueStore.reserveValuesJpa(getFreeReservedValue(), values);
assertEquals(n, res.size());
assertEquals((count + n), reservedValueStore.getCount());
}
use of org.hisp.dhis.reservedvalue.ReservedValue in project dhis2-core by dhis2.
the class HibernateReservedValueStoreTest method shouldNotAddAlreadyReservedValues.
@Test
void shouldNotAddAlreadyReservedValues() {
ReservedValue rv = reservedValue.value(prog001).build();
reservedValueStore.save(rv);
OrganisationUnit ou = createOrganisationUnit("OU");
organisationUnitStore.save(ou);
TrackedEntityInstance tei = createTrackedEntityInstance(ou);
trackedEntityInstanceStore.save(tei);
TrackedEntityAttribute tea = createTrackedEntityAttribute('Y');
tea.setUid(teaUid);
trackedEntityAttributeStore.save(tea);
TrackedEntityAttributeValue teav = createTrackedEntityAttributeValue('Z', tei, tea);
teav.setValue(prog001);
trackedEntityAttributeValueStore.save(teav);
assertEquals(1, reservedValueStore.getCount());
}
use of org.hisp.dhis.reservedvalue.ReservedValue in project dhis2-core by dhis2.
the class HibernateReservedValueStoreTest method removeExpiredReservationsDoesNotRemoveAnythingIfNothingHasExpired.
@Test
void removeExpiredReservationsDoesNotRemoveAnythingIfNothingHasExpired() {
ReservedValue rv = reservedValue.value(prog001).build();
reservedValueStore.save(rv);
int num = reservedValueStore.getCount();
reservedValueStore.removeUsedOrExpiredReservations();
assertEquals(num, reservedValueStore.getCount());
}
Aggregations