use of org.springframework.r2dbc.core.FetchSpec in project dotwebstack-framework by dotwebstack.
the class PostgresBackendLoaderTest method loadMany_returnsFluxObject.
@Test
void loadMany_returnsFluxObject() {
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);
Map<String, Object> source = new HashMap<>();
source.put("a", "bbb");
RequestContext requestContext = RequestContext.builder().objectField(mock(ObjectField.class)).source(source).build();
ObjectRequest objectRequest = initObjectRequest();
CollectionRequest request = CollectionRequest.builder().objectRequest(objectRequest).sortCriterias(List.of()).build();
var res = backendLoader.loadMany(request, requestContext);
assertThat(res, CoreMatchers.is(notNullValue()));
res.doOnNext(result -> assertTrue(result.isEmpty())).subscribe();
}
use of org.springframework.r2dbc.core.FetchSpec in project dotwebstack-framework by dotwebstack.
the class PostgresBackendLoaderTest method batchLoadMany_returnsFluxObject.
@Test
@Disabled("fix me")
void batchLoadMany_returnsFluxObject() {
FetchSpec fetchSpec = mock(FetchSpec.class);
when(fetchSpec.all()).thenReturn(Flux.just(Map.of("@@@", "ccc")));
DatabaseClient.GenericExecuteSpec spec = mock(DatabaseClient.GenericExecuteSpec.class);
when(spec.fetch()).thenReturn(fetchSpec);
when(databaseClient.sql(anyString())).thenReturn(spec);
PostgresObjectField objectFieldMock = mock(PostgresObjectField.class);
when(objectFieldMock.getJoinTable()).thenReturn(mock(JoinTable.class));
Map<String, Object> source = new HashMap<>();
source.put("a", "bbb");
RequestContext requestContext = RequestContext.builder().objectField(objectFieldMock).source(source).build();
ObjectRequest objectRequest = initObjectRequest();
CollectionRequest collectionRequest = CollectionRequest.builder().objectRequest(objectRequest).sortCriterias(List.of()).build();
CollectionBatchRequest request = CollectionBatchRequest.builder().collectionRequest(collectionRequest).joinCriteria(JoinCriteria.builder().build()).build();
var res = backendLoader.batchLoadMany(request, requestContext);
assertThat(res, CoreMatchers.is(notNullValue()));
}
use of org.springframework.r2dbc.core.FetchSpec 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