Skip to content

Commit 5653e8b

Browse files
authored
fix(datastore) Set isOrchestratorReady flag to true when no API is configured (#653)
1 parent 71aa76d commit 5653e8b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

aws-datastore/src/main/java/com/amplifyframework/datastore/AWSDataStorePlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ private void beforeOperation(@NonNull final Runnable runnable) {
491491

492492
private Completable initializeOrchestrator() {
493493
if (api.getPlugins().isEmpty()) {
494+
isOrchestratorReady.set(true);
494495
return Completable.complete();
495496
} else {
496497
// Let's prevent the orchestrator startup from possibly running in main.

aws-datastore/src/test/java/com/amplifyframework/datastore/AWSDataStorePluginTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,20 @@ public void configureAndInitializeInLocalMode() throws AmplifyException {
102102
//Configure DataStore with an empty config (All defaults)
103103
ApiCategory emptyApiCategory = spy(ApiCategory.class);
104104
AWSDataStorePlugin standAloneDataStorePlugin = new AWSDataStorePlugin(modelProvider, emptyApiCategory);
105+
SynchronousDataStore synchronousDataStore = SynchronousDataStore.delegatingTo(standAloneDataStorePlugin);
105106
standAloneDataStorePlugin.configure(new JSONObject(), context);
106107
standAloneDataStorePlugin.initialize(context);
108+
109+
// Trick the DataStore since it's not getting initialized as part of the Amplify.initialize call chain
110+
Amplify.Hub.publish(HubChannel.DATASTORE, HubEvent.create(InitializationStatus.SUCCEEDED));
111+
107112
assertSyncProcessorNotStarted();
113+
114+
Person person1 = createPerson("Test", "Dummy I");
115+
synchronousDataStore.save(person1);
116+
assertNotNull(person1.getId());
117+
Person person1FromDb = synchronousDataStore.get(Person.class, person1.getId());
118+
assertEquals(person1, person1FromDb);
108119
}
109120

110121
/**

0 commit comments

Comments
 (0)