Skip to content

Commit

Permalink
Merge pull request cBioPortal#6 from sheridancbio/mskvocab
Browse files Browse the repository at this point in the history
Create mock MskVocabularyRepository
  • Loading branch information
averyniceday authored Sep 23, 2020
2 parents 1eb2d10 + 68373a4 commit c6964b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public TopBraidSessionManager mskVocabularySessionManager() {
return new TopBraidSessionManager(mskVocabularySessionConfiguration());
}

// @Bean
@Bean
// TODO : rename to knowledgeSystemsRepository
@Qualifier("knowledgeSystemsClinicalAttributeMetadataRepository")
public KnowledgeSystemsClinicalAttributeMetadataRepository knowledgeSystemsClinicalAttributeMetadataRepository() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,35 @@
import org.mockito.Mockito;
import org.cbioportal.cdd.model.ClinicalAttributeMetadata;
import org.cbioportal.cdd.repository.topbraid.KnowledgeSystemsClinicalAttributeMetadataRepository;
import org.cbioportal.cdd.repository.topbraid.MskVocabularyRepository;
import org.cbioportal.cdd.model.MskVocabulary;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class ClinicalDataDictionaryTestConfig {

@Bean
@Primary
@Qualifier("mockedKnowledgeSystemsClinicalAttributeMetadataRepository")
public KnowledgeSystemsClinicalAttributeMetadataRepository mockClinicalAttributesRepository() {
KnowledgeSystemsClinicalAttributeMetadataRepository mockClinicalAttributesRepository = Mockito.mock(KnowledgeSystemsClinicalAttributeMetadataRepository.class);
return mockClinicalAttributesRepository;
}

@Bean
@Primary
@Qualifier("mockedMskVocabularyRepository")
public MskVocabularyRepository mockMskVocabularyRepository() {
MskVocabularyRepository mockMskVocabularyRepository = Mockito.mock(MskVocabularyRepository.class);
Mockito.reset(mockMskVocabularyRepository);
// TODO : mock realistic behavior and write unit tests against the MskVocabularyRepository
Mockito.when(mockMskVocabularyRepository.getClinicalAttributeMetadata()).thenReturn(new ArrayList<MskVocabulary>());
return mockMskVocabularyRepository;
}

public void resetWorkingClinicalAttributesRepository(KnowledgeSystemsClinicalAttributeMetadataRepository mockClinicalAttributesRepository) {
Mockito.reset(mockClinicalAttributesRepository);
Mockito.when(mockClinicalAttributesRepository.getClinicalAttributeMetadata()).thenReturn(makeMockAttributeList());
Expand Down

0 comments on commit c6964b2

Please sign in to comment.