@Test public void shouldCallSubscriberOnSave(TestContext context) { Async async = context.async(); view.save(collection, key, document).subscribe(async::complete); }
@Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction(() -> { Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>()); collectionData.put(key, document); }); }
InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction(() -> { Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>()); collectionData.put(key, document); }); } }
InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction(() -> { Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>()); collectionData.put(key, document); }); }  }
InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction(() -> { Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>()); collectionData.put(key, document); }); }  @Override synchronized Completable save(String collection, String key, Map<String, Object> document); @Override synchronized Single<Map<String, Object>> findById(String collection, String key); @Override synchronized Single<Long> count(String collection); @Override synchronized Flowable<DocumentWithKey> findAll(String collection); @Override synchronized Completable remove(String collection, String key); }
InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction(() -> { Map<String, Map<String, Object>> collectionData = documents.computeIfAbsent(collection, k -> new LinkedHashMap<>()); collectionData.put(key, document); }); }  @Override synchronized Completable save(String collection, String key, Map<String, Object> document); @Override synchronized Single<Map<String, Object>> findById(String collection, String key); @Override synchronized Single<Long> count(String collection); @Override synchronized Flowable<DocumentWithKey> findAll(String collection); @Override synchronized Completable remove(String collection, String key); static final String NULL_COLLECTION_MESSAGE; static final String NULL_KEY_MESSAGE; }