Commit 8dd168e6 authored by Piotr Gawron's avatar Piotr Gawron

autowired beans moved to proper tests classes

parent 3e196ab2
......@@ -42,22 +42,13 @@ public abstract class ServiceTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
private static Map<String, Model> models = new HashMap<String, Model>();
private static Map<String, Model> models = new HashMap<>();
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
public double EPSILON = 1e-6;
@Autowired
protected DrugbankHTMLParser drugBankHTMLParser;
@Autowired
protected ModelAnnotator modelAnnotator;
@Autowired
protected IConfigurationService configurationService;
@Autowired
protected IModelService modelService;
@Autowired
protected ILayoutService layoutService;
protected IConfigurationService configurationService;
@Autowired
protected SearchHistoryDao searchHistoryDao;
......@@ -65,15 +56,9 @@ public abstract class ServiceTestFunctions {
@Autowired
protected PasswordEncoder passwordEncoder;
@Autowired
protected IUserService userService;
@Autowired
protected ISearchService searchService;
@Autowired
protected IDrugService drugService;
@Autowired
protected IChemicalService chemicalService;
......@@ -83,21 +68,12 @@ public abstract class ServiceTestFunctions {
@Autowired
protected ProjectDao projectDao;
@Autowired
protected ModelDao modelDao;
@Autowired
protected ICommentService commentService;
@Autowired
protected UserDao userDao;
@Autowired
protected CommentDao commentDao;
@Autowired
protected DbUtils dbUtils;
private Logger logger = LogManager.getLogger(ServiceTestFunctions.class);
private Logger logger = LogManager.getLogger();
private MinervaLoggerAppender appender;
@Before
......
......@@ -9,6 +9,7 @@ import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import lcsb.mapviewer.model.Project;
......@@ -16,17 +17,29 @@ import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.persist.dao.map.CommentDao;
import lcsb.mapviewer.persist.dao.map.ModelDao;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.interfaces.ICommentService;
@Rollback(true)
public class CommentServiceTest extends ServiceTestFunctions {
static Logger logger = LogManager.getLogger(CommentServiceTest.class);
static Logger logger = LogManager.getLogger();
Model model;
Project project;
Element alias;
Element alias2;
private String projectId = "Some_id";
@Autowired
protected ModelDao modelDao;
@Autowired
protected ICommentService commentService;
@Autowired
protected CommentDao commentDao;
@Before
public void setUp() throws Exception {
dbUtils.setAutoFlush(true);
......@@ -64,11 +77,16 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public void testGetAgregatedComments() throws Exception {
commentService.addComment("John Doe", "a@a.pl", "Conteneta 1", new Point2D.Double(0, 1), alias, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetb 2", new Point2D.Double(0, 2), alias, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 3", new Point2D.Double(0, 3), alias2, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 4", new Point2D.Double(0, 4), null, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 5", new Point2D.Double(0, 5), null, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Conteneta 1", new Point2D.Double(0, 1), alias, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetb 2", new Point2D.Double(0, 2), alias, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 3", new Point2D.Double(0, 3), alias2, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 4", new Point2D.Double(0, 4), null, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
commentService.addComment("John Doe", "a@a.pl", "Contenetc 5", new Point2D.Double(0, 5), null, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
CommentService service = new CommentService(null, null, null, null);
service.setCommentDao(commentDao);
List<List<Comment>> comments = service.getAgregatedComments(model, null);
......@@ -89,7 +107,8 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public void testAddComment() throws Exception {
long counter = commentService.getCommentCount();
Comment feedback = commentService.addComment("a", "b", "c", new Point2D.Double(0, 0), null, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Comment feedback = commentService.addComment("a", "b", "c", new Point2D.Double(0, 0), null, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
long counter2 = commentService.getCommentCount();
assertEquals(counter + 1, counter2);
commentDao.delete(feedback);
......@@ -109,7 +128,8 @@ public class CommentServiceTest extends ServiceTestFunctions {
public void testAddCommentForAlias() throws Exception {
Element alias = model.getElementByElementId("sa1");
long counter = commentService.getCommentCount();
Comment feedback = commentService.addComment("a", "b", "c", new Point2D.Double(0, 0), alias, false, model, userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Comment feedback = commentService.addComment("a", "b", "c", new Point2D.Double(0, 0), alias, false, model,
userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
long counter2 = commentService.getCommentCount();
assertEquals(counter + 1, counter2);
commentDao.delete(feedback);
......
......@@ -2,11 +2,10 @@ package lcsb.mapviewer.services.impl;
import static org.junit.Assert.*;
import java.awt.*;
import java.awt.Color;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
......@@ -28,12 +27,13 @@ import lcsb.mapviewer.persist.dao.map.LayoutDao;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.interfaces.ILayoutService;
import lcsb.mapviewer.services.interfaces.ILayoutService.CreateLayoutParams;
import lcsb.mapviewer.services.interfaces.IUserService;
import lcsb.mapviewer.services.utils.ColorSchemaReader;
import lcsb.mapviewer.services.utils.EmailSender;
import lcsb.mapviewer.services.utils.data.ColorSchemaColumn;
public class LayoutServiceTest extends ServiceTestFunctions {
Logger logger = LogManager.getLogger(LayoutServiceTest.class);
Logger logger = LogManager.getLogger();
Project project = null;
Model model = null;
......@@ -48,9 +48,14 @@ public class LayoutServiceTest extends ServiceTestFunctions {
@Autowired
ILayoutService layoutService;
ColorExtractor colorExtractor = new ColorExtractor(Color.RED, Color.GREEN, Color.BLUE);
private User user, user2;
@Autowired
protected IUserService userService;
@Before
public void setUp() throws Exception {
// we use custom threads because in layout service there is commit method
......
......@@ -18,6 +18,7 @@ import org.primefaces.model.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import lcsb.mapviewer.annotation.services.ModelAnnotator;
import lcsb.mapviewer.commands.CopyCommand;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.converter.ComplexZipConverter;
......@@ -37,6 +38,7 @@ import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.map.LayoutDao;
import lcsb.mapviewer.persist.dao.map.species.ElementDao;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.overlay.AnnotatedObjectTreeRow;
import lcsb.mapviewer.services.utils.CreateProjectParams;
import lcsb.mapviewer.services.utils.data.BuildInLayout;
......@@ -53,6 +55,12 @@ public class ProjectServiceTest extends ServiceTestFunctions {
private ZipEntryFileFactory zefFactory = new ZipEntryFileFactory();
private String projectId = "Some_id";
@Autowired
private ModelAnnotator modelAnnotator;
@Autowired
protected IModelService modelService;
@Before
public void setUp() throws Exception {
}
......
......@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.data.Drug;
import lcsb.mapviewer.annotation.data.Target;
import lcsb.mapviewer.annotation.services.DrugbankHTMLParser;
import lcsb.mapviewer.annotation.services.TaxonomyBackend;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -23,11 +24,18 @@ import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.search.DbSearchCriteria;
public class DrugServiceTest extends ServiceTestFunctions {
Logger logger = LogManager.getLogger(DrugServiceTest.class);
Logger logger = LogManager.getLogger();
@Autowired
ElementDao elementDao;
@Autowired
private DrugbankHTMLParser drugBankHTMLParser;
@Autowired
private IDrugService drugService;
@Before
public void setUp() throws Exception {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment