1111import org .mockito .MockitoAnnotations ;
1212import static org .mockito .Mockito .*;
1313
14- public class TmcSettingsTest {
14+ public class NbTmcSettingsTest {
1515 private PersistableSettings store ;
1616 @ Mock private Tailoring tailoring ;
1717 private TmcEventBus eventBus ;
18-
18+
1919 private NbTmcSettings settings ;
20-
20+
2121 @ Before
2222 public void setUp () {
2323 MockitoAnnotations .initMocks (this );
2424 store = PersistableSettings .forModule (this .getClass ());
2525 settings = newSettings ();
2626 eventBus = TmcEventBus .createNewInstance ();
27-
27+
2828 when (tailoring .getDefaultServerUrl ()).thenReturn ("http://default.example.com" );
2929 }
30-
30+
3131 @ After
3232 public void tearDown () {
3333 store .cancel ();
3434 }
35-
35+
3636 private NbTmcSettings newSettings () {
3737 return new NbTmcSettings (store , tailoring , eventBus );
3838 }
39-
39+
4040 @ Test
4141 public void itUsesBaseUrlFromTailoringIfNoneStored () {
4242 assertEquals ("http://default.example.com" , settings .getServerAddress ());
4343 }
44-
44+
4545 @ Test
4646 public void itUsesProjectRootDirFromTailoringIfNoneStored () {
4747 assertEquals ("http://default.example.com" , settings .getServerAddress ());
4848 }
49-
49+
5050 @ Test
5151 public void itStripsTrailingSlashesOffTheBaseUrl () {
5252 settings .setServerBaseUrl ("http://example.com" );
5353 assertEquals ("http://example.com" , settings .getServerAddress ());
54-
54+
5555 settings .setServerBaseUrl ("http://example.com/" );
5656 assertEquals ("http://example.com" , settings .getServerAddress ());
57-
57+
5858 settings .setServerBaseUrl ("http://example.com///////" );
5959 assertEquals ("http://example.com" , settings .getServerAddress ());
60-
60+
6161 settings .setServerBaseUrl ("http://example.com///////" );
6262 assertEquals ("http://example.com" , settings .getServerAddress ());
6363 }
64-
64+
6565 @ Test
6666 public void itDoesntStoreThePasswordByDefault () {
6767 assertFalse (settings .isSavingPassword ());
6868 settings .setPassword ("xoo" );
6969 assertEquals ("" , newSettings ().getPassword ());
7070 }
71-
71+
7272 @ Test
7373 public void itMayOptionallyStoreThePassword () {
7474 settings .setSavingPassword (true );
7575 settings .setPassword ("xoo" );
76-
76+
7777 assertTrue (settings .isSavingPassword ());
7878 assertEquals ("xoo" , newSettings ().getPassword ());
7979 assertTrue (newSettings ().isSavingPassword ());
8080 }
81-
81+
8282 @ Test
8383 public void itMayStoreThePasswordEvenAfterItHasBeenSet () {
8484 settings .setPassword ("xoo" );
8585 settings .setSavingPassword (true );
86-
86+
8787 assertTrue (settings .isSavingPassword ());
8888 assertEquals ("xoo" , newSettings ().getPassword ());
8989 assertTrue (newSettings ().isSavingPassword ());
9090 }
91-
91+
9292 @ Test
9393 public void itCanBeToldToRemoveAStoredPassword () {
9494 settings .setSavingPassword (true );
9595 settings .setPassword ("xoo" );
9696 settings .setSavingPassword (false );
97-
97+
9898 assertFalse (settings .isSavingPassword ());
9999 assertEquals ("xoo" , settings .getPassword ());
100-
100+
101101 assertEquals ("" , newSettings ().getPassword ());
102102 assertFalse (newSettings ().isSavingPassword ());
103103 }
104-
104+
105105 @ Test
106106 public void itSavesWhetherToCheckUpdatesInTheBackground () {
107107 assertTrue (settings .isCheckingForUpdatesInTheBackground ());
@@ -110,7 +110,7 @@ public void itSavesWhetherToCheckUpdatesInTheBackground() {
110110 settings .setCheckingForUpdatesInTheBackground (true );
111111 assertTrue (newSettings ().isCheckingForUpdatesInTheBackground ());
112112 }
113-
113+
114114 @ Test
115115 public void localeToStringBehavesAsExpected () {
116116 assertEquals ("fi" , new Locale ("fi" ).toString ());
0 commit comments