Skip to content
Snippets Groups Projects
Commit 71a77e79 authored by piotr.gawron's avatar piotr.gawron
Browse files

fix on layout tests

parent 7d3a8beb
No related branches found
No related tags found
1 merge request!1Issue 37
......@@ -46,6 +46,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
Model model = null;
String projectId = "Some_id";
String clearProjectId = "Some_id2";
@Autowired
LayoutDao layoutDao;
......@@ -65,13 +66,18 @@ public class LayoutServiceTest extends ServiceTestFunctions {
projectDao.delete(project);
}
project = projectDao.getProjectByProjectId(clearProjectId);
if (project != null) {
projectDao.delete(project);
}
project = new Project();
CellDesignerXmlParser parser = new CellDesignerXmlParser();
model = parser.createModel(new ConverterParams().filename("testFiles/sample.xml"));
project.addModel(model);
project.setProjectId("Some_id2");
project.setProjectId(projectId);
projectService.addProject(project);
......@@ -338,7 +344,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
localModel.addSubmodelConnection(connection);
localProject.addModel(localModel);
localProject.setProjectId("Some_id");
localProject.setProjectId(clearProjectId);
projectService.addProject(localProject);
......@@ -392,29 +398,41 @@ public class LayoutServiceTest extends ServiceTestFunctions {
@Test
public void testInputDataInLayout() throws Exception {
try {
logger.debug("A");
List<LayoutView> layouts = layoutService.getCustomLayouts(model, user);
logger.debug("A");
assertNotNull(layouts);
assertEquals(0, layouts.size());
userService.setUserPrivilege(user, new BasicPrivilege(1, PrivilegeType.CUSTOM_LAYOUTS, user));
logger.debug("A");
CreateLayoutParams params = new CreateLayoutParams().name("Test").//
directory("testDir").//
model(model).//
colorInputStream(new FileInputStream("testFiles/enricoData/ge001.txt")).//
user(user).//
async(false);
logger.debug("A");
LayoutView row = layoutService.createLayout(params);
logger.debug("A");
assertNotNull(row);
assertNotNull(row.getIdObject());
logger.debug("A");
assertTrue("true".equalsIgnoreCase(row.getInputDataAvailable()));
logger.debug("A");
byte[] inputData = layoutService.getInputDataForLayout(row);
logger.debug("A");
assertNotNull(inputData);
logger.debug("A");
byte[] originalData = IOUtils.toByteArray(new FileInputStream("testFiles/enricoData/ge001.txt"));
logger.debug("A");
assertEquals(new String(originalData, StandardCharsets.UTF_8), new String(inputData, StandardCharsets.UTF_8));
logger.debug("A");
layoutService.removeLayout(row, null);
logger.debug("A");
} catch (Exception e) {
e.printStackTrace();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment