1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*******************************************************************************
* Copyright (c) 2013 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.client.integration.tests.integration.ui.skynet;
import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
import org.eclipse.osee.client.test.framework.TestInfo;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.skynet.render.HTMLRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
/**
* @author Marc Potter
*/
public class HtmlRendererTest {
@Rule
public OseeClientIntegrationRule integration = new OseeClientIntegrationRule(OSEE_CLIENT_DEMO);
@Rule
public OseeLogMonitorRule monitorRule = new OseeLogMonitorRule();
@Rule
public TestInfo method = new TestInfo();
private static String INPUT_HTML;
private static String EXPECTED_HTML;
private final static String LEGACY_ID = "ABC-123,ABC-234";
private final static String PARAGRAPH_NUMBER = "1.2.3.4";
private BranchId rootBranch;
private List<Artifact> theArtifacts = null;
private HTMLRenderer renderer = null;
@BeforeClass
public static void loadTemplateInfo() throws Exception {
INPUT_HTML = getResourceData("htmlRenderer/htmlTestInput.htm");
EXPECTED_HTML = getResourceData("htmlRenderer/htmlExpectOutput.htm");
}
@Before
public void setUp() throws OseeCoreException {
Artifact Folder;
Artifact htmlArtifact;
renderer = new HTMLRenderer();
// create example artifact
theArtifacts = new ArrayList<>();
String branchName = method.getQualifiedTestName();
rootBranch = BranchManager.createTopLevelBranch(branchName);
Artifact programRoot = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(rootBranch);
Folder = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, rootBranch, "Folder");
programRoot.addChild(Folder);
Folder.persist("FOLDER SETUP");
htmlArtifact = ArtifactTypeManager.addArtifact(CoreArtifactTypes.HTMLArtifact, rootBranch, "Html Artifact");
htmlArtifact.addAttributeFromString(CoreAttributeTypes.LegacyId, LEGACY_ID);
htmlArtifact.addAttributeFromString(CoreAttributeTypes.ParagraphNumber, PARAGRAPH_NUMBER);
htmlArtifact.addAttributeFromString(CoreAttributeTypes.HTMLContent, INPUT_HTML);
htmlArtifact.persist("create sample artifact");
theArtifacts.add(htmlArtifact);
}
@After
public void tearDown() throws Exception {
if (BranchManager.branchExists(rootBranch)) {
BranchManager.purgeBranch(rootBranch);
}
}
@Test
public void testHtmlRender() throws Exception {
InputStream stream = renderer.getRenderInputStream(PresentationType.PREVIEW, theArtifacts);
String theInput = Lib.inputStreamToString(stream);
Assert.assertEquals("Expect HTMl does not equal rendered HTML", theInput, EXPECTED_HTML);
}
private static String getResourceData(String relativePath) throws IOException {
String value = Lib.fileToString(HtmlRendererTest.class, "support/" + relativePath);
Assert.assertTrue(Strings.isValid(value));
return value;
}
}
|