Commit d29ceb08 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fix unit tests

parent 29319fe1
Pipeline #51490 failed with stage
in 15 minutes and 57 seconds
......@@ -2,10 +2,12 @@ package lcsb.mapviewer.services.impl;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.poi.util.IOUtils;
import org.junit.After;
......@@ -16,12 +18,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import lcsb.mapviewer.converter.graphics.MapGenerator;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.ProjectStatus;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.SpringServiceTestConfig;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
import lcsb.mapviewer.services.interfaces.IProjectService;
import lcsb.mapviewer.services.interfaces.IUserService;
import lcsb.mapviewer.services.utils.CreateProjectParams;
......@@ -35,6 +43,9 @@ public class ProjectServiceNoTransactionTest {
@Autowired
private IProjectService projectService;
@Autowired
private IConfigurationService configurationService;
@Autowired
private IUserService userService;
......@@ -94,4 +105,26 @@ public class ProjectServiceNoTransactionTest {
projectService.removeProject(project, null, false);
}
@Test
public void uploadToBigFile() throws Exception {
Integer value = Integer
.parseInt(configurationService.getValue(ConfigurationElementType.MAX_NUMBER_OF_MAP_LEVELS).getValue());
double size = MapGenerator.TILE_SIZE * Math.pow(2, value) + 1;
Model model = new ModelFullIndexed(null);
model.setWidth(size);
model.setHeight(size);
String xml = new CellDesignerXmlParser().model2String(model);
InputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
CreateProjectParams params = createProjectParams("sample.xml", is);
projectService.createProject(params);
projectService.waitForJobQueueToEmpty();
Project project = projectService.getProjectByProjectId(ServiceTestFunctions.TEST_PROJECT_ID, true);
assertEquals(ProjectStatus.FAIL, project.getStatus());
assertEquals("ERROR", project.getLogEntries().iterator().next().getSeverity());
projectService.removeProject(project, null, false);
}
}
......@@ -7,13 +7,11 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
......@@ -43,7 +41,6 @@ import lcsb.mapviewer.commands.CopyCommand;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.converter.ComplexZipConverter;
import lcsb.mapviewer.converter.ComplexZipConverterParams;
import lcsb.mapviewer.converter.graphics.MapGenerator;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.converter.zip.ModelZipEntryFile;
import lcsb.mapviewer.converter.zip.ZipEntryFile;
......@@ -70,7 +67,6 @@ import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.overlay.DataOverlay;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.model.user.UserAnnotationSchema;
import lcsb.mapviewer.model.user.UserClassAnnotators;
......@@ -693,27 +689,6 @@ public class ProjectServiceTest extends ServiceTestFunctions {
projectService.removeProject(project, null, false);
}
@Test
public void uploadToBigFile() throws Exception {
Integer value = Integer
.parseInt(configurationService.getValue(ConfigurationElementType.MAX_NUMBER_OF_MAP_LEVELS).getValue());
double size = MapGenerator.TILE_SIZE * Math.pow(2, value) + 1;
Model model = new ModelFullIndexed(null);
model.setWidth(size);
model.setHeight(size);
String xml = new CellDesignerXmlParser().model2String(model);
InputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
CreateProjectParams params = createProjectParams("sample.xml", is);
projectService.createProject(params);
Project project = projectService.getProjectByProjectId(TEST_PROJECT_ID);
assertEquals(ProjectStatus.FAIL, project.getStatus());
assertEquals("ERROR", project.getLogEntries().iterator().next().getSeverity());
projectService.removeProject(project, null, false);
}
@Test
public void testCreateLogEntries() throws Exception {
Protein protein = new GenericProtein("id");
......
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