<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 /**
 * Copyright © 2014 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.ac.ebi.phenotype.api;

import org.apache.commons.collections.CollectionUtils;
import org.apache.solr.client.solrj.SolrServerException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mousephenotype.cda.solr.service.GeneService;
import org.mousephenotype.cda.solr.service.MpService;
import org.mousephenotype.cda.solr.service.PostQcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import uk.ac.ebi.phenotype.web.TestConfig;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.fail;

/**
 * @author ilinca
 */
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource("file:${user.home}/configfiles/${profile}/test.properties")
@SpringApplicationConfiguration(classes = TestConfig.class)
public class CoreTests {

    @Autowired
	@Qualifier("postqcService")
    private PostQcService gpService;

    @Autowired
    private GeneService gService;

    @Autowired
    private MpService mpService;

    @Test
    public void testAllGPGenesInGeneCore() throws SolrServerException {
    	System.out.println("Test if all genes in genotype-phenotype core are indexed in the gene core.");

        Set<String> gpGenes = gpService.getAllGenesWithPhenotypeAssociations();

        Set<String> gGenes = gService.getAllGenes();
        Set<String> knownToMiss = new HashSet<>();  // Ignore these genes because they only have legacy phenotype data.      
//        knownToMiss.add("MGI:3688249"); // For bug MPII-1493
//        knownToMiss.add("MGI:1861674"); 
        
        // Eliminate MGI:3688249 (bug MPII-1493)
        Collection res = CollectionUtils.subtract(gpGenes, gGenes);
        res = CollectionUtils.subtract(res, knownToMiss);

        if (res.size() > 0) {
        	System.out.println("The following genes are in in the genotype-phenotype core but not in the gene core: " + res);
        	fail("The following genes are in in the genotype-phenotype core but not in the gene core: " + res);
        }
    }<commit_msg>Added comment <commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 /**
 * Copyright © 2014 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.ac.ebi.phenotype.api;

import org.apache.commons.collections.CollectionUtils;
import org.apache.solr.client.solrj.SolrServerException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mousephenotype.cda.solr.service.GeneService;
import org.mousephenotype.cda.solr.service.MpService;
import org.mousephenotype.cda.solr.service.PostQcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import uk.ac.ebi.phenotype.web.TestConfig;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.fail;

/**
 * @author ilinca
 */
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource("file:${user.home}/configfiles/${profile}/test.properties")
@SpringApplicationConfiguration(classes = TestConfig.class)
public class CoreTests {

    @Autowired
	@Qualifier("postqcService")
    private PostQcService gpService;

    @Autowired
    private GeneService gService;

    @Autowired
    private MpService mpService;

    @Test
    public void testAllGPGenesInGeneCore() throws SolrServerException {
    	System.out.println("Test if all genes in genotype-phenotype core are indexed in the gene core.");

        Set<String> gpGenes = gpService.getAllGenesWithPhenotypeAssociations();

        Set<String> gGenes = gService.getAllGenes();
        Set<String> knownToMiss = new HashSet<>();  // Ignore these genes because they only have legacy phenotype data.      
//        knownToMiss.add("MGI:3688249"); // For bug MPII-1493
//        knownToMiss.add("MGI:1861674"); // Don't need this any more as Peter put them in iMits and they should be in now. 
        
        Collection res = CollectionUtils.subtract(gpGenes, gGenes);
        res = CollectionUtils.subtract(res, knownToMiss);

        if (res.size() > 0) {
        	System.out.println("The following genes are in in the genotype-phenotype core but not in the gene core: " + res);
        	fail("The following genes are in in the genotype-phenotype core but not in the gene core: " + res);
        }
    }
{'fraction_non_alphanumeric': 0.09337157425111536, 'fraction_numerical': 0.01131293817718292, 'mean_word_length': 4.029647435897436, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1886448', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1754, 'n_words': 537}