SyncUtils { static SystemInstance getRemoteInstance( SystemSettingManager systemSettingManager, SyncEndpoint syncEndpoint ) { String username = (String) systemSettingManager.getSystemSetting( SettingKey.REMOTE_INSTANCE_USERNAME ); String password = (String) systemSettingManager.getSystemSetting( SettingKey.REMOTE_INSTANCE_PASSWORD ); String syncUrl = systemSettingManager.getSystemSetting( SettingKey.REMOTE_INSTANCE_URL ) + syncEndpoint.getPath(); return new SystemInstance( syncUrl, username, password ); } private  SyncUtils(); static Optional<AbstractWebMessageResponse> runSyncRequest( RestTemplate restTemplate,
        RequestCallback requestCallback, Class<? extends AbstractWebMessageResponse> klass, String syncUrl,
        int maxSyncAttempts ); static AvailabilityStatus isRemoteServerAvailable( SystemSettingManager systemSettingManager, RestTemplate restTemplate ); static void setLastSyncSuccess( SystemSettingManager systemSettingManager, SettingKey settingKey, Date time ); static Date getLastSyncSuccess( SystemSettingManager systemSettingManager, SettingKey settingKey );  }
@Test public void getRemoteInstanceTest() { systemSettingManager.saveSystemSetting( SettingKey.REMOTE_INSTANCE_USERNAME, USERNAME ); systemSettingManager.saveSystemSetting( SettingKey.REMOTE_INSTANCE_PASSWORD, PASSWORD ); systemSettingManager.saveSystemSetting( SettingKey.REMOTE_INSTANCE_URL, URL ); SystemInstance systemInstance = SyncUtils.getRemoteInstance( systemSettingManager, SyncEndpoint.EVENTS ); assertThat( systemInstance.getUsername(), is( USERNAME ) ); assertThat( systemInstance.getPassword(), is( PASSWORD ) ); assertThat( systemInstance.getUrl(), is( EVENTS_URL ) ); }