11
11
import org .mockito .MockitoAnnotations ;
12
12
import static org .mockito .Mockito .*;
13
13
14
- public class TmcSettingsTest {
14
+ public class NbTmcSettingsTest {
15
15
private PersistableSettings store ;
16
16
@ Mock private Tailoring tailoring ;
17
17
private TmcEventBus eventBus ;
18
-
18
+
19
19
private NbTmcSettings settings ;
20
-
20
+
21
21
@ Before
22
22
public void setUp () {
23
23
MockitoAnnotations .initMocks (this );
24
24
store = PersistableSettings .forModule (this .getClass ());
25
25
settings = newSettings ();
26
26
eventBus = TmcEventBus .createNewInstance ();
27
-
27
+
28
28
when (tailoring .getDefaultServerUrl ()).thenReturn ("http://default.example.com" );
29
29
}
30
-
30
+
31
31
@ After
32
32
public void tearDown () {
33
33
store .cancel ();
34
34
}
35
-
35
+
36
36
private NbTmcSettings newSettings () {
37
37
return new NbTmcSettings (store , tailoring , eventBus );
38
38
}
39
-
39
+
40
40
@ Test
41
41
public void itUsesBaseUrlFromTailoringIfNoneStored () {
42
42
assertEquals ("http://default.example.com" , settings .getServerAddress ());
43
43
}
44
-
44
+
45
45
@ Test
46
46
public void itUsesProjectRootDirFromTailoringIfNoneStored () {
47
47
assertEquals ("http://default.example.com" , settings .getServerAddress ());
48
48
}
49
-
49
+
50
50
@ Test
51
51
public void itStripsTrailingSlashesOffTheBaseUrl () {
52
52
settings .setServerBaseUrl ("http://example.com" );
53
53
assertEquals ("http://example.com" , settings .getServerAddress ());
54
-
54
+
55
55
settings .setServerBaseUrl ("http://example.com/" );
56
56
assertEquals ("http://example.com" , settings .getServerAddress ());
57
-
57
+
58
58
settings .setServerBaseUrl ("http://example.com///////" );
59
59
assertEquals ("http://example.com" , settings .getServerAddress ());
60
-
60
+
61
61
settings .setServerBaseUrl ("http://example.com///////" );
62
62
assertEquals ("http://example.com" , settings .getServerAddress ());
63
63
}
64
-
64
+
65
65
@ Test
66
66
public void itDoesntStoreThePasswordByDefault () {
67
67
assertFalse (settings .isSavingPassword ());
68
68
settings .setPassword ("xoo" );
69
69
assertEquals ("" , newSettings ().getPassword ());
70
70
}
71
-
71
+
72
72
@ Test
73
73
public void itMayOptionallyStoreThePassword () {
74
74
settings .setSavingPassword (true );
75
75
settings .setPassword ("xoo" );
76
-
76
+
77
77
assertTrue (settings .isSavingPassword ());
78
78
assertEquals ("xoo" , newSettings ().getPassword ());
79
79
assertTrue (newSettings ().isSavingPassword ());
80
80
}
81
-
81
+
82
82
@ Test
83
83
public void itMayStoreThePasswordEvenAfterItHasBeenSet () {
84
84
settings .setPassword ("xoo" );
85
85
settings .setSavingPassword (true );
86
-
86
+
87
87
assertTrue (settings .isSavingPassword ());
88
88
assertEquals ("xoo" , newSettings ().getPassword ());
89
89
assertTrue (newSettings ().isSavingPassword ());
90
90
}
91
-
91
+
92
92
@ Test
93
93
public void itCanBeToldToRemoveAStoredPassword () {
94
94
settings .setSavingPassword (true );
95
95
settings .setPassword ("xoo" );
96
96
settings .setSavingPassword (false );
97
-
97
+
98
98
assertFalse (settings .isSavingPassword ());
99
99
assertEquals ("xoo" , settings .getPassword ());
100
-
100
+
101
101
assertEquals ("" , newSettings ().getPassword ());
102
102
assertFalse (newSettings ().isSavingPassword ());
103
103
}
104
-
104
+
105
105
@ Test
106
106
public void itSavesWhetherToCheckUpdatesInTheBackground () {
107
107
assertTrue (settings .isCheckingForUpdatesInTheBackground ());
@@ -110,7 +110,7 @@ public void itSavesWhetherToCheckUpdatesInTheBackground() {
110
110
settings .setCheckingForUpdatesInTheBackground (true );
111
111
assertTrue (newSettings ().isCheckingForUpdatesInTheBackground ());
112
112
}
113
-
113
+
114
114
@ Test
115
115
public void localeToStringBehavesAsExpected () {
116
116
assertEquals ("fi" , new Locale ("fi" ).toString ());
0 commit comments