EncryptorService { public void configure(String masterPassword) { checkMasterPassword(masterPassword); synchronized (configurationLock) { checkState(!isConfigured(), "Cannot configure encryption settings more than once"); setMasterPassword(masterPassword); } } @Inject  EncryptorService(SettingsService settingsService, EncryptorProviderService encryptorProviderService,
			EncryptorListener encryptorListener); boolean isConfigured(); boolean isInitialized(); void reconfigure(String newMasterPassword); void configure(String masterPassword); void initialize(String masterPassword);  }
@Test public void configure() { encryptorService.configure("1234"); InOrder order = inOrder(encryptorProviderService, settingsService); order.verify(encryptorProviderService).setEncryptor(any(Encryptor.class)); order.verify(settingsService).update(any()); assertTrue(settings.get().getEncryptorSettings().validateMasterPassword("1234")); }
@Test public void configureNull() { thrown.expect(NullPointerException.class); thrown.expectMessage("Must provide a master password"); encryptorService.configure(null); }
@Test public void configureEmpty() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Must provide a master password"); encryptorService.configure(""); }
@Test public void configureInvalid() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Master password must not have leading or trailing whitespace"); encryptorService.configure(" asdf"); }