1
1
package com .e_gineering .maven .gitflowhelper ;
2
2
3
+ import org .apache .commons .io .IOUtils ;
3
4
import org .apache .maven .plugin .MojoExecutionException ;
4
5
import org .junit .Assert ;
5
6
import org .junit .Test ;
6
7
8
+ import java .nio .charset .StandardCharsets ;
7
9
import java .util .function .BiFunction ;
8
10
11
+ /**
12
+ * Unit-Test for the class {@link PropertyMapper}
13
+ */
9
14
public class TestPropertyMapper
10
15
{
11
16
/**
12
- * Test the methode {@link PropertyMapper#map(GitBranchInfo)} with a Java Mapper
17
+ * Tests the methode {@link PropertyMapper#map(GitBranchInfo)} with a Java Mapper
13
18
* @throws MojoExecutionException on error
14
19
*/
15
20
@ Test
@@ -26,7 +31,7 @@ public void testPropertyMapperWithJava() throws MojoExecutionException
26
31
}
27
32
28
33
/**
29
- * Test the methode {@link PropertyMapper#map(GitBranchInfo)} with a Javascript Mapper
34
+ * Tests the methode {@link PropertyMapper#map(GitBranchInfo)} with a Javascript Mapper
30
35
* @throws MojoExecutionException on error
31
36
*/
32
37
@ Test
@@ -47,6 +52,47 @@ public void testPropertyMapperWithJavascript() throws MojoExecutionException
47
52
48
53
}
49
54
55
+ /**
56
+ * Tests the conversion of a branch name to a valid Docker image name
57
+ * @throws Exception on error
58
+ */
59
+ @ Test
60
+ public void testPropertyMapperWithJavascriptBranchNameToDockerImageNameDevelopBranch () throws Exception {
61
+
62
+ PropertyMapper mapper = new PropertyMapper ();
63
+ mapper .setPropertyName ("prop" );
64
+ mapper .setLanguage ("javascript" );
65
+
66
+ mapper .setMapper (IOUtils .toString (getClass ().getResource ("PropertyMapperBranchNameToDockerName.js" ), StandardCharsets .UTF_8 ));
67
+
68
+ Assert .assertEquals ("" , mapper .map (new GitBranchInfo ("" , GitBranchType .OTHER , "" )));
69
+
70
+ Assert .assertEquals ("foo" , mapper .map (new GitBranchInfo ("FOO" , GitBranchType .OTHER , "" )));
71
+ Assert .assertEquals ("f_f" , mapper .map (new GitBranchInfo ("F_f" , GitBranchType .OTHER , "" )));
72
+ Assert .assertEquals ("f_ae" , mapper .map (new GitBranchInfo ("F_ä" , GitBranchType .OTHER , "" )));
73
+ Assert .assertEquals ("f_ae" , mapper .map (new GitBranchInfo ("F_Ä" , GitBranchType .OTHER , "" )));
74
+ Assert .assertEquals ("f_oe" , mapper .map (new GitBranchInfo ("F_ö" , GitBranchType .OTHER , "" )));
75
+ Assert .assertEquals ("f_oe" , mapper .map (new GitBranchInfo ("F_Ö" , GitBranchType .OTHER , "" )));
76
+ Assert .assertEquals ("f_ue" , mapper .map (new GitBranchInfo ("F_ü" , GitBranchType .OTHER , "" )));
77
+ Assert .assertEquals ("f_ue" , mapper .map (new GitBranchInfo ("F_Ü" , GitBranchType .OTHER , "" )));
78
+ Assert .assertEquals ("f_ss" , mapper .map (new GitBranchInfo ("F_ß" , GitBranchType .OTHER , "" )));
79
+ Assert .assertEquals ("f_ss" , mapper .map (new GitBranchInfo ("F_ß" , GitBranchType .OTHER , "" )));
80
+
81
+ Assert .assertEquals ("f__" , mapper .map (new GitBranchInfo ("F_!" , GitBranchType .OTHER , "" )));
82
+ Assert .assertEquals ("f__a_" , mapper .map (new GitBranchInfo ("F__!" , GitBranchType .OTHER , "" )));
83
+
84
+ Assert .assertEquals ("a_f" , mapper .map (new GitBranchInfo ("_f" , GitBranchType .OTHER , "" )));
85
+ Assert .assertEquals ("a__a_" , mapper .map (new GitBranchInfo ("___" , GitBranchType .OTHER , "" )));
86
+
87
+ Assert .assertEquals ("a.a" , mapper .map (new GitBranchInfo (".a" , GitBranchType .OTHER , "" )));
88
+ Assert .assertEquals ("a-a" , mapper .map (new GitBranchInfo ("-a" , GitBranchType .OTHER , "" )));
89
+ Assert .assertEquals ("a_a" , mapper .map (new GitBranchInfo ("_a" , GitBranchType .OTHER , "" )));
90
+
91
+ Assert .assertEquals ("a__a" , mapper .map (new GitBranchInfo ("__a" , GitBranchType .OTHER , "" )));
92
+ Assert .assertEquals ("a---a" , mapper .map (new GitBranchInfo ("---a" , GitBranchType .OTHER , "" )));
93
+ }
94
+
95
+
50
96
public static class ToLowerCaseMapper implements BiFunction <String ,String ,String >
51
97
{
52
98
@ Override
0 commit comments