use of org.dotwebstack.framework.core.query.model.RequestContext in project dotwebstack-framework by dotwebstack.
the class PostgresBackendLoaderTest method loadSingle_returnsMonoObject.
@Test
void loadSingle_returnsMonoObject() {
Map<String, Object> source = new HashMap<>();
source.put("a", "bbb");
RequestContext requestContext = RequestContext.builder().objectField(mock(ObjectField.class)).source(source).build();
FetchSpec fetchSpec = mock(FetchSpec.class);
when(fetchSpec.all()).thenReturn(Flux.just(Collections.emptyMap()));
DatabaseClient.GenericExecuteSpec anotherSpec = mock(DatabaseClient.GenericExecuteSpec.class);
when(anotherSpec.fetch()).thenReturn(fetchSpec);
DatabaseClient.GenericExecuteSpec spec = mock(DatabaseClient.GenericExecuteSpec.class);
when(spec.bind(anyInt(), any())).thenReturn(anotherSpec);
when(databaseClient.sql(anyString())).thenReturn(spec);
ObjectRequest objectRequest = initObjectRequest();
var res = backendLoader.loadSingle(objectRequest, requestContext);
assertThat(res, CoreMatchers.is(notNullValue()));
res.doOnNext(result -> assertTrue(result.isEmpty())).subscribe();
}
Aggregations