Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
haynescd committed Jun 11, 2024
1 parent 65d647b commit d96ce73
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void getMutatedGenes() {
var testBrca1AlterationCount = alterationCountByGenes.stream().filter(a -> Objects.equals(a.getHugoGeneSymbol(), "brca1")).findFirst();
assert(testBrca1AlterationCount.isPresent());
assertEquals(Integer.valueOf(5), testBrca1AlterationCount.get().getTotalCount());
assertEquals(1, testBrca1AlterationCount.get().getMatchingGenePanelIds().size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package org.cbioportal.service.impl;

import org.apache.commons.math3.util.Pair;
import org.cbioportal.model.*;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.AlterationCountByStructuralVariant;
import org.cbioportal.model.AlterationFilter;
import org.cbioportal.model.CNA;
import org.cbioportal.model.CopyNumberCountByGene;
import org.cbioportal.model.MolecularProfile;
import org.cbioportal.model.MolecularProfileCaseIdentifier;
import org.cbioportal.model.MutationEventType;
import org.cbioportal.model.util.Select;
import org.cbioportal.persistence.AlterationRepository;
import org.cbioportal.persistence.MolecularProfileRepository;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.service.exception.MolecularProfileNotFoundException;
import org.cbioportal.service.util.AlterationEnrichmentUtil;
import org.cbioportal.service.util.MolecularProfileUtil;
Expand All @@ -14,17 +22,25 @@
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;

import static org.mockito.Mockito.*;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class AlterationCountServiceImplTest extends BaseServiceImplTest {

@InjectMocks
private AlterationCountServiceImpl alterationCountService;
@Mock
private AlterationRepository alterationRepository;
Expand All @@ -39,6 +55,8 @@ public class AlterationCountServiceImplTest extends BaseServiceImplTest {
private MolecularProfileUtil molecularProfileUtil;
@Mock
private MolecularProfileRepository molecularProfileRepository;
@Mock
private StudyViewRepository studyViewRepository;

List<MolecularProfileCaseIdentifier> caseIdentifiers = Arrays.asList(new MolecularProfileCaseIdentifier("A", MOLECULAR_PROFILE_ID));
Select<MutationEventType> mutationEventTypes = Select.byValues(Arrays.asList(MutationEventType.missense_mutation));
Expand All @@ -64,6 +82,11 @@ public class AlterationCountServiceImplTest extends BaseServiceImplTest {

@Before
public void setup() {
MockitoAnnotations.openMocks(this);

alterationCountService = new AlterationCountServiceImpl(alterationRepository, alterationEnrichmentUtil,
alterationEnrichmentUtilCna, alterationEnrichmentUtilStructVar, molecularProfileRepository, studyViewRepository);

MolecularProfile molecularProfile = new MolecularProfile();
molecularProfile.setStableId(MOLECULAR_PROFILE_ID);
molecularProfile.setCancerStudyIdentifier(STUDY_ID);
Expand Down

0 comments on commit d96ce73

Please sign in to comment.