Search in sources :

Example 36 with ResourceURI

use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.

the class SnomedExtensionUpgradeTest method upgrade19UpgradeFromCodeSystemVersionWithUnpublishedAndPublishedChanges.

@Test
public void upgrade19UpgradeFromCodeSystemVersionWithUnpublishedAndPublishedChanges() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    String newConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    String newConceptId2 = createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    // new SE concept
    String newConceptId3 = createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId).statusCode(200);
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId2).statusCode(200);
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId3).statusCode(404);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 37 with ResourceURI

use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.

the class SnomedExtensionUpgradeTest method upgrade14CompleteUpgrade.

@Test
public void upgrade14CompleteUpgrade() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // create a new INT version without any changes
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
    // create new extension version with one new concept, module in this case
    String moduleId = createModule(extension);
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion);
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, moduleId).statusCode(200);
    Boolean success = CodeSystemRequests.prepareComplete(upgradeCodeSystem.getId()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
    assertTrue(success);
    // after upgrade completion, the upgrade Code System is no longer available
    CodeSystemRestRequests.assertGetCodeSystem(upgradeCodeSystem.getId()).statusCode(404);
    // the extension should use the upgrade's branch
    CodeSystem afterUpgrade = CodeSystemRestRequests.getCodeSystem(upgradeCodeSystem.getUpgradeOf().getResourceId());
    assertThat(afterUpgrade.getBranchPath()).isEqualTo(upgradeCodeSystem.getBranchPath());
    assertThat(afterUpgrade.getExtensionOf()).isEqualByComparingTo(upgradeCodeSystem.getExtensionOf());
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 38 with ResourceURI

use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.

the class SnomedExtensionUpgradeTest method upgrade16UpgradeFromCodeSystemVersion.

@Test
public void upgrade16UpgradeFromCodeSystemVersion() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    String newConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId).statusCode(200);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 39 with ResourceURI

use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.

the class SnomedExtensionUpgradeTest method upgrade21ExpandUpgradeInfo.

@Test
public void upgrade21ExpandUpgradeInfo() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveDate).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
    // new SE concept
    String extensionModuleId = createModule(extension);
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate2 = LocalDate.now();
    createVersion(extension.getId(), effectiveDate2).statusCode(201);
    ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
    // new SE concept
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
    // version extension
    LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
    createVersion(extension.getId(), effectiveDate3).statusCode(201);
    ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
    CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
    assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
    assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystems(com.b2international.snowowl.core.codesystem.CodeSystems) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 40 with ResourceURI

use of com.b2international.snowowl.core.ResourceURI in project snow-owl by b2ihealthcare.

the class SnomedExtensionUpgradeTest method upgrade04InternationalAddedDirectlyToExtensionResultsInConflict.

@Test
public void upgrade04InternationalAddedDirectlyToExtensionResultsInConflict() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    // new SI concept
    String newConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
    // create a new INT version
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
    // replay SI concept on extension branch, simulating direct import of a preview or release SI RF2
    createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE).with("id", newConceptId));
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    // start upgrade but it fails due to same content present on both sides
    assertCodeSystemUpgrade(extension.getResourceURI(), upgradeVersion).statusCode(409);
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

ResourceURI (com.b2international.snowowl.core.ResourceURI)49 Test (org.junit.Test)29 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)21 LocalDate (java.time.LocalDate)19 Collectors (java.util.stream.Collectors)11 TerminologyResource (com.b2international.snowowl.core.TerminologyResource)7 List (java.util.List)7 Set (java.util.Set)7 BadRequestException (com.b2international.commons.exceptions.BadRequestException)6 Options (com.b2international.commons.options.Options)6 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)6 IEventBus (com.b2international.snowowl.eventbus.IEventBus)6 IOException (java.io.IOException)6 Map (java.util.Map)6 TimeUnit (java.util.concurrent.TimeUnit)6 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)5 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)5 CodeSystems (com.b2international.snowowl.core.codesystem.CodeSystems)5 Version (com.b2international.snowowl.core.version.Version)5 Strings (com.google.common.base.Strings)5