1 package org.cateproject.view.reference;
2
3 import java.io.File;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import org.cateproject.controller.editor.PartialPropertyEditor;
8 import org.cateproject.controller.flow.action.reference.UploadAction;
9 import org.cateproject.controller.flow.action.upload.ParsedMatrix;
10 import org.cateproject.view.CATEViewTest;
11 import org.junit.Test;
12 import org.springframework.binding.message.DefaultMessageContext;
13 import org.springframework.core.convert.support.GenericConversionService;
14 import org.springframework.web.servlet.ModelAndView;
15
16 import eu.etaxonomy.cdm.model.reference.Generic;
17 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
18
19
20 public class ReferencePageTest extends CATEViewTest {
21
22 @Test
23 public void testEditReference() {
24 Generic generic = new Generic();
25 generic.setTitleCache("Reference Title",true);
26
27 Map<String,Object> referenceData = new HashMap<String,Object>();
28 referenceData.put("object",generic);
29 referenceData.put("flowExecutionUrl", "/reference/edit?execution=e1s1");
30 outputForm("reference/edit/edit",
31 "target/generated-sources/mock/reference/edit/edit.html",
32 "object",
33 Generic.class,
34 referenceData,
35 "GET",
36 null,
37 new HashMap<String,String>());
38 }
39
40 @Test
41 public void testReviewReference() {
42 Generic generic = new Generic();
43 generic.setTitleCache("Reference Title",true);
44 Map<String,Object> referenceData = new HashMap<String,Object>();
45 referenceData.put("object",generic);
46 referenceData.put("flowExecutionUrl", "/reference/edit?execution=e1s1");
47 outputForm("reference/edit/review",
48 "target/generated-sources/mock/reference/edit/review.html",
49 "object",
50 Generic.class,
51 referenceData,
52 "GET",
53 null,
54 new HashMap<String,String>());
55 }
56
57 @Test
58 public void testIndexPage() {
59 ModelAndView modelAndView = new ModelAndView("reference/index");
60 ReferenceBase reference = dataSet.getReferences().get(0);
61 modelAndView.addObject("object", reference );
62
63 outputMock(modelAndView,"target/generated-sources/mock/reference/Index.html");
64 }
65
66 @Test
67 public void testUploadPage() throws Exception {
68 UploadAction uploadAction = new UploadAction();
69 GenericConversionService conversionService = new GenericConversionService();
70 conversionService.addConverter(new PartialPropertyEditor());
71 uploadAction.setConversionService(conversionService);
72
73 ParsedMatrix parsedMatrix = uploadAction.constructMatrixFromFile(new File("./src/test/resources/org/cateproject/view/test.xls"));
74
75 uploadAction.bindMatrix(parsedMatrix, new DefaultMessageContext());
76
77 Map<String,Object> referenceData = new HashMap<String,Object>();
78 referenceData.put("object",parsedMatrix);
79 referenceData.put("flowExecutionUrl", "/reference/upload?execution=e1s1");
80 outputForm("common/edit/editMatrix",
81 "target/generated-sources/mock/reference/edit/editMatrix.html",
82 "object",
83 ParsedMatrix.class,
84 referenceData,
85 "GET",
86 null,
87 new HashMap<String,String>());
88 }
89 }