Search in sources :

Example 6 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class OncotreeTestConfig method oncoTreeAdditionalVersionRepositoryMockResponse.

@Bean
public ArrayList<Version> oncoTreeAdditionalVersionRepositoryMockResponse() {
    ArrayList<Version> oncoTreeAdditionalVersionRepositoryMockResponse = new ArrayList<Version>(oncoTreeVersionRepositoryMockResponse());
    Version nextVersion = new Version();
    nextVersion.setVersion("test_version");
    nextVersion.setGraphURI("urn:x-evn-master:test_version");
    nextVersion.setDescription("This is just another test OncoTree version for testing cache updates");
    oncoTreeAdditionalVersionRepositoryMockResponse.add(nextVersion);
    return oncoTreeAdditionalVersionRepositoryMockResponse;
}
Also used : Version(org.mskcc.oncotree.model.Version) Bean(org.springframework.context.annotation.Bean)

Example 7 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class VersionUtilTest method testUnmatchedVersionQuery.

@Test(expected = InvalidVersionException.class)
public void testUnmatchedVersionQuery() throws Exception {
    String testVersionName = "THIS_STRING_IS_VERY_UNLIKELY_TO_EVER_BE_USED_FOR_THE_NAME_OF_AN_ACTUAL_ONCOTREE_VERSION";
    Version returnedVersion = versionUtil.getVersion(testVersionName);
    fail("expected exception (InvalidVersionException) did not get thrown");
}
Also used : Version(org.mskcc.oncotree.model.Version) Test(org.junit.Test)

Example 8 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class VersionUtilTest method testFullVersionList.

@Test
public void testFullVersionList() throws Exception {
    List<Version> versionsFromUtil = versionUtil.getVersions();
    Map<String, Version> returnedVersionMap = new HashMap<>(versionsFromUtil.size());
    for (Version version : versionsFromUtil) {
        returnedVersionMap.put(version.getVersion(), version);
    }
    int failureCount = 0;
    StringBuilder failureReport = new StringBuilder();
    for (String versionName : expectedVersionMap.keySet()) {
        Version expectedVersion = expectedVersionMap.get(versionName);
        Version returnedVersion = returnedVersionMap.get(versionName);
        failureCount = failureCount + failuresInReturnedVersionComparison(versionName, expectedVersion, returnedVersion, failureReport);
    }
    if (expectedVersionMap.size() != returnedVersionMap.size()) {
        failureReport.append("mismatch between returned version list (size:" + Integer.toString(returnedVersionMap.size()) + ") and expected version list (size:" + Integer.toString(expectedVersionMap.size()) + ")");
        failureCount = failureCount + 1;
    }
    if (failureCount > 0) {
        fail(Integer.toString(failureCount) + " failed test conditions. Details follow... " + failureReport.toString());
    }
    return;
}
Also used : Version(org.mskcc.oncotree.model.Version) Test(org.junit.Test)

Example 9 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class VersionUtilTest method testNullVersionQuery.

@Test(expected = InvalidVersionException.class)
public void testNullVersionQuery() throws Exception {
    String testVersionName = null;
    Version returnedVersion = versionUtil.getVersion(testVersionName);
    fail("expected exception (InvalidVersionException) did not get thrown");
}
Also used : Version(org.mskcc.oncotree.model.Version) Test(org.junit.Test)

Example 10 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class TumorTypesTxtApi method tumorTypesTxtGet.

@Deprecated
@ApiOperation(value = "Tumor Types in plain text format.", notes = "Return all available tumor types.", response = Void.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Tumor types text file."), @ApiResponse(code = 404, message = "Could not find tumor types text file"), @ApiResponse(code = 503, message = "Required data source unavailable") })
@RequestMapping(value = "", produces = { TEXT_PLAIN_VALUE }, method = RequestMethod.GET)
public InputStreamResource tumorTypesTxtGet(@ApiParam(value = "The version of tumor types. For example, " + VersionUtil.DEFAULT_VERSION + ". Please see the versions api documentation for released versions.") @RequestParam(value = "version", required = false) String version) {
    Map<String, TumorType> tumorTypes = new HashMap<>();
    Version v = (version == null) ? versionUtil.getDefaultVersion() : versionUtil.getVersion(version);
    tumorTypes = cacheUtil.getTumorTypesByVersion(v);
    InputStream inputStream = tumorTypesUtil.getTumorTypeInputStream(tumorTypes);
    InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
    return inputStreamResource;
}
Also used : TumorType(org.mskcc.oncotree.model.TumorType) HashMap(java.util.HashMap) Version(org.mskcc.oncotree.model.Version) InputStream(java.io.InputStream) InputStreamResource(org.springframework.core.io.InputStreamResource) Deprecated(java.lang.Deprecated) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Version (org.mskcc.oncotree.model.Version)15 Test (org.junit.Test)5 TumorType (org.mskcc.oncotree.model.TumorType)3 Bean (org.springframework.context.annotation.Bean)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 OncoTreeNode (org.mskcc.oncotree.topbraid.OncoTreeNode)2 TopBraidException (org.mskcc.oncotree.topbraid.TopBraidException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 InputStream (java.io.InputStream)1 Deprecated (java.lang.Deprecated)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CacheManager (javax.cache.CacheManager)1 InvalidOncoTreeDataException (org.mskcc.oncotree.error.InvalidOncoTreeDataException)1 InvalidVersionException (org.mskcc.oncotree.error.InvalidVersionException)1 FailedCacheRefreshException (org.mskcc.oncotree.utils.FailedCacheRefreshException)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 EventListener (org.springframework.context.event.EventListener)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1