use of com.b2international.snowowl.snomed.cis.ISnomedIdentifierService in project snow-owl by b2ihealthcare.
the class DefaultSnomedIdentifierServiceRegressionTest method issue_SO_2138_testCoveringReservedRanges.
@Test(expected = IllegalArgumentException.class)
public void issue_SO_2138_testCoveringReservedRanges() throws Exception {
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
reservationService.create("nothingAboveOneHundredNinetyNine", Reservations.range(200L, 8999_9999_9999_999L, null, ImmutableSet.of(ComponentCategory.CONCEPT)));
reservationService.create("nothingBelowOneHundredNinetyNine", Reservations.range(100L, 198L, null, ImmutableSet.of(ComponentCategory.CONCEPT)));
final ItemIdGenerationStrategy idGenerationStrategy = new SequentialItemIdGenerationStrategy(reservationService);
final ISnomedIdentifierService identifiers = new DefaultSnomedIdentifierService(store, idGenerationStrategy, reservationService, new SnomedIdentifierConfiguration());
identifiers.register(ImmutableSet.of("198007"));
assertEquals("199004", Iterables.getOnlyElement(identifiers.generate(INT_NAMESPACE, ComponentCategory.CONCEPT, 1)));
// This attempt should not be able to generate any other value
System.err.println(identifiers.generate(INT_NAMESPACE, ComponentCategory.CONCEPT, 1));
}
use of com.b2international.snowowl.snomed.cis.ISnomedIdentifierService in project snow-owl by b2ihealthcare.
the class DefaultSnomedIdentifierServiceRegressionTest method issue_SO_2138_testItemIdWraparound.
@Test
public void issue_SO_2138_testItemIdWraparound() throws Exception {
final ISnomedIdentifierReservationService reservationService = new SnomedIdentifierReservationServiceImpl();
final SequentialItemIdGenerationStrategy idGenerationStrategy = new SequentialItemIdGenerationStrategy(reservationService);
idGenerationStrategy.getOrCreateCounter(INT_NAMESPACE, ComponentCategory.CONCEPT).setCounter(999999999999999L);
final ISnomedIdentifierService identifiers = new DefaultSnomedIdentifierService(store, idGenerationStrategy, reservationService, new SnomedIdentifierConfiguration());
// Register a few existing SCTIDs to see if sorting works
identifiers.register(ImmutableSet.of("999999999999997008", "999999999999998003", "100005", "101009"));
List<String> actualIds = ImmutableList.copyOf(identifiers.generate(INT_NAMESPACE, ComponentCategory.CONCEPT, 2));
List<String> expectedIds = ImmutableList.of("102002", "103007");
assertEquals(expectedIds, actualIds);
}
use of com.b2international.snowowl.snomed.cis.ISnomedIdentifierService in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method createDescriptionWithReservedId.
@Test
public void createDescriptionWithReservedId() {
ISnomedIdentifierService identifierService = getServiceForClass(ISnomedIdentifierService.class);
String descriptionId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.DESCRIPTION, 1));
Json requestBody = createDescriptionRequestBody(Concepts.ROOT_CONCEPT).with("id", descriptionId).with("commitComment", "Created new description with reserved identifier");
final String createdDescriptionId = assertCreated(createComponent(branchPath, SnomedComponentType.DESCRIPTION, requestBody));
assertEquals(descriptionId, createdDescriptionId);
SctId descriptionSctId = SnomedRequests.identifiers().prepareGet().setComponentId(descriptionId).buildAsync().execute(getBus()).getSync().first().get();
assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), descriptionSctId.getStatus());
}
use of com.b2international.snowowl.snomed.cis.ISnomedIdentifierService in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method createConceptWithReservedId.
@Test
public void createConceptWithReservedId() {
ISnomedIdentifierService identifierService = ApplicationContext.getServiceForClass(ISnomedIdentifierService.class);
String conceptId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.CONCEPT, 1));
String createConceptId = createConcept(branchPath, createConceptRequestBody(Concepts.ROOT_CONCEPT).with("id", conceptId));
assertEquals(conceptId, createConceptId);
SctId conceptSctId = SnomedRequests.identifiers().prepareGet().setComponentId(conceptId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES).first().get();
assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), conceptSctId.getStatus());
}
use of com.b2international.snowowl.snomed.cis.ISnomedIdentifierService in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method createConcreteValueWithReservedId.
@Test
public void createConcreteValueWithReservedId() {
ISnomedIdentifierService identifierService = getServiceForClass(ISnomedIdentifierService.class);
String relationshipId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.RELATIONSHIP, 1));
Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue("string value")).with("id", relationshipId).with("commitComment", "Created new concrete value with reserved identifier");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(201).header("Location", endsWith("/" + relationshipId));
SctId concreteValueSctId = SnomedRequests.identifiers().prepareGet().setComponentId(relationshipId).buildAsync().execute(getBus()).getSync().first().get();
assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), concreteValueSctId.getStatus());
}
Aggregations