public class ServiceProvider extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ServiceProvider.MetaApiConnectionProvider
Interface for creating
MetaApiConnection. |
| Constructor and Description |
|---|
ServiceProvider() |
| Modifier and Type | Method and Description |
|---|---|
static HistoryFileManager |
createHistoryFileManager(String accountId,
String application,
HistoryStorage storage)
Constructs history file manager with its corresponding constructor or returns a mock if it is set.
|
static MetaApiConnection |
createMetaApiConnection(MetaApiWebsocketClient websocketClient,
MetatraderAccount account,
HistoryStorage historyStorage,
ConnectionRegistry connectionRegistry,
cloud.metaapi.sdk.clients.models.IsoTime historyStartTime)
Constructs metaapi connection with its corresponding constructor or returns a mock if it is set.
|
static java.time.Instant |
getNow()
Returns instant with current time or a mock if it is set
|
static double |
getRandom()
Returns value of Math.random() or stubbed value
|
static void |
reset()
Removes all mocks
|
static void |
setHistoryFileManagerMock(HistoryFileManager mock)
Sets history file manager mock that will be created by this provider.
|
static void |
setMetApiConnectionMock(MetaApiConnection mock)
Sets metaapi connection mock that will be created by this provider.
|
static void |
setMetApiConnectionMock(ServiceProvider.MetaApiConnectionProvider mockProvider)
Sets metaapi connection provider that will be used for creating the mock.
|
static void |
setNowInstantMock(java.time.Instant instant)
Sets instant with current time that will be used for provided by this class instead of real instant.
|
static void |
setRandom(Double value)
Sets or removes mock for random value
|
public static void reset()
public static HistoryFileManager createHistoryFileManager(String accountId, String application, HistoryStorage storage)
accountId - account idapplication - MetaApi application idstorage - storagesetHistoryFileManagerMock(HistoryFileManager)public static void setHistoryFileManagerMock(HistoryFileManager mock)
null is set, the mock is removed and the object will be created as normal.mock - mocked history file manager or nullpublic static MetaApiConnection createMetaApiConnection(MetaApiWebsocketClient websocketClient, MetatraderAccount account, HistoryStorage historyStorage, ConnectionRegistry connectionRegistry, cloud.metaapi.sdk.clients.models.IsoTime historyStartTime)
websocketClient - MetaApi websocket clientaccount - MetaTrader account to connect tohistoryStorage - optional local terminal history storage. Use for accounts in user synchronization mode.
By default an instance of MemoryHistoryStorage will be used.connectionRegistry - metatrader account connection registryhistoryStartTime - history start sync time, or nullsetHistoryFileManagerMock(HistoryFileManager)public static void setMetApiConnectionMock(MetaApiConnection mock)
null is set, the mock is removed and the object will be created as normal.mock - mocked metaapi connection or nullpublic static void setMetApiConnectionMock(ServiceProvider.MetaApiConnectionProvider mockProvider)
null is set, the mock provider is removed and the object will be created as normal.mockProvider - mocked metaapi connection or nullpublic static java.time.Instant getNow()
setNowInstantMock(Instant)public static void setNowInstantMock(java.time.Instant instant)
null is set, the mock provider is removed and the object will be created as normal.instant - mocked instant or nullpublic static double getRandom()
public static void setRandom(Double value)
value - random value to returnCopyright © 2023. All rights reserved.