EncryptorProviderService { public void setEncryptor(Encryptor encryptor) { checkNotNull(encryptor, "Must provide an encryptor"); encryptorReference.set(encryptor); }  boolean isInitialized(); Encryptor getEncryptor(); void setEncryptor(Encryptor encryptor);  }
@Test public void setEncryptor() { Encryptor encryptor = mock(Encryptor.class); service.setEncryptor(encryptor); assertSame(encryptor, service.getEncryptor()); Encryptor encryptor2 = mock(Encryptor.class); service.setEncryptor(encryptor2); assertSame(encryptor2, service.getEncryptor()); }