From d52e31d5a9de9df6f5f214c0fd9483933fa2a6e3 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 2 Jan 2025 10:11:48 -0500 Subject: [PATCH 1/7] upgrade to spring boot 3.4 --- pom.xml | 4 +- .../mybatis/ClinicalEventMapper.xml | 8 +- ...opyNumberSegmentMyBatisRepositoryTest.java | 8 +- .../ExpressionEnrichmentServiceImplTest.java | 129 +++++++++++++++--- ...GenericAssayEnrichmentServiceImplTest.java | 75 ++++++++-- 5 files changed, 182 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index e61597ee3a1..6e2a69f6469 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.4 + 3.4.1 org.cbioportal @@ -72,7 +72,7 @@ 1.6.3 - 3.0.2 + 3.0.4 1.19.4 5.15.0 4.1.1 diff --git a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml index 828500a579c..48e446aeccb 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalEventMapper.xml @@ -228,9 +228,9 @@ clinical_event.EVENT_TYPE = #{element.eventType} - (clinical_event.EVENT_TYPE, clinical_event_data.KEY, clinical_event_data.VALUE) IN + (CONCAT(clinical_event.EVENT_TYPE, '_', clinical_event_data.KEY, '_', clinical_event_data.VALUE)) IN - (#{element.eventType}, #{attribute.key}, #{attribute.value}) + CONCAT(#{element.eventType}, '_', #{attribute.key}, '_', #{attribute.value}) @@ -291,9 +291,9 @@ clinical_event.EVENT_TYPE = #{element.eventType} - (clinical_event.EVENT_TYPE, clinical_event_data.KEY) IN + (CONCAT(clinical_event.EVENT_TYPE, '_', clinical_event_data.KEY)) IN - (#{element.eventType}, #{attribute.key}) + CONCAT(#{element.eventType}, '_', #{attribute.key}) diff --git a/src/test/java/org/cbioportal/persistence/mybatis/CopyNumberSegmentMyBatisRepositoryTest.java b/src/test/java/org/cbioportal/persistence/mybatis/CopyNumberSegmentMyBatisRepositoryTest.java index 38a7720a823..b8e72afac33 100644 --- a/src/test/java/org/cbioportal/persistence/mybatis/CopyNumberSegmentMyBatisRepositoryTest.java +++ b/src/test/java/org/cbioportal/persistence/mybatis/CopyNumberSegmentMyBatisRepositoryTest.java @@ -181,16 +181,16 @@ public void fetchCopyNumberSegments() throws Exception { studyIds, sampleIds, "3", "SUMMARY"); Assert.assertEquals(3, result0.size()); - Assert.assertEquals("TCGA-A1-B0SO-01", result0.get(0).getSampleStableId()); + Assert.assertEquals("TCGA-A1-A0SB-01", result0.get(0).getSampleStableId()); Assert.assertEquals("TCGA-A1-A0SB-01", result0.get(1).getSampleStableId()); - Assert.assertEquals("TCGA-A1-A0SB-01", result0.get(2).getSampleStableId()); + Assert.assertEquals("TCGA-A1-B0SO-01", result0.get(2).getSampleStableId()); Assert.assertEquals(1, result1.size()); Assert.assertEquals("TCGA-A1-A0SB-01", result1.get(0).getSampleStableId()); Assert.assertEquals(2, result2.size()); - Assert.assertEquals("TCGA-A1-B0SO-01", result2.get(0).getSampleStableId()); - Assert.assertEquals("TCGA-A1-A0SB-01", result2.get(1).getSampleStableId()); + Assert.assertEquals("TCGA-A1-A0SB-01", result2.get(0).getSampleStableId()); + Assert.assertEquals("TCGA-A1-B0SO-01", result2.get(1).getSampleStableId()); Assert.assertEquals(0, result3.size()); } diff --git a/src/test/java/org/cbioportal/service/impl/ExpressionEnrichmentServiceImplTest.java b/src/test/java/org/cbioportal/service/impl/ExpressionEnrichmentServiceImplTest.java index 280cd706adf..0b612d5f9ea 100644 --- a/src/test/java/org/cbioportal/service/impl/ExpressionEnrichmentServiceImplTest.java +++ b/src/test/java/org/cbioportal/service/impl/ExpressionEnrichmentServiceImplTest.java @@ -18,7 +18,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) @@ -34,8 +33,7 @@ public class ExpressionEnrichmentServiceImplTest extends BaseServiceImplTest { private MolecularDataRepository molecularDataRepository; @Mock private GeneService geneService; - @Spy - @InjectMocks + @Mock private ExpressionEnrichmentUtil expressionEnrichmentUtil; @Mock private GenericAssayService genericAssayService; @@ -125,13 +123,7 @@ public void setup() throws MolecularProfileNotFoundException { molecularProfilePatientLevelCaseSets.put("unaltered samples", unalteredPatientLevelSampleIdentifieres); Mockito.when(molecularProfileService.getMolecularProfile(MOLECULAR_PROFILE_ID)) - .thenReturn(geneMolecularProfile); - - Mockito.when(molecularDataRepository.getCommaSeparatedSampleIdsOfMolecularProfile(MOLECULAR_PROFILE_ID)) - .thenReturn(molecularProfileSamples); - - Mockito.when(sampleService.fetchSamples(Arrays.asList(STUDY_ID, STUDY_ID, STUDY_ID, STUDY_ID), - Arrays.asList(SAMPLE_ID3, SAMPLE_ID4, SAMPLE_ID1, SAMPLE_ID2), "ID")).thenReturn(samples); + .thenReturn(geneMolecularProfile); } @Test @@ -149,7 +141,40 @@ public void getGenomicEnrichments() throws Exception { geneMolecularAlteration2.setValues("1.1,5,2.3,3"); molecularDataList.add(geneMolecularAlteration2); Mockito.when(molecularDataRepository.getGeneMolecularAlterationsIterableFast(MOLECULAR_PROFILE_ID)) - .thenReturn(molecularDataList); + .thenReturn(molecularDataList); + + List expectedEnrichments = new ArrayList<>(); + GenomicEnrichment enrichment1 = new GenomicEnrichment(); + enrichment1.setEntrezGeneId(ENTREZ_GENE_ID_2); + enrichment1.setHugoGeneSymbol(HUGO_GENE_SYMBOL_2); + GroupStatistics unalteredGroupStats1 = new GroupStatistics(); + unalteredGroupStats1.setName("unaltered samples"); + unalteredGroupStats1.setMeanExpression(new BigDecimal("2.55")); + unalteredGroupStats1.setStandardDeviation(new BigDecimal("0.6363961030678927")); + GroupStatistics alteredGroupStats1 = new GroupStatistics(); + alteredGroupStats1.setName("altered samples"); + alteredGroupStats1.setMeanExpression(new BigDecimal("2.5")); + alteredGroupStats1.setStandardDeviation(new BigDecimal("0.7071067811865476")); + enrichment1.setGroupsStatistics(List.of(unalteredGroupStats1, alteredGroupStats1)); + enrichment1.setpValue(new BigDecimal("0.9475795430163914")); + expectedEnrichments.add(enrichment1); + + GenomicEnrichment enrichment2 = new GenomicEnrichment(); + enrichment2.setEntrezGeneId(ENTREZ_GENE_ID_3); + enrichment2.setHugoGeneSymbol(HUGO_GENE_SYMBOL_3); + GroupStatistics unalteredGroupStats2 = new GroupStatistics(); + unalteredGroupStats2.setName("unaltered samples"); + unalteredGroupStats2.setMeanExpression(new BigDecimal("2.65")); + unalteredGroupStats2.setStandardDeviation(new BigDecimal("0.4949747468305834")); + GroupStatistics alteredGroupStats2 = new GroupStatistics(); + alteredGroupStats2.setName("altered samples"); + alteredGroupStats2.setMeanExpression(new BigDecimal("3.05")); + alteredGroupStats2.setStandardDeviation(new BigDecimal("2.7577164466275352")); + enrichment2.setGroupsStatistics(List.of(unalteredGroupStats2, alteredGroupStats2)); + enrichment2.setpValue(new BigDecimal("0.8716148250471419")); + expectedEnrichments.add(enrichment2); + Mockito.when(expressionEnrichmentUtil.getEnrichments(geneMolecularProfile, molecularProfileCaseSets, EnrichmentType.SAMPLE, molecularDataList)) + .thenReturn(expectedEnrichments); List expectedGeneList = new ArrayList<>(); Gene gene1 = new Gene(); @@ -162,10 +187,10 @@ public void getGenomicEnrichments() throws Exception { expectedGeneList.add(gene2); Mockito.when(geneService.fetchGenes(Arrays.asList("2", "3"), "ENTREZ_GENE_ID", "SUMMARY")) - .thenReturn(expectedGeneList); + .thenReturn(expectedGeneList); List result = enrichmentServiceImpl.getGenomicEnrichments(MOLECULAR_PROFILE_ID, - molecularProfileCaseSets, EnrichmentType.SAMPLE); + molecularProfileCaseSets, EnrichmentType.SAMPLE); Assert.assertEquals(2, result.size()); GenomicEnrichment expressionEnrichment = result.get(0); @@ -221,16 +246,47 @@ public void getGenericAssayNumericalEnrichments() throws Exception { genericAssayMolecularAlteration2.setValues("1.1,5,2.3,3"); molecularDataList.add(genericAssayMolecularAlteration2); Mockito.when(molecularDataRepository.getGenericAssayMolecularAlterationsIterable(MOLECULAR_PROFILE_ID, null, - "SUMMARY")).thenReturn(molecularDataList); + "SUMMARY")).thenReturn(molecularDataList); + + List expectedEnrichments = new ArrayList<>(); + GenericAssayEnrichment enrichment1 = new GenericAssayEnrichment(); + enrichment1.setStableId(HUGO_GENE_SYMBOL_1); + GroupStatistics unalteredGroupStats1 = new GroupStatistics(); + unalteredGroupStats1.setName("unaltered samples"); + unalteredGroupStats1.setMeanExpression(new BigDecimal("2.55")); + unalteredGroupStats1.setStandardDeviation(new BigDecimal("0.6363961030678927")); + GroupStatistics alteredGroupStats1 = new GroupStatistics(); + alteredGroupStats1.setName("altered samples"); + alteredGroupStats1.setMeanExpression(new BigDecimal("2.5")); + alteredGroupStats1.setStandardDeviation(new BigDecimal("0.7071067811865476")); + enrichment1.setGroupsStatistics(List.of(unalteredGroupStats1, alteredGroupStats1)); + enrichment1.setpValue(new BigDecimal("0.9475795430163914")); + expectedEnrichments.add(enrichment1); + + GenericAssayEnrichment enrichment2 = new GenericAssayEnrichment(); + enrichment2.setStableId(HUGO_GENE_SYMBOL_2); + GroupStatistics unalteredGroupStats2 = new GroupStatistics(); + unalteredGroupStats2.setName("unaltered samples"); + unalteredGroupStats2.setMeanExpression(new BigDecimal("2.65")); + unalteredGroupStats2.setStandardDeviation(new BigDecimal("0.4949747468305834")); + GroupStatistics alteredGroupStats2 = new GroupStatistics(); + alteredGroupStats2.setName("altered samples"); + alteredGroupStats2.setMeanExpression(new BigDecimal("3.05")); + alteredGroupStats2.setStandardDeviation(new BigDecimal("2.7577164466275352")); + enrichment2.setGroupsStatistics(List.of(unalteredGroupStats2, alteredGroupStats2)); + enrichment2.setpValue(new BigDecimal("0.8716148250471419")); + expectedEnrichments.add(enrichment2); + Mockito.when(expressionEnrichmentUtil.getEnrichments(geneMolecularProfile, molecularProfileCaseSets, EnrichmentType.SAMPLE, molecularDataList)) + .thenReturn(expectedEnrichments); Mockito.when(genericAssayService.getGenericAssayMetaByStableIdsAndMolecularIds( Arrays.asList(HUGO_GENE_SYMBOL_1, HUGO_GENE_SYMBOL_2), Arrays.asList(MOLECULAR_PROFILE_ID, MOLECULAR_PROFILE_ID), "SUMMARY")) - .thenReturn(Arrays.asList(new GenericAssayMeta(HUGO_GENE_SYMBOL_1), - new GenericAssayMeta(HUGO_GENE_SYMBOL_2))); + .thenReturn(Arrays.asList(new GenericAssayMeta(HUGO_GENE_SYMBOL_1), + new GenericAssayMeta(HUGO_GENE_SYMBOL_2))); List result = enrichmentServiceImpl.getGenericAssayNumericalEnrichments(MOLECULAR_PROFILE_ID, - molecularProfileCaseSets, EnrichmentType.SAMPLE); + molecularProfileCaseSets, EnrichmentType.SAMPLE); Assert.assertEquals(2, result.size()); GenericAssayEnrichment genericAssayEnrichment = result.get(0); @@ -283,13 +339,44 @@ public void getGenericAssayPatientLevelEnrichments() throws Exception { genericAssayMolecularAlteration2.setValues("1.1,5,2.3,3,3"); molecularDataList.add(genericAssayMolecularAlteration2); Mockito.when(molecularDataRepository.getGenericAssayMolecularAlterationsIterable(MOLECULAR_PROFILE_ID, null, - "SUMMARY")).thenReturn(molecularDataList); + "SUMMARY")).thenReturn(molecularDataList); + + List expectedEnrichments = new ArrayList<>(); + GenericAssayEnrichment enrichment1 = new GenericAssayEnrichment(); + enrichment1.setStableId(HUGO_GENE_SYMBOL_1); + GroupStatistics unalteredGroupStats1 = new GroupStatistics(); + unalteredGroupStats1.setName("unaltered samples"); + unalteredGroupStats1.setMeanExpression(new BigDecimal("2.55")); + unalteredGroupStats1.setStandardDeviation(new BigDecimal("0.6363961030678927")); + GroupStatistics alteredGroupStats1 = new GroupStatistics(); + alteredGroupStats1.setName("altered samples"); + alteredGroupStats1.setMeanExpression(new BigDecimal("2.5")); + alteredGroupStats1.setStandardDeviation(new BigDecimal("0.7071067811865476")); + enrichment1.setGroupsStatistics(List.of(unalteredGroupStats1, alteredGroupStats1)); + enrichment1.setpValue(new BigDecimal("0.9475795430163914")); + expectedEnrichments.add(enrichment1); + + GenericAssayEnrichment enrichment2 = new GenericAssayEnrichment(); + enrichment2.setStableId(HUGO_GENE_SYMBOL_2); + GroupStatistics unalteredGroupStats2 = new GroupStatistics(); + unalteredGroupStats2.setName("unaltered samples"); + unalteredGroupStats2.setMeanExpression(new BigDecimal("2.65")); + unalteredGroupStats2.setStandardDeviation(new BigDecimal("0.4949747468305834")); + GroupStatistics alteredGroupStats2 = new GroupStatistics(); + alteredGroupStats2.setName("altered samples"); + alteredGroupStats2.setMeanExpression(new BigDecimal("3.05")); + alteredGroupStats2.setStandardDeviation(new BigDecimal("2.7577164466275352")); + enrichment2.setGroupsStatistics(List.of(unalteredGroupStats2, alteredGroupStats2)); + enrichment2.setpValue(new BigDecimal("0.8716148250471419")); + expectedEnrichments.add(enrichment2); + Mockito.when(expressionEnrichmentUtil.getEnrichments(geneMolecularProfile, molecularProfileCaseSets, EnrichmentType.SAMPLE, molecularDataList)) + .thenReturn(expectedEnrichments); Mockito.when(genericAssayService.getGenericAssayMetaByStableIdsAndMolecularIds( Arrays.asList(HUGO_GENE_SYMBOL_1, HUGO_GENE_SYMBOL_2), Arrays.asList(MOLECULAR_PROFILE_ID, MOLECULAR_PROFILE_ID), "SUMMARY")) - .thenReturn(Arrays.asList(new GenericAssayMeta(HUGO_GENE_SYMBOL_1), - new GenericAssayMeta(HUGO_GENE_SYMBOL_2))); + .thenReturn(Arrays.asList(new GenericAssayMeta(HUGO_GENE_SYMBOL_1), + new GenericAssayMeta(HUGO_GENE_SYMBOL_2))); // add 5th sample which is the second sample of patient 4 Sample sample5 = new Sample(); @@ -337,4 +424,4 @@ public void getGenericAssayPatientLevelEnrichments() throws Exception { Assert.assertEquals(new BigDecimal("0.8716148250471419"), genericAssayEnrichment.getpValue()); } -} +} \ No newline at end of file diff --git a/src/test/java/org/cbioportal/service/impl/GenericAssayEnrichmentServiceImplTest.java b/src/test/java/org/cbioportal/service/impl/GenericAssayEnrichmentServiceImplTest.java index 017a5ab005f..ea9e489e13a 100644 --- a/src/test/java/org/cbioportal/service/impl/GenericAssayEnrichmentServiceImplTest.java +++ b/src/test/java/org/cbioportal/service/impl/GenericAssayEnrichmentServiceImplTest.java @@ -1,5 +1,6 @@ package org.cbioportal.service.impl; +import org.cbioportal.model.ExpressionEnrichment; import org.cbioportal.model.meta.GenericAssayMeta; import org.cbioportal.model.EnrichmentType; import org.cbioportal.model.MolecularProfileCaseIdentifier; @@ -26,7 +27,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import java.math.BigDecimal; @@ -51,8 +51,7 @@ public class GenericAssayEnrichmentServiceImplTest extends BaseServiceImplTest{ @Mock private GenericAssayService genericAssayService; - @Spy - @InjectMocks + @Mock private ExpressionEnrichmentUtil expressionEnrichmentUtil; CancerStudy cancerStudy = new CancerStudy(); @@ -142,14 +141,8 @@ public void setup() throws MolecularProfileNotFoundException { Mockito.when(molecularProfileService.getMolecularProfile(MOLECULAR_PROFILE_ID)) .thenReturn(geneMolecularProfile); - - Mockito.when(molecularDataRepository.getCommaSeparatedSampleIdsOfMolecularProfile(MOLECULAR_PROFILE_ID)) - .thenReturn(molecularProfileSamples); - - Mockito.when(sampleService.fetchSamples(Arrays.asList(STUDY_ID, STUDY_ID, STUDY_ID, STUDY_ID), - Arrays.asList(SAMPLE_ID3, SAMPLE_ID4, SAMPLE_ID1, SAMPLE_ID2), "ID")).thenReturn(samples); } - + @Test public void getGenericAssayBinaryEnrichments() throws Exception { geneMolecularProfile.setMolecularAlterationType(MolecularProfile.MolecularAlterationType.GENERIC_ASSAY); @@ -169,6 +162,40 @@ public void getGenericAssayBinaryEnrichments() throws Exception { Mockito.when(molecularDataRepository.getGenericAssayMolecularAlterationsIterable(MOLECULAR_PROFILE_ID, null, "SUMMARY")).thenReturn(molecularDataList); + List expectedEnrichments = new ArrayList<>(); + GenericAssayBinaryEnrichment enrichment1 = new GenericAssayBinaryEnrichment(); + enrichment1.setStableId(HUGO_GENE_SYMBOL_1); + GroupStatistics unalteredGroupStats1 = new GroupStatistics(); + unalteredGroupStats1.setName("unaltered samples"); + unalteredGroupStats1.setMeanExpression(new BigDecimal("0.5")); + unalteredGroupStats1.setStandardDeviation(new BigDecimal("0.7071067811865476")); + GroupStatistics alteredGroupStats1 = new GroupStatistics(); + alteredGroupStats1.setName("altered samples"); + alteredGroupStats1.setMeanExpression(new BigDecimal("1.0")); + alteredGroupStats1.setStandardDeviation(new BigDecimal("0.0")); + enrichment1.setGroupsStatistics(List.of(unalteredGroupStats1, alteredGroupStats1)); + enrichment1.setpValue(new BigDecimal("0.49999999999999983")); + enrichment1.setqValue(new BigDecimal("0.99999999999999966")); + expectedEnrichments.add(enrichment1); + + GenericAssayBinaryEnrichment enrichment2 = new GenericAssayBinaryEnrichment(); + enrichment2.setStableId(HUGO_GENE_SYMBOL_2); + GroupStatistics unalteredGroupStats2 = new GroupStatistics(); + unalteredGroupStats2.setName("unaltered samples"); + unalteredGroupStats2.setMeanExpression(new BigDecimal("0.5")); + unalteredGroupStats2.setStandardDeviation(new BigDecimal("0.7071067811865476")); + GroupStatistics alteredGroupStats2 = new GroupStatistics(); + alteredGroupStats2.setName("altered samples"); + alteredGroupStats2.setMeanExpression(new BigDecimal("0.5")); + alteredGroupStats2.setStandardDeviation(new BigDecimal("0.7071067811865476")); + enrichment2.setGroupsStatistics(List.of(unalteredGroupStats2, alteredGroupStats2)); + enrichment2.setpValue(new BigDecimal("1.0")); + enrichment2.setqValue(new BigDecimal("1.0")); + expectedEnrichments.add(enrichment2); + + Mockito.when(expressionEnrichmentUtil.getGenericAssayBinaryEnrichments(geneMolecularProfile, molecularProfileCaseSets, EnrichmentType.SAMPLE, molecularDataList)) + .thenReturn(expectedEnrichments); + Mockito.when(genericAssayService.getGenericAssayMetaByStableIdsAndMolecularIds( Arrays.asList(HUGO_GENE_SYMBOL_1, HUGO_GENE_SYMBOL_2), Arrays.asList(MOLECULAR_PROFILE_ID, MOLECULAR_PROFILE_ID), "SUMMARY")) @@ -232,6 +259,32 @@ public void getGenericAssayCategoricalEnrichments() throws MolecularProfileNotFo Mockito.when(molecularDataRepository.getGenericAssayMolecularAlterationsIterable(MOLECULAR_PROFILE_ID, null, "SUMMARY")).thenReturn(molecularDataList); + List expectedEnrichments = new ArrayList<>(); + GenericAssayCategoricalEnrichment enrichment1 = new GenericAssayCategoricalEnrichment(); + enrichment1.setStableId(HUGO_GENE_SYMBOL_1); + GroupStatistics unalteredGroupStats1 = new GroupStatistics(); + unalteredGroupStats1.setName("unaltered samples"); + GroupStatistics alteredGroupStats1 = new GroupStatistics(); + alteredGroupStats1.setName("altered samples"); + enrichment1.setGroupsStatistics(List.of(unalteredGroupStats1, alteredGroupStats1)); + enrichment1.setpValue(new BigDecimal("0.04550026389635764")); + enrichment1.setqValue(new BigDecimal("0.04550026389635764")); + expectedEnrichments.add(enrichment1); + + GenericAssayCategoricalEnrichment enrichment2 = new GenericAssayCategoricalEnrichment(); + enrichment2.setStableId(HUGO_GENE_SYMBOL_2); + GroupStatistics unalteredGroupStats2 = new GroupStatistics(); + unalteredGroupStats2.setName("unaltered samples"); + GroupStatistics alteredGroupStats2 = new GroupStatistics(); + alteredGroupStats2.setName("altered samples"); + enrichment2.setGroupsStatistics(List.of(unalteredGroupStats2, alteredGroupStats2)); + enrichment2.setpValue(new BigDecimal("0.04550026389635764")); + enrichment2.setqValue(new BigDecimal("0.04550026389635764")); + expectedEnrichments.add(enrichment2); + + Mockito.when(expressionEnrichmentUtil.getGenericAssayCategoricalEnrichments(geneMolecularProfile, molecularProfileCaseSets, EnrichmentType.SAMPLE, molecularDataList)) + .thenReturn(expectedEnrichments); + Mockito.when(genericAssayService.getGenericAssayMetaByStableIdsAndMolecularIds( Arrays.asList(HUGO_GENE_SYMBOL_1, HUGO_GENE_SYMBOL_2), Arrays.asList(MOLECULAR_PROFILE_ID, MOLECULAR_PROFILE_ID), "SUMMARY")) @@ -269,4 +322,4 @@ public void getGenericAssayCategoricalEnrichments() throws MolecularProfileNotFo Assert.assertEquals(new BigDecimal("0.04550026389635764"), genericAssayCategoricalEnrichment.getqValue()); } -} +} \ No newline at end of file From 49b557c0a0a2dfe617721bc5daddcfe09069f494 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 9 Jan 2025 14:49:16 -0500 Subject: [PATCH 2/7] fix critical and high vulnerabilities --- pom.xml | 39 +++- .../MockInMemoryRedissonClient.java | 80 +++++++- .../util/fakeclient/MockRBucket.java | 182 ++++++++++++++++++ .../util/fakeclient/MockRKeys.java | 10 + 4 files changed, 302 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 6e2a69f6469..a77c9cab05b 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ - 3.13.2 + 3.22.0 3.6.1 2.2.0 4.4 @@ -93,13 +93,13 @@ 1.1.1 3.12.14 0.8.2 - 8.0.33 3.2.0 3.14.0 4.17.0 7.1.0 5.2.1 1.19.7 + 1.78 @@ -249,11 +249,6 @@ jwks-rsa 0.22.1 - - mysql - mysql-connector-java - ${mysql_driver.version} - org.springframework.boot spring-boot-starter-thymeleaf @@ -380,6 +375,36 @@ spring-boot-testcontainers test + + commons-io + commons-io + 2.18.0 + + + com.nimbusds + nimbus-jose-jwt + 9.37.2 + + + org.bouncycastle + bcpkix-jdk18on + ${bouncy_castle.version} + + + org.bouncycastle + bc-fips + 2.0.0 + + + org.bouncycastle + bcprov-jdk18on + ${bouncy_castle.version} + + + org.bouncycastle + bctls-jdk18on + ${bouncy_castle.version} + diff --git a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockInMemoryRedissonClient.java b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockInMemoryRedissonClient.java index 92f69db4a88..145be13601c 100644 --- a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockInMemoryRedissonClient.java +++ b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockInMemoryRedissonClient.java @@ -4,6 +4,7 @@ import org.redisson.api.redisnode.BaseRedisNodes; import org.redisson.api.redisnode.RedisNodes; import org.redisson.client.codec.Codec; +import org.redisson.codec.JsonCodec; import org.redisson.config.Config; import java.util.concurrent.ConcurrentHashMap; @@ -32,12 +33,12 @@ public RKeys getKeys() { } @Override - public RTimeSeries getTimeSeries(String s) { + public RTimeSeries getTimeSeries(String s) { throw new UnsupportedOperationException(); } @Override - public RTimeSeries getTimeSeries(String s, Codec codec) { + public RTimeSeries getTimeSeries(String s, Codec codec) { throw new UnsupportedOperationException(); } @@ -51,6 +52,16 @@ public RStream getStream(String s, Codec codec) { throw new UnsupportedOperationException(); } + @Override + public RSearch getSearch() { + throw new UnsupportedOperationException(); + } + + @Override + public RSearch getSearch(Codec codec) { + throw new UnsupportedOperationException(); + } + @Override public RRateLimiter getRateLimiter(String s) { throw new UnsupportedOperationException(); @@ -116,6 +127,11 @@ public RBuckets getBuckets(Codec codec) { throw new UnsupportedOperationException(); } + @Override + public RJsonBucket getJsonBucket(String name, JsonCodec codec) { + throw new UnsupportedOperationException(); + } + @Override public RHyperLogLog getHyperLogLog(String s) { throw new UnsupportedOperationException(); @@ -221,6 +237,21 @@ public RLock getLock(String s) { throw new UnsupportedOperationException(); } + @Override + public RLock getSpinLock(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public RLock getSpinLock(String s, LockOptions.BackOff backOff) { + throw new UnsupportedOperationException(); + } + + @Override + public RFencedLock getFencedLock(String s) { + throw new UnsupportedOperationException(); + } + @Override public RLock getMultiLock(RLock... rLocks) { throw new UnsupportedOperationException(); @@ -281,6 +312,16 @@ public RLexSortedSet getLexSortedSet(String s) { throw new UnsupportedOperationException(); } + @Override + public RShardedTopic getShardedTopic(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public RShardedTopic getShardedTopic(String s, Codec codec) { + throw new UnsupportedOperationException(); + } + @Override public RTopic getTopic(String s) { throw new UnsupportedOperationException(); @@ -291,6 +332,16 @@ public RTopic getTopic(String s, Codec codec) { throw new UnsupportedOperationException(); } + @Override + public RReliableTopic getReliableTopic(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public RReliableTopic getReliableTopic(String s, Codec codec) { + throw new UnsupportedOperationException(); + } + @Override public RPatternTopic getPatternTopic(String s) { throw new UnsupportedOperationException(); @@ -456,6 +507,21 @@ public RBloomFilter getBloomFilter(String s, Codec codec) { throw new UnsupportedOperationException(); } + @Override + public RIdGenerator getIdGenerator(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public RFunction getFunction() { + throw new UnsupportedOperationException(); + } + + @Override + public RFunction getFunction(Codec codec) { + throw new UnsupportedOperationException(); + } + @Override public RScript getScript() { throw new UnsupportedOperationException(); @@ -526,6 +592,16 @@ public RLiveObjectService getLiveObjectService() { throw new UnsupportedOperationException(); } + @Override + public RedissonRxClient rxJava() { + throw new UnsupportedOperationException(); + } + + @Override + public RedissonReactiveClient reactive() { + throw new UnsupportedOperationException(); + } + @Override public void shutdown() { diff --git a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRBucket.java b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRBucket.java index e721381fdca..642509fd28a 100644 --- a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRBucket.java +++ b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRBucket.java @@ -5,6 +5,8 @@ import org.redisson.api.RFuture; import org.redisson.client.codec.Codec; +import java.time.Duration; +import java.time.Instant; import java.util.Date; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -40,6 +42,11 @@ public void set(Object o, long l, TimeUnit timeUnit) { } } + @Override + public void setAndKeepTTL(Object o) { + + } + @Override public RFuture setAsync(Object o) { set(o); @@ -52,6 +59,11 @@ public RFuture setAsync(Object o, long l, TimeUnit timeUnit) { return null; } + @Override + public RFuture setAndKeepTTLAsync(Object o) { + return null; + } + @Override public RFuture expireAsync(long l, TimeUnit timeUnit) { // This cache is really primitive, so ttl isn't fully implemented @@ -86,6 +98,16 @@ public boolean trySet(Object o, long l, TimeUnit timeUnit) { throw new UnsupportedOperationException(); } + @Override + public boolean setIfAbsent(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean setIfAbsent(Object o, Duration duration) { + throw new UnsupportedOperationException(); + } + @Override public boolean setIfExists(Object o) { throw new UnsupportedOperationException(); @@ -111,6 +133,26 @@ public Object getAndSet(Object o, long l, TimeUnit timeUnit) { throw new UnsupportedOperationException(); } + @Override + public Object getAndExpire(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public Object getAndExpire(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public Object getAndClearExpire() { + throw new UnsupportedOperationException(); + } + + @Override + public Long getIdleTime() { + throw new UnsupportedOperationException(); + } + @Override public long sizeInMemory() { throw new UnsupportedOperationException(); @@ -231,6 +273,16 @@ public RFuture trySetAsync(Object o, long l, TimeUnit timeUnit) { throw new UnsupportedOperationException(); } + @Override + public RFuture setIfAbsentAsync(Object o) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture setIfAbsentAsync(Object o, Duration duration) { + throw new UnsupportedOperationException(); + } + @Override public RFuture setIfExistsAsync(Object o) { throw new UnsupportedOperationException(); @@ -256,6 +308,21 @@ public RFuture getAndSetAsync(Object o, long l, TimeUnit timeUnit) { throw new UnsupportedOperationException(); } + @Override + public RFuture getAndExpireAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture getAndExpireAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture getAndClearExpireAsync() { + throw new UnsupportedOperationException(); + } + @Override public boolean expire(long l, TimeUnit timeUnit) { throw new UnsupportedOperationException(); @@ -271,6 +338,56 @@ public boolean expireAt(Date date) { throw new UnsupportedOperationException(); } + @Override + public boolean expire(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfSet(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfNotSet(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfGreater(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfLess(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expire(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfSet(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfNotSet(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfGreater(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean expireIfLess(Duration duration) { + throw new UnsupportedOperationException(); + } + @Override public boolean clearExpire() { throw new UnsupportedOperationException(); @@ -281,6 +398,11 @@ public long remainTimeToLive() { throw new UnsupportedOperationException(); } + @Override + public long getExpireTime() { + throw new UnsupportedOperationException(); + } + @Override public RFuture expireAtAsync(Date date) { throw new UnsupportedOperationException(); @@ -291,6 +413,56 @@ public RFuture expireAtAsync(long l) { throw new UnsupportedOperationException(); } + @Override + public RFuture expireAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfSetAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfNotSetAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfGreaterAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfLessAsync(Instant instant) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfSetAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfNotSetAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfGreaterAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture expireIfLessAsync(Duration duration) { + throw new UnsupportedOperationException(); + } + @Override public RFuture clearExpireAsync() { throw new UnsupportedOperationException(); @@ -301,6 +473,16 @@ public RFuture remainTimeToLiveAsync() { throw new UnsupportedOperationException(); } + @Override + public RFuture getExpireTimeAsync() { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture getIdleTimeAsync() { + throw new UnsupportedOperationException(); + } + @Override public RFuture sizeInMemoryAsync() { throw new UnsupportedOperationException(); diff --git a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRKeys.java b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRKeys.java index 81b219e49fa..3866c31ddca 100644 --- a/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRKeys.java +++ b/src/test/java/org/cbioportal/persistence/util/fakeclient/MockRKeys.java @@ -32,6 +32,16 @@ public long deleteByPattern(String s) { .count(); } + @Override + public Iterable getKeysWithLimit(int i) { + throw new UnsupportedOperationException(); + } + + @Override + public Iterable getKeysWithLimit(String s, int i) { + throw new UnsupportedOperationException(); + } + /* * Methods we don't use */ From ad2b9dee7fbb879704a0d254aa3c78fcd4855478 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 9 Jan 2025 16:34:43 -0500 Subject: [PATCH 3/7] fix vulnerability with commons-io --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index a77c9cab05b..0e673a55797 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ 1.1.1 3.12.14 0.8.2 + 8.0.33 3.2.0 3.14.0 4.17.0 @@ -248,6 +249,11 @@ com.auth0 jwks-rsa 0.22.1 + + + mysql + mysql-connector-java + ${mysql_driver.version} org.springframework.boot @@ -375,6 +381,11 @@ spring-boot-testcontainers test + + org.apache.velocity + velocity-engine-core + 2.4.1 + commons-io commons-io From a1d106aadf7c75fe68faf371501b2413cd611786 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 9 Jan 2025 18:35:38 -0500 Subject: [PATCH 4/7] fix mysql connector vulnerability --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0e673a55797..0ab8b929126 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ 2.12.5 8.0.28 + 8.2.0 3.0.0 UTF-8 UTF-8 @@ -93,7 +94,6 @@ 1.1.1 3.12.14 0.8.2 - 8.0.33 3.2.0 3.14.0 4.17.0 @@ -251,9 +251,9 @@ 0.22.1 - mysql - mysql-connector-java - ${mysql_driver.version} + com.mysql + mysql-connector-j + ${mysql.version} org.springframework.boot From 2f2f5ad145fd99cbf745a29836710b0ee7401ded Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 10 Jan 2025 17:18:26 -0500 Subject: [PATCH 5/7] fix security integration tests --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0ab8b929126..f720fe13efa 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,6 @@ 3.14.0 4.17.0 7.1.0 - 5.2.1 1.19.7 1.78 @@ -212,6 +211,12 @@ com.github.romain-warnan simple-java-bitly ${simple_java_bitly.version} + + + org.apache.httpcomponents + httpclient + + org.ehcache @@ -352,8 +357,6 @@ org.apache.httpcomponents.client5 httpclient5 - ${apache_httpclient.version} - test From 169cba54c9fe358b2a5bf5a5642e60672d43a3b4 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Mon, 13 Jan 2025 14:56:55 -0500 Subject: [PATCH 6/7] add back test scopes --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index f720fe13efa..a0ae2cf6e67 100644 --- a/pom.xml +++ b/pom.xml @@ -357,6 +357,7 @@ org.apache.httpcomponents.client5 httpclient5 + test @@ -393,6 +394,7 @@ commons-io commons-io 2.18.0 + test com.nimbusds From fbde89a741bbf3d89fb35e9b5c522296f025b572 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Mon, 13 Jan 2025 16:14:25 -0500 Subject: [PATCH 7/7] remove conflicting dependencies --- pom.xml | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/pom.xml b/pom.xml index a0ae2cf6e67..00f9153130e 100644 --- a/pom.xml +++ b/pom.xml @@ -385,42 +385,6 @@ spring-boot-testcontainers test - - org.apache.velocity - velocity-engine-core - 2.4.1 - - - commons-io - commons-io - 2.18.0 - test - - - com.nimbusds - nimbus-jose-jwt - 9.37.2 - - - org.bouncycastle - bcpkix-jdk18on - ${bouncy_castle.version} - - - org.bouncycastle - bc-fips - 2.0.0 - - - org.bouncycastle - bcprov-jdk18on - ${bouncy_castle.version} - - - org.bouncycastle - bctls-jdk18on - ${bouncy_castle.version} -