AbstractEncryptionBackend { public static AbstractEncryptionBackend getInstance() { String className = AppSettings.getInstance().getString(AppSettings.ENCRYPTION_BACKEND); if (instance == null || !className.equals(instance.getClass().getCanonicalName())) { instance = (AbstractEncryptionBackend) InstanceUtils.invokeConstructor(className); } return instance; }  abstract byte[] decrypt(byte[] cipherText); abstract byte[] encrypt(byte[] plainText); abstract CheckResult checkConnection(); static AbstractEncryptionBackend getInstance();  }
@Test public void testGetInstance() { try(SettingsOverride override = SettingsOverride.apply(Map.of(AppSettings.ENCRYPTION_BACKEND, "com.example.DoesNotExist"))) { try { AbstractEncryptionBackend.getInstance(); fail(); } catch (RuntimeException e) { assertEquals("java.lang.ClassNotFoundException: com.example.DoesNotExist", e.getMessage()); } } }