use of com.b2international.snowowl.snomed.cis.SnomedIdentifier 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.SnomedIdentifier 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.SnomedIdentifier in project snow-owl by b2ihealthcare.
the class SnomedIdentifierTest method whenCreatingRelationshipIdentifierInShortFormat_ThenItShouldBeCreated.
@Test
public void whenCreatingRelationshipIdentifierInShortFormat_ThenItShouldBeCreated() throws Exception {
final SnomedIdentifier id = SnomedIdentifiers.create("9940000001029");
assertEquals(9940000001L, id.getItemId());
assertEquals("", id.getNamespace());
assertEquals(0, id.getFormatIdentifier());
assertEquals(2, id.getComponentIdentifier());
assertEquals(9, id.getCheckDigit());
assertEquals(ComponentCategory.RELATIONSHIP, id.getComponentCategory());
}
use of com.b2international.snowowl.snomed.cis.SnomedIdentifier in project snow-owl by b2ihealthcare.
the class SnomedIdentifierTest method whenCreatingLongestConceptIdentifierInShortFormat_ThenItShouldBeCreated.
@Test
public void whenCreatingLongestConceptIdentifierInShortFormat_ThenItShouldBeCreated() throws Exception {
final SnomedIdentifier id = SnomedIdentifiers.create(Concepts.DEFINITION_STATUS_ROOT);
assertEquals(900000000000444L, id.getItemId());
assertEquals("", id.getNamespace());
assertEquals(0, id.getFormatIdentifier());
assertEquals(0, id.getComponentIdentifier());
assertEquals(6, id.getCheckDigit());
assertEquals(ComponentCategory.CONCEPT, id.getComponentCategory());
}
use of com.b2international.snowowl.snomed.cis.SnomedIdentifier in project snow-owl by b2ihealthcare.
the class SnomedIdentifierTest method whenCreatingDescriptionIdentifierInLongFormat_ThenItShouldBeCreated.
@Test
public void whenCreatingDescriptionIdentifierInLongFormat_ThenItShouldBeCreated() throws Exception {
final SnomedIdentifier id = SnomedIdentifiers.create("1290000001117");
assertEquals(129L, id.getItemId());
assertEquals("0000001", id.getNamespace());
assertEquals(1, id.getFormatIdentifier());
assertEquals(1, id.getComponentIdentifier());
assertEquals(7, id.getCheckDigit());
assertEquals(ComponentCategory.DESCRIPTION, id.getComponentCategory());
}
Aggregations