@@ -31,112 +31,97 @@ public void init() {
31
31
public void testAbsoluteLogDir () {
32
32
System .setProperty ("cryptomator.logDir" , "/foo/bar" );
33
33
34
+ Optional <Path > logDir = env .getLogDir ();
34
35
35
- @ Nested
36
- @ DisplayName ("Testing parsing path lists" )
37
- class PathLists {
38
-
39
- @ Test
40
- @ DisplayName ("test.path.property=" )
41
- public void testEmptyList () {
42
- System .setProperty ("test.path.property" , "" );
43
- List <Path > result = env .getPaths ("test.path.property" ).toList ();
44
-
45
- MatcherAssert .assertThat (result , Matchers .hasSize (0 ));
46
- }
47
-
48
- @ Test
49
- @ DisplayName ("test.path.property=/foo/bar/test" )
50
- public void testSinglePath () {
51
- System .setProperty ("test.path.property" , "/foo/bar/test" );
52
- List <Path > result = env .getPaths ("test.path.property" ).toList ();
53
-
54
- MatcherAssert .assertThat (result , Matchers .hasSize (1 ));
55
- MatcherAssert .assertThat (result , Matchers .hasItem (Paths .get ("/foo/bar/test" )));
56
- }
57
-
58
- @ Test
59
- @ EnabledIf ("isColonPathSeperator" )
60
- @ DisplayName ("test.path.property=/foo/bar/test:/bar/nez/tost" )
61
- public void testTwoPathsColon () {
62
- System .setProperty ("test.path.property" , "/foo/bar/test:bar/nez/tost" );
63
- List <Path > result = env .getPaths ("test.path.property" ).toList ();
64
-
65
- MatcherAssert .assertThat (result , Matchers .hasSize (2 ));
66
- MatcherAssert .assertThat (result , Matchers .hasItems (Path .of ("/foo/bar/test" ), Path .of ("bar/nez/tost" )));
67
- }
68
-
69
- @ Test
70
- @ EnabledIf ("isSemiColonPathSeperator" )
71
- @ DisplayName ("test.path.property=/foo/bar/test;/bar/nez/tost" )
72
- public void testTwoPathsSemiColon () {
73
- System .setProperty ("test.path.property" , "/foo/bar/test;bar/nez/tost" );
74
- List <Path > result = env .getPaths ("test.path.property" ).toList ();
75
-
76
- MatcherAssert .assertThat (result , Matchers .hasSize (2 ));
77
- MatcherAssert .assertThat (result , Matchers .hasItems (Path .of ("/foo/bar/test" ), Path .of ("bar/nez/tost" )));
78
- }
79
-
80
- boolean isColonPathSeperator () {
81
- return System .getProperty ("path.separator" ).equals (":" );
82
- }
83
-
84
- boolean isSemiColonPathSeperator () {
85
- return System .getProperty ("path.separator" ).equals (";" );
86
- }
36
+ Assertions .assertTrue (logDir .isPresent ());
37
+ }
38
+
39
+ @ Nested
40
+ @ DisplayName ("Testing parsing path lists" )
41
+ public class PathLists {
42
+
43
+ @ Test
44
+ @ DisplayName ("test.path.property=" )
45
+ public void testEmptyList () {
46
+ System .setProperty ("test.path.property" , "" );
47
+ List <Path > result = env .getPaths ("test.path.property" ).toList ();
87
48
49
+ MatcherAssert .assertThat (result , Matchers .hasSize (0 ));
88
50
}
89
51
90
- @ Nested
91
- public class VariablesContainingPathLists {
92
-
93
- @ Test
94
- public void testSettingsPath () {
95
- Mockito . doReturn ( Stream . of ()). when ( env ). getPaths ( Mockito . anyString ());
96
- env . getSettingsPath ( );
97
- Mockito . verify ( env ). getPaths ( "cryptomator.settingsPath" );
98
- }
99
-
100
- @ Test
101
- public void testP12Path () {
102
- Mockito . doReturn ( Stream . of ()). when ( env ). getPaths ( Mockito . anyString ());
103
- env . getP12Path ();
104
- Mockito . verify ( env ). getPaths ( "cryptomator.p12Path " );
105
- }
106
-
107
- @ Test
108
- public void testIpcSocketPath () {
109
- Mockito . doReturn ( Stream . of ()). when ( env ). getPaths ( Mockito . anyString ());
110
- env . getIpcSocketPath ();
111
- Mockito . verify ( env ). getPaths ( "cryptomator.ipcSocketPath" );
112
- }
113
-
114
- @ Test
115
- public void testKeychainPath () {
116
- Mockito . doReturn ( Stream . of ()). when ( env ). getPaths ( Mockito . anyString () );
117
- env . getKeychainPath ();
118
- Mockito . verify ( env ). getPaths ( "cryptomator.integrationsWin.keychainPaths" );
119
- }
52
+ @ Test
53
+ @ DisplayName ( "test.path.property=/foo/bar/test" )
54
+ public void testSinglePath () {
55
+ System . setProperty ( "test.path.property" , "/foo/bar/test" );
56
+ List < Path > result = env . getPaths ( "test.path.property" ). toList ();
57
+
58
+ MatcherAssert . assertThat ( result , Matchers . hasSize ( 1 ) );
59
+ MatcherAssert . assertThat ( result , Matchers . hasItem ( Paths . get ( "/foo/bar/test" )) );
60
+ }
61
+
62
+ @ Test
63
+ @ EnabledIf ( "isColonPathSeperator" )
64
+ @ DisplayName ( "test.path.property=/foo/bar/test:/bar/nez/tost" )
65
+ public void testTwoPathsColon () {
66
+ System . setProperty ( "test.path.property" , "/foo/bar/test:bar/nez/tost " );
67
+ List < Path > result = env . getPaths ( "test.path.property" ). toList ();
68
+
69
+ MatcherAssert . assertThat ( result , Matchers . hasSize ( 2 ));
70
+ MatcherAssert . assertThat ( result , Matchers . hasItems ( Path . of ( "/foo/bar/test" ), Path . of ( "bar/nez/tost" )));
71
+ }
72
+
73
+ @ Test
74
+ @ EnabledIf ( "isSemiColonPathSeperator" )
75
+ @ DisplayName ( "test.path.property=/foo/bar/test;/bar/nez/tost" )
76
+ public void testTwoPathsSemiColon () {
77
+ System . setProperty ( "test.path.property" , "/foo/bar/test;bar/nez/tost" );
78
+ List < Path > result = env . getPaths ( "test.path.property" ). toList ( );
79
+
80
+ MatcherAssert . assertThat ( result , Matchers . hasSize ( 2 ) );
81
+ MatcherAssert . assertThat ( result , Matchers . hasItems ( Path . of ( "/foo/bar/test" ), Path . of ( "bar/nez/tost" )));
120
82
}
121
- }
122
- /**
123
- * Le test suivant a pour but de vérifier que la méthode getMinPwLength() renvoie
124
- * la valeur par défaut 8 quand la propriété système cryptomator.minPwLength
125
- * n'est pas définie.
126
- */
127
- @ Test
128
- @ DisplayName ("getMinPwLength should return default value when property is not set" )
129
- public void testGetMinPwLength_DefaultValue () {
130
- // Arrange: Supprime la propriété pour garantir que la valeur par défaut est utilisée
131
- System .clearProperty ("cryptomator.minPwLength" );
132
83
133
- // Act: Appelle la méthode à tester
134
- int minPwLength = env .getMinPwLength ();
84
+ boolean isColonPathSeperator () {
85
+ return System .getProperty ("path.separator" ).equals (":" );
86
+ }
87
+
88
+ boolean isSemiColonPathSeperator () {
89
+ return System .getProperty ("path.separator" ).equals (";" );
90
+ }
135
91
136
- // Assert: Vérifie que la longueur minimale par défaut est renvoyée
137
- Assertions .assertEquals (8 , minPwLength , "The default minimum password length should be 8" );
138
92
}
139
93
94
+ @ Nested
95
+ public class VariablesContainingPathLists {
96
+
97
+ @ Test
98
+ public void testSettingsPath () {
99
+ Mockito .doReturn (Stream .of ()).when (env ).getPaths (Mockito .anyString ());
100
+ env .getSettingsPath ();
101
+ Mockito .verify (env ).getPaths ("cryptomator.settingsPath" );
102
+ }
103
+
104
+ @ Test
105
+ public void testP12Path () {
106
+ Mockito .doReturn (Stream .of ()).when (env ).getPaths (Mockito .anyString ());
107
+ env .getP12Path ();
108
+ Mockito .verify (env ).getPaths ("cryptomator.p12Path" );
109
+ }
110
+
111
+ @ Test
112
+ public void testIpcSocketPath () {
113
+ Mockito .doReturn (Stream .of ()).when (env ).getPaths (Mockito .anyString ());
114
+ env .getIpcSocketPath ();
115
+ Mockito .verify (env ).getPaths ("cryptomator.ipcSocketPath" );
116
+ }
140
117
118
+ @ Test
119
+ public void testKeychainPath () {
120
+ Mockito .doReturn (Stream .of ()).when (env ).getPaths (Mockito .anyString ());
121
+ env .getKeychainPath ();
122
+ Mockito .verify (env ).getPaths ("cryptomator.integrationsWin.keychainPaths" );
123
+ }
124
+ }
141
125
142
126
}
127
+
0 commit comments