use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.
the class ReservationImplTest method whenReservingRangeOfIDs_ThenItShouldConflictWithAllIDsInThatRangeIncludingBoundaries.
@Test
public void whenReservingRangeOfIDs_ThenItShouldConflictWithAllIDsInThatRangeIncludingBoundaries() throws Exception {
final Index store = Indexes.createIndex(UUID.randomUUID().toString(), new ObjectMapper(), new Mappings(SctId.class));
store.admin().create();
final ISnomedIdentifierService identifierService = new DefaultSnomedIdentifierService(store, new ItemIdGenerationStrategy() {
int counter = 200;
@Override
public Set<String> generateItemIds(String namespace, ComponentCategory category, int quantity, int attempt) {
return IntStream.range(counter, counter + quantity).mapToObj(String::valueOf).collect(Collectors.toSet());
}
}, new SnomedIdentifierReservationServiceImpl(), new SnomedIdentifierConfiguration());
final Set<ComponentCategory> components = Collections.singleton(ComponentCategory.CONCEPT);
final Reservation range = Reservations.range(200, 300, "", components);
final Set<String> componentIds = identifierService.generate(null, ComponentCategory.CONCEPT, 300 - 200 + 1);
for (String id : componentIds) {
final SnomedIdentifier identifier = SnomedIdentifiers.create(id);
assertTrue(range.includes(identifier));
}
store.admin().delete();
}
use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.
the class ReservationImplTest method whenReservingSingleID_ThenItShouldConflictWithThatIDOnly.
@Test
public void whenReservingSingleID_ThenItShouldConflictWithThatIDOnly() throws Exception {
final Reservation single = Reservations.single(Concepts.ROOT_CONCEPT);
assertTrue(single.includes(SnomedIdentifiers.create(Concepts.ROOT_CONCEPT)));
assertFalse(single.includes(SnomedIdentifiers.create(Concepts.FULLY_DEFINED)));
assertFalse(single.includes(SnomedIdentifiers.create(Concepts.ADDITIONAL_RELATIONSHIP)));
}
use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.
the class SnomedIdSetReservationTest method testIdSetReservationReservedIds.
@Test
public void testIdSetReservationReservedIds() {
final Reservation idSetReservation = Reservations.idSetReservation(Sets.newHashSet(Concepts.MODULE_ROOT, Concepts.MODULE_SCT_CORE));
final SnomedIdentifier rootIdentifier = SnomedIdentifiers.create(Concepts.ROOT_CONCEPT);
final SnomedIdentifier sctCoreIdentifier = SnomedIdentifiers.create(Concepts.MODULE_SCT_CORE);
final Set<SnomedIdentifier> reservedIds = idSetReservation.intersection(Sets.newHashSet(rootIdentifier, sctCoreIdentifier));
assertThat(reservedIds).containsOnly(sctCoreIdentifier);
}
use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.
the class SnomedIdentifierReservationServiceImplTest method whenCreatingMoreThanOneReservation_ThenServiceMustStoreThem.
@Test
public void whenCreatingMoreThanOneReservation_ThenServiceMustStoreThem() throws Exception {
final Reservation single = Reservations.single(Concepts.ROOT_CONCEPT);
final Reservation range = Reservations.range(100, 200, null, Collections.singleton(ComponentCategory.CONCEPT));
this.reservationService.create(SINGLE_RESERVATION, single);
this.reservationService.create(RANGE_RESERVATION, range);
assertThat(this.reservationService.getReservations()).contains(single, range);
}
use of com.b2international.snowowl.snomed.cis.reservations.Reservation in project snow-owl by b2ihealthcare.
the class SnomedIdentifierReservationServiceImplTest method whenCreatingSingleIDReservation_ThenReturnIsReservedTrueForThatID.
@Test
public void whenCreatingSingleIDReservation_ThenReturnIsReservedTrueForThatID() throws Exception {
final Reservation single = Reservations.single(Concepts.ROOT_CONCEPT);
this.reservationService.create(SINGLE_RESERVATION, single);
assertThat(this.reservationService.isReserved(Concepts.ROOT_CONCEPT)).isTrue();
}
Aggregations