package uk.ac.ebi.quickgo.geneproduct.service;

import uk.ac.ebi.quickgo.geneproduct.common.GeneProductRepository;
import uk.ac.ebi.quickgo.geneproduct.common.document.GeneProductDocument;
import uk.ac.ebi.quickgo.geneproduct.model.GeneProduct;
import uk.ac.ebi.quickgo.geneproduct.service.converter.GeneProductDocConverter;
import uk.ac.ebi.quickgo.rest.service.ServiceHelper;
import uk.ac.ebi.quickgo.rest.service.ServiceHelperImpl;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author Tony Wardell
 * Date: 29/03/2016
 * Time: 10:56
 * Created with IntelliJ IDEA.
 */
public class GeneProductServiceImpl implements GeneProductService {

	private final ServiceHelper serviceHelper;
	private final GeneProductRepository geneProductRepository;
	private final GeneProductDocConverter converter;

	public GeneProductServiceImpl(ServiceHelper serviceHelper, GeneProductRepository geneProductRepository, GeneProductDocConverter converter) {
		this.serviceHelper = serviceHelper;
		this.geneProductRepository = geneProductRepository;
		this.converter = converter;
	}

	@Override
	public List<GeneProduct> findById(String[] ids) {
		return convertDocs(geneProductRepository.findById(serviceHelper.buildIdList(ids)));
	}

	protected List<GeneProduct> convertDocs(List<GeneProductDocument> docs) {
		return docs
				.stream()
				.map(converter::convert)
				.collect(Collectors.toList());
	}
}

@@ -41,16 +41,100 @@
 rvice;%0A%0A
+import com.google.common.base.Objects;%0Aimport com.google.common.base.Preconditions;%0A
 import u
@@ -1041,133 +1041,895 @@
 ) %7B%0A
-%09%09this.serviceHelper = serviceHelper;%0A%09%09this.geneProductRepository = geneProductRepository;%0A%09%09this.converter = converter;%0A%09%7D%0A
+%0A%09%09java.util.Objects.requireNonNull(serviceHelper, %22The ServiceHelper instance passed to the constructor of %22 +%0A%09%09%09%09%22GeneProductServiceImpl should not be null.%22);%0A%09%09java.util.Objects.requireNonNull(geneProductRepository, %22The GeneProductRepository instance passed to the constructor of %22 +%0A%09%09%09%09%22GeneProductServiceImpl should not be null.%22);%0A%09%09java.util.Objects.requireNonNull(converter, %22The GeneProductDocConverter instance passed to the constructor of %22 +%0A%09%09%09%09%22GeneProductServiceImpl should not be null.%22);%0A%09%09this.serviceHelper = serviceHelper;%0A%09%09this.geneProductRepository = geneProductRepository;%0A%09%09this.converter = converter;%0A%09%7D%0A%0A%09/**%0A%09 * Find the core data set stored for a specified list of geneProduct IDs.%0A%09 * @param ids the ontology IDs%0A%09 * @return a %7B@link List%7D of %7B@link GeneProduct%7D instances corresponding to the gene product ids containing the%0A%09 * chosen information%0A%09 */
 %0A%09@O

Add preconditions to check that the dependencies are valid.