Class |
Line # |
Actions |
|||||
---|---|---|---|---|---|---|---|
SnippetParserTest | 28 | 25 | 0% | 13 | 6 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.devacfr.maven.skins.reflow.snippet; | |
20 | ||
21 | import java.io.IOException; | |
22 | ||
23 | import org.devacfr.maven.skins.reflow.ISkinConfig; | |
24 | import org.devacfr.testing.jupiter.MockitoTestCase; | |
25 | import org.junit.jupiter.api.Test; | |
26 | import org.mockito.Mock; | |
27 | ||
28 | public class SnippetParserTest extends MockitoTestCase { | |
29 | ||
30 | @Mock | |
31 | private ISkinConfig config; | |
32 | ||
33 | 1 | @Test |
34 | public void shouldReplaceSnippetByHtml() throws Exception { | |
35 | 1 | verify((htmlSource) -> { |
36 | 1 | try { |
37 | 1 | return createParser().parse(config, htmlSource).html(); |
38 | } catch (final IOException e) { | |
39 | 0 | throw new RuntimeException(e.getMessage(), e); |
40 | } | |
41 | }, "html"); | |
42 | } | |
43 | ||
44 | 1 | @Test |
45 | public void shouldRenderCard() { | |
46 | 1 | verify((htmlSource) -> { |
47 | 1 | try { |
48 | 1 | return createParser().parse(config, htmlSource).html(); |
49 | } catch (final IOException e) { | |
50 | 0 | throw new RuntimeException(e.getMessage(), e); |
51 | } | |
52 | }, "html"); | |
53 | } | |
54 | ||
55 | 1 | @Test |
56 | public void shouldRenderCardRecursively() { | |
57 | 1 | verify((htmlSource) -> { |
58 | 1 | try { |
59 | 1 | return createParser().parse(config, htmlSource).html(); |
60 | } catch (final IOException e) { | |
61 | 0 | throw new RuntimeException(e.getMessage(), e); |
62 | } | |
63 | }, "html"); | |
64 | } | |
65 | ||
66 | 1 | @Test |
67 | public void shouldRenderBadge() { | |
68 | 1 | verify((htmlSource) -> { |
69 | 1 | try { |
70 | 1 | return createParser().parse(config, htmlSource).html(); |
71 | } catch (final IOException e) { | |
72 | 0 | throw new RuntimeException(e.getMessage(), e); |
73 | } | |
74 | }, "html"); | |
75 | } | |
76 | ||
77 | 1 | @Test |
78 | public void shouldRenderLayout() { | |
79 | 1 | verify((htmlSource) -> { |
80 | 1 | try { |
81 | 1 | return createParser().parse(config, htmlSource).html(); |
82 | } catch (final IOException e) { | |
83 | 0 | throw new RuntimeException(e.getMessage(), e); |
84 | } | |
85 | }, "html"); | |
86 | } | |
87 | ||
88 | 1 | @Test |
89 | public void shouldRenderNestedComponent() { | |
90 | 1 | verify((htmlSource) -> { |
91 | 1 | try { |
92 | 1 | return createParser().parse(config, htmlSource).html(); |
93 | } catch (final IOException e) { | |
94 | 0 | throw new RuntimeException(e.getMessage(), e); |
95 | } | |
96 | }, "html"); | |
97 | } | |
98 | ||
99 | 6 | private SnippetParser createParser() { |
100 | 6 | return new SnippetParser().insertResourcePath(getPackagePath().toString(), 0); |
101 | } | |
102 | } |