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 |
|
package info.magnolia.module.resources.setup; |
35 |
|
|
36 |
|
import static info.magnolia.module.resources.setup.TemplateMigrationTask.*; |
37 |
|
import static info.magnolia.resourceloader.dummy.DummyResourceOrigin.Differentiator.qux; |
38 |
|
import static info.magnolia.test.hamcrest.ExceptionMatcher.strictlyInstanceOf; |
39 |
|
import static info.magnolia.test.hamcrest.ExecutionMatcher.*; |
40 |
|
import static info.magnolia.test.hamcrest.NodeMatchers.hasProperty; |
41 |
|
import static org.hamcrest.CoreMatchers.*; |
42 |
|
import static org.junit.Assert.*; |
43 |
|
import static org.mockito.Mockito.*; |
44 |
|
|
45 |
|
import info.magnolia.context.MgnlContext; |
46 |
|
import info.magnolia.context.SystemContext; |
47 |
|
import info.magnolia.jcr.util.NodeTypes; |
48 |
|
import info.magnolia.jcr.util.NodeUtil; |
49 |
|
import info.magnolia.module.InstallContext; |
50 |
|
import info.magnolia.module.delta.Task; |
51 |
|
import info.magnolia.module.delta.TaskExecutionException; |
52 |
|
import info.magnolia.repository.RepositoryManager; |
53 |
|
import info.magnolia.resourceloader.ResourceOrigin; |
54 |
|
import info.magnolia.resourceloader.dummy.DummyResourceOrigin; |
55 |
|
import info.magnolia.resourceloader.jcr.JcrResourceOrigin; |
56 |
|
import info.magnolia.resourceloader.jcr.JcrResourceOriginFactory; |
57 |
|
import info.magnolia.resourceloader.layered.LayeredResourceOrigin; |
58 |
|
import info.magnolia.resourceloader.layered.LayeredResourceOriginFactory; |
59 |
|
import info.magnolia.test.ComponentsTestUtil; |
60 |
|
import info.magnolia.test.hamcrest.Execution; |
61 |
|
import info.magnolia.test.mock.MockContext; |
62 |
|
import info.magnolia.test.mock.jcr.MockSession; |
63 |
|
|
64 |
|
import java.util.Calendar; |
65 |
|
|
66 |
|
import javax.jcr.Node; |
67 |
|
import javax.jcr.RepositoryException; |
68 |
|
import javax.jcr.Session; |
69 |
|
|
70 |
|
import org.junit.Before; |
71 |
|
import org.junit.Test; |
72 |
|
|
73 |
|
import com.google.inject.util.Providers; |
74 |
|
|
75 |
|
|
76 |
|
@link@link |
77 |
|
|
|
|
| 98.1% |
Uncovered Elements: 3 (162) |
Complexity: 25 |
Complexity Density: 0.19 |
|
78 |
|
public class TemplateMigrationTaskTest { |
79 |
|
|
80 |
|
private TemplateMigrationTask task; |
81 |
|
private InstallContext installContext; |
82 |
|
private Session templateSession; |
83 |
|
private Session resourceSession; |
84 |
|
private LayeredResourceOrigin origin; |
85 |
|
|
86 |
|
private MockContext context; |
87 |
|
private RepositoryManager repositoryManager; |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
|
89 |
13 |
@Before... |
90 |
|
public void setUp() throws Exception { |
91 |
13 |
context = new MockContext(); |
92 |
|
|
93 |
13 |
templateSession = new MockSession(TemplateMigrationTask.TEMPLATES_WORKSPACE); |
94 |
13 |
resourceSession = new MockSession(JcrResourceOrigin.RESOURCES_WORKSPACE); |
95 |
13 |
context.addSession(TemplateMigrationTask.TEMPLATES_WORKSPACE, templateSession); |
96 |
13 |
context.addSession(JcrResourceOrigin.RESOURCES_WORKSPACE, resourceSession); |
97 |
|
|
98 |
13 |
installContext = mock(InstallContext.class); |
99 |
13 |
when(installContext.getJCRSession(TemplateMigrationTask.TEMPLATES_WORKSPACE)).thenReturn(templateSession); |
100 |
13 |
when(installContext.getJCRSession(JcrResourceOrigin.RESOURCES_WORKSPACE)).thenReturn(resourceSession); |
101 |
|
|
102 |
|
|
103 |
13 |
JcrResourceOrigin jcrResourceOrigin = new JcrResourceOriginFactory(Providers.<SystemContext>of(context)).create("jcr"); |
104 |
13 |
origin = new LayeredResourceOriginFactory().create("layeredOrigin", new ResourceOrigin[]{jcrResourceOrigin}); |
105 |
|
|
106 |
13 |
ComponentsTestUtil.setInstance(ResourceOrigin.class, origin); |
107 |
|
|
108 |
13 |
repositoryManager = mock(RepositoryManager.class); |
109 |
13 |
when(repositoryManager.hasWorkspace(eq(TemplateMigrationTask.TEMPLATES_WORKSPACE))).thenReturn(true); |
110 |
13 |
ComponentsTestUtil.setInstance(RepositoryManager.class, repositoryManager); |
111 |
|
|
112 |
13 |
task = new TemplateMigrationTask(); |
113 |
|
} |
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
115 |
1 |
@Test... |
116 |
|
public void templateThatIsNotEnabledWillNotBeHandled() throws Exception { |
117 |
1 |
origin = mock(LayeredResourceOrigin.class); |
118 |
1 |
ComponentsTestUtil.setInstance(ResourceOrigin.class, origin); |
119 |
|
|
120 |
|
|
121 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", true, false, "some_text"); |
122 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
123 |
|
|
124 |
1 |
NodeUtil.createPath(resourceSession.getRootNode(), "test-template.ftl", NodeTypes.Content.NAME); |
125 |
|
|
126 |
|
|
127 |
1 |
task.doExecute(installContext); |
128 |
|
|
129 |
|
|
130 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
131 |
1 |
assertThat("We want to make sure that the task does NOT copy/migrate the template node", |
132 |
|
resourceSession.getNode("/test-template.ftl"), not(hasProperty(PROPERTY_AUTO_IMPORT))); |
133 |
|
|
134 |
|
|
135 |
1 |
verify(origin, never()).hasPath(anyString()); |
136 |
1 |
verify(origin, never()).getByPath(anyString()); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
139 |
1 |
@Test... |
140 |
|
public void templateWillBeDeletedWhenAutoImportTrueAndResourceExists() throws Exception { |
141 |
|
|
142 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", true, true, "some_text"); |
143 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
144 |
|
|
145 |
1 |
NodeUtil.createPath(resourceSession.getRootNode(), "test-template.ftl", NodeTypes.Content.NAME); |
146 |
|
|
147 |
|
|
148 |
1 |
task.doExecute(installContext); |
149 |
|
|
150 |
|
|
151 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
152 |
1 |
assertThat("We want to make sure that the task does NOT copy/migrate the template node", |
153 |
|
resourceSession.getNode("/test-template.ftl"), not(hasProperty(PROPERTY_AUTO_IMPORT))); |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
156 |
1 |
@Test... |
157 |
|
public void templateWillBeDeletedWhenAutoImportFalseAndResourceExistsWithSameContent() throws Exception { |
158 |
|
|
159 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", false, true, "some_text"); |
160 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
161 |
|
|
162 |
1 |
final Node resourcesTestTemplateNode = NodeUtil.createPath(resourceSession.getRootNode(), "test-template.ftl", NodeTypes.Content.NAME); |
163 |
1 |
resourcesTestTemplateNode.setProperty(PROPERTY_TEXT, "some_text"); |
164 |
|
|
165 |
|
|
166 |
1 |
task.doExecute(installContext); |
167 |
|
|
168 |
|
|
169 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
170 |
1 |
assertThat("We want to make sure that the task does NOT copy/migrate the template node", |
171 |
|
resourceSession.getNode("/test-template.ftl"), not(hasProperty(PROPERTY_AUTO_IMPORT))); |
172 |
|
} |
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
174 |
1 |
@Test... |
175 |
|
public void taskWillFailWhenAutoImportFalseAndResourceExistsWithDifferentContent() throws Exception { |
176 |
|
|
177 |
1 |
createLegacyTemplateNode(templateSession.getRootNode(), "test-template", false, true, "some_text"); |
178 |
|
|
179 |
1 |
final Node resourcesTestTemplateNode = NodeUtil.createPath(resourceSession.getRootNode(), "test-template.ftl", NodeTypes.Content.NAME); |
180 |
1 |
resourcesTestTemplateNode.setProperty(PROPERTY_TEXT, "other_text"); |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
1 |
assertThat(new Execution() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
1 |
@Override... |
186 |
|
public void evaluate() throws Exception { |
187 |
1 |
task.doExecute(installContext); |
188 |
|
} |
189 |
|
}, throwsAnException(strictlyInstanceOf(TaskExecutionException.class).withMessage(containsString("Cannot proceed with template migration")))); |
190 |
|
} |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
192 |
1 |
@Test... |
193 |
|
public void taskWillNotFailWhenRepositoryExceptionIsEncounteredWhileGettingSession() throws Exception { |
194 |
|
|
195 |
1 |
when(installContext.getJCRSession(TemplateMigrationTask.TEMPLATES_WORKSPACE)).thenThrow(new RepositoryException("This exception is thrown on purpose")); |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
1 |
assertThat(new Execution() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
1 |
@Override... |
201 |
|
public void evaluate() throws Exception { |
202 |
1 |
task.doExecute(installContext); |
203 |
|
} |
204 |
|
}, throwsNothing()); |
205 |
|
|
206 |
1 |
verify(installContext).info("Could not get session for workspace 'templates'. Not running template migration task."); |
207 |
|
} |
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
209 |
1 |
@Test... |
210 |
|
public void taskWillNotFailWhenNoTemplatesWorkspaceEncountered() throws Exception { |
211 |
|
|
212 |
1 |
when(repositoryManager.hasWorkspace(TemplateMigrationTask.TEMPLATES_WORKSPACE)).thenReturn(false); |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
1 |
assertThat(new Execution() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
217 |
1 |
@Override... |
218 |
|
public void evaluate() throws Exception { |
219 |
1 |
task.doExecute(installContext); |
220 |
|
} |
221 |
|
}, throwsNothing()); |
222 |
|
|
223 |
1 |
verify(installContext).info("Inplace-templating might not be installed. Not running template migration task."); |
224 |
|
} |
225 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
226 |
1 |
@Test... |
227 |
|
public void templateIsMigratedWhenAutoImportTrueAndNoResourceExist() throws Exception { |
228 |
|
|
229 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", true, true, "some_text"); |
230 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
231 |
1 |
final String newTemplateNodePath = testTemplateNodePath + ".ftl"; |
232 |
|
|
233 |
|
|
234 |
1 |
task.doExecute(installContext); |
235 |
|
|
236 |
|
|
237 |
1 |
assertTrue(resourceSession.itemExists(newTemplateNodePath)); |
238 |
1 |
assertTemplateResource(resourceSession.getNode(newTemplateNodePath), true, "some_text"); |
239 |
|
|
240 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
241 |
|
} |
242 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
243 |
1 |
@Test... |
244 |
|
public void templateIsMigratedWhenAutoImportFalseAndNoResourceExist() throws Exception { |
245 |
|
|
246 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", false, true, "some_other_text"); |
247 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
248 |
1 |
final String newTemplateNodePath = testTemplateNodePath + ".ftl"; |
249 |
|
|
250 |
|
|
251 |
1 |
task.doExecute(installContext); |
252 |
|
|
253 |
|
|
254 |
1 |
assertTrue(resourceSession.itemExists(newTemplateNodePath)); |
255 |
1 |
assertTemplateResource(resourceSession.getNode(newTemplateNodePath), false, "some_other_text"); |
256 |
|
|
257 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
258 |
|
} |
259 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
260 |
1 |
@Test... |
261 |
|
public void templateIsMigratedWhenAutoImportFalseAndResourceInOtherOriginExist() throws Exception { |
262 |
1 |
MgnlContext.setInstance(context); |
263 |
|
|
264 |
|
|
265 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", false, true, "some_text"); |
266 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
267 |
1 |
final String newTemplateNodePath = testTemplateNodePath + ".ftl"; |
268 |
|
|
269 |
|
|
270 |
1 |
final DummyResourceOrigin dummyOrigin = new DummyResourceOrigin(qux, null, null, new String[]{newTemplateNodePath}); |
271 |
1 |
final JcrResourceOrigin jcrResourceOrigin = new JcrResourceOriginFactory(Providers.of((SystemContext) MgnlContext.getInstance())).create("jcr"); |
272 |
1 |
origin = new LayeredResourceOriginFactory().create("layeredOrigin", new ResourceOrigin[]{dummyOrigin, jcrResourceOrigin}); |
273 |
|
|
274 |
1 |
ComponentsTestUtil.setInstance(ResourceOrigin.class, origin); |
275 |
|
|
276 |
|
|
277 |
1 |
task.doExecute(installContext); |
278 |
|
|
279 |
|
|
280 |
1 |
assertTrue(resourceSession.itemExists(newTemplateNodePath)); |
281 |
1 |
assertTemplateResource(resourceSession.getNode(newTemplateNodePath), false, "some_text"); |
282 |
|
|
283 |
1 |
assertTrue("We want to make sure that nothing gets deleted", templateSession.itemExists(testTemplateNodePath)); |
284 |
|
} |
285 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
286 |
1 |
@Test... |
287 |
|
public void templateIsMigratedWhenAutoImportTrueAndNoResourceExistAndTemplateIsInFolderThatDoesNotExistInDest() throws Exception { |
288 |
|
|
289 |
1 |
final Node folderNode = NodeUtil.createPath(templateSession.getRootNode(), "folder", NodeTypes.Folder.NAME); |
290 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(folderNode, "test-template", true, true, "some_text"); |
291 |
1 |
final String testTemplateNodePath = testTemplateNode.getPath(); |
292 |
1 |
final String newTemplateNodePath = testTemplateNodePath + ".ftl"; |
293 |
|
|
294 |
|
|
295 |
1 |
task.doExecute(installContext); |
296 |
|
|
297 |
|
|
298 |
1 |
assertTrue(resourceSession.itemExists(newTemplateNodePath)); |
299 |
1 |
assertTemplateResource(resourceSession.getNode(newTemplateNodePath), true, "some_text"); |
300 |
|
|
301 |
1 |
assertTrue(templateSession.itemExists("/folder")); |
302 |
1 |
assertTrue(templateSession.itemExists(testTemplateNodePath)); |
303 |
|
} |
304 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
305 |
1 |
@Test... |
306 |
|
public void templateIsMigratedAndActivationStatusIsNotCopied() throws Exception { |
307 |
|
|
308 |
1 |
final Calendar calendar = Calendar.getInstance(); |
309 |
1 |
final Node testTemplateNode = createLegacyTemplateNode(templateSession.getRootNode(), "test-template", null, true, null); |
310 |
1 |
testTemplateNode.setProperty(NodeTypes.Activatable.ACTIVATION_STATUS, true); |
311 |
1 |
testTemplateNode.setProperty(NodeTypes.Activatable.LAST_ACTIVATED, calendar); |
312 |
1 |
testTemplateNode.setProperty(NodeTypes.LastModified.LAST_MODIFIED, calendar); |
313 |
1 |
testTemplateNode.setProperty(NodeTypes.LastModified.LAST_MODIFIED_BY, "yet-other-guy"); |
314 |
1 |
testTemplateNode.setProperty(NodeTypes.Created.CREATED, calendar); |
315 |
1 |
testTemplateNode.setProperty(NodeTypes.Created.CREATED_BY, "this-other-guy"); |
316 |
|
|
317 |
1 |
final String newTemplateNodePath = testTemplateNode.getPath() + ".ftl"; |
318 |
|
|
319 |
1 |
assertThat(NodeTypes.Activatable.getActivationStatus(testTemplateNode), is(NodeTypes.Activatable.ACTIVATION_STATUS_ACTIVATED)); |
320 |
|
|
321 |
1 |
Thread.sleep(1); |
322 |
|
|
323 |
|
|
324 |
1 |
task.doExecute(installContext); |
325 |
|
|
326 |
|
|
327 |
1 |
assertTrue(resourceSession.itemExists(newTemplateNodePath)); |
328 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), not(hasProperty(NodeTypes.Activatable.ACTIVATION_STATUS))); |
329 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), not(hasProperty(NodeTypes.Activatable.LAST_ACTIVATED))); |
330 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), not(hasProperty(NodeTypes.Activatable.LAST_ACTIVATED_BY))); |
331 |
|
|
332 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), hasProperty(NodeTypes.Created.CREATED, calendar.getTime())); |
333 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), hasProperty(NodeTypes.Created.CREATED_BY, "this-other-guy")); |
334 |
|
|
335 |
|
|
336 |
|
|
337 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), not(hasProperty(NodeTypes.LastModified.LAST_MODIFIED))); |
338 |
1 |
assertThat(resourceSession.getNode(newTemplateNodePath), not(hasProperty(NodeTypes.LastModified.LAST_MODIFIED_BY))); |
339 |
|
} |
340 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
341 |
1 |
@Test... |
342 |
|
public void makeSureAdditionalTaskIsExecutedWhenMigrationPasses() throws Exception { |
343 |
|
|
344 |
1 |
final Task onSuccessTask = mock(Task.class); |
345 |
1 |
task = new TemplateMigrationTask(onSuccessTask); |
346 |
|
|
347 |
|
|
348 |
1 |
task.execute(installContext); |
349 |
|
|
350 |
|
|
351 |
1 |
verify(onSuccessTask, times(1)).execute(installContext); |
352 |
|
} |
353 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
1PASS
|
|
354 |
1 |
@Test... |
355 |
|
public void makeSureAdditionalTaskIsNotExecutedWhenMigrationIsNotPassing() throws Exception { |
356 |
|
|
357 |
|
|
358 |
1 |
createLegacyTemplateNode(templateSession.getRootNode(), "test-template", false, true, "some_text"); |
359 |
|
|
360 |
1 |
final Node resourcesTestTemplateNode = NodeUtil.createPath(resourceSession.getRootNode(), "test-template.ftl", NodeTypes.Content.NAME); |
361 |
1 |
resourcesTestTemplateNode.setProperty(PROPERTY_TEXT, "other_text"); |
362 |
|
|
363 |
1 |
final Task onSuccessTask = mock(Task.class); |
364 |
1 |
task = new TemplateMigrationTask(onSuccessTask); |
365 |
|
|
366 |
|
|
367 |
1 |
try { |
368 |
1 |
task.execute(installContext); |
369 |
|
} catch (TaskExecutionException e) { |
370 |
|
|
371 |
|
} |
372 |
|
|
373 |
|
|
374 |
1 |
verify(onSuccessTask, never()).execute(installContext); |
375 |
|
} |
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
380 |
10 |
private Node createLegacyTemplateNode(final Node parent, final String relativePath, final Boolean autoImport, final Boolean enabled, final String text) throws RepositoryException {... |
381 |
10 |
final Node templateNode = NodeUtil.createPath(parent, relativePath, NodeTypes.Content.NAME); |
382 |
10 |
if (autoImport != null) { |
383 |
9 |
templateNode.setProperty(PROPERTY_AUTO_IMPORT, autoImport); |
384 |
|
} |
385 |
10 |
if (enabled != null) { |
386 |
10 |
templateNode.setProperty(PROPERTY_ENABLED, enabled); |
387 |
|
} |
388 |
10 |
if (text != null) { |
389 |
9 |
templateNode.setProperty(PROPERTY_TEXT, text); |
390 |
|
} |
391 |
10 |
return templateNode; |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
397 |
4 |
private void assertTemplateResource(final Node newTemplateNode, final Boolean autoImport, final String text) throws RepositoryException {... |
398 |
4 |
if (text != null) { |
399 |
4 |
assertThat(newTemplateNode, hasProperty(PROPERTY_TEXT)); |
400 |
4 |
assertThat(newTemplateNode.getProperty(PROPERTY_TEXT).getString(), is(text)); |
401 |
|
} |
402 |
4 |
if (autoImport != null) { |
403 |
4 |
assertThat(newTemplateNode, hasProperty(PROPERTY_AUTO_IMPORT)); |
404 |
4 |
assertThat(newTemplateNode.getProperty(PROPERTY_AUTO_IMPORT).getBoolean(), is(autoImport)); |
405 |
|
} |
406 |
|
|
407 |
4 |
assertThat(newTemplateNode, not(hasProperty(PROPERTY_ENABLED))); |
408 |
|
} |
409 |
|
|
410 |
|
} |