/**
 * 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.
 *
 * This test class is intended to run healthchecks against the observation table.
 */

package org.mousephenotype.cda.datatests.repositories.solr;

import org.apache.solr.client.solrj.SolrServerException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mousephenotype.cda.db.pojo.GenesSecondaryProject;
import org.mousephenotype.cda.solr.service.EssentialGeneService;
import org.mousephenotype.cda.solr.service.dto.EssentialGeneDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {RepositorySolrTestConfig.class})
public class EssentialGeneServiceTest {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private EssentialGeneService essentialGeneService;


	@Test
	public void testGetGeneById() throws SolrServerException, IOException {
		String mgiId = "MGI:1098687";//Aak1

		List<EssentialGeneDTO> essentialGeneDTOS = essentialGeneService.getGeneListByMgiId(mgiId);
		for(EssentialGeneDTO geneDTO: essentialGeneDTOS) {
			logger.info("Gene symbol is: " + geneDTO.getMarkerSymbol());
			logger.info("mgiAccessionId: " + geneDTO.getMgiAccession());
			logger.info("idgChr: " + geneDTO.getIdgChr());
			logger.info("idgFamily: " + geneDTO.getIdgFamily());
			logger.info("idgIDL: " + geneDTO.getIdgIdl());
			logger.info("idgSymbol: " + geneDTO.getIdgSymbol());
			logger.info("uniprot acc: " + geneDTO.getIdgUniprotAcc());
			logger.info("===================");
		}

		EssentialGeneDTO gene = essentialGeneService.getGeneByMgiId(mgiId);
		logger.info("single Gene symbol is: " + gene.getMarkerSymbol());
		logger.info("mgiAccessionId: " + gene.getMgiAccession());
		logger.info("idgChr: " + gene.getIdgChr());
		logger.info("idgFamily: " + gene.getIdgFamily());
		logger.info("idgIDL: " + gene.getIdgIdl());
		logger.info("idgSymbol: " + gene.getIdgSymbol());
		logger.info("uniprot acc: " + gene.getIdgUniprotAcc());
		logger.info("===================");
		assertTrue("Expected gene but was null", gene != null);
	}

	@Test
	public void testGetAllIdgGeneList() throws IOException, SolrServerException {
		List<EssentialGeneDTO> idgGeneDTOS = essentialGeneService.getAllIdgGeneList();
		logger.info("idgGenes size="+idgGeneDTOS.size());

//		for(EssentialGeneDTO geneDTO: idgGeneDTOS) {
//			logger.info("Gene symbol is: " + geneDTO.getMarkerSymbol());
//			logger.info("mgiAccessionId: " + geneDTO.getMgiAccession());
//			logger.info("idgChr: " + geneDTO.getIdgChr());
//			logger.info("idgFamily: " + geneDTO.getIdgFamily());
//			logger.info("idgIDL: " + geneDTO.getIdgIdl());
//			logger.info("idgSymbol: " + geneDTO.getIdgSymbol());
//			logger.info("uniprot acc: " + geneDTO.getIdgUniprotAcc());
//			logger.info("===================");
//		}
	}

	@Test
	public void getAllBySecondaryProjectIdAndGroupLabel() throws IOException, SolrServerException {
		List<EssentialGeneDTO> genes = essentialGeneService.getAllIdgGeneListByGroupLabel("Kinase");
		assert(genes.size()> 127);
	}
}

@@ -1066,69 +1066,8 @@
 th;%0A
-import org.mousephenotype.cda.db.pojo.GenesSecondaryProject;%0A
 impo
@@ -1484,165 +1484,14 @@
 til.
-HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;%0A%0Aimport static org.junit.Assert.assertEquals;
+List;%0A
 %0Aimp
@@ -2198,58 +2198,8 @@
 ));%0A
-%09%09%09logger.info(%22idgChr: %22 + geneDTO.getIdgChr());%0A
 %09%09%09l
@@ -2254,176 +2254,8 @@
 ));%0A
-%09%09%09logger.info(%22idgIDL: %22 + geneDTO.getIdgIdl());%0A%09%09%09logger.info(%22idgSymbol: %22 + geneDTO.getIdgSymbol());%0A%09%09%09logger.info(%22uniprot acc: %22 + geneDTO.getIdgUniprotAcc());%0A
 %09%09%09l
@@ -2513,239 +2513,37 @@
 %22idg
-Chr: %22 + gene.getIdgChr());%0A%09%09logger.info(%22idgFamily: %22 + gene.getIdgFamily());%0A%09%09logger.info(%22idgIDL: %22 + gene.getIdgIdl());%0A%09%09logger.info(%22idgSymbol: %22 + gene.getIdgSymbol());%0A%09%09logger.info(%22uniprot acc: %22 + gene.getIdgUniprotAcc
+Family: %22 + gene.getIdgFamily
 ());

Fix EG tests to remove fields