Search in sources :

Example 1 with CollectionBatchRequest

use of org.dotwebstack.framework.core.query.model.CollectionBatchRequest 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()));
}
Also used : CollectionRequest(org.dotwebstack.framework.core.query.model.CollectionRequest) FetchSpec(org.springframework.r2dbc.core.FetchSpec) HashMap(java.util.HashMap) CollectionBatchRequest(org.dotwebstack.framework.core.query.model.CollectionBatchRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ObjectRequest(org.dotwebstack.framework.core.query.model.ObjectRequest) DatabaseClient(org.springframework.r2dbc.core.DatabaseClient) PostgresObjectField(org.dotwebstack.framework.backend.postgres.model.PostgresObjectField) RequestContext(org.dotwebstack.framework.core.query.model.RequestContext) JoinTable(org.dotwebstack.framework.backend.postgres.model.JoinTable) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

HashMap (java.util.HashMap)1 JoinTable (org.dotwebstack.framework.backend.postgres.model.JoinTable)1 PostgresObjectField (org.dotwebstack.framework.backend.postgres.model.PostgresObjectField)1 CollectionBatchRequest (org.dotwebstack.framework.core.query.model.CollectionBatchRequest)1 CollectionRequest (org.dotwebstack.framework.core.query.model.CollectionRequest)1 ObjectRequest (org.dotwebstack.framework.core.query.model.ObjectRequest)1 RequestContext (org.dotwebstack.framework.core.query.model.RequestContext)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 DatabaseClient (org.springframework.r2dbc.core.DatabaseClient)1 FetchSpec (org.springframework.r2dbc.core.FetchSpec)1