use of com.commercetools.sync.commons.models.ResourceKeyId in project commercetools-sync-java by commercetools.
the class BaseServiceImplTest method cacheKeysToIdsUsingGraphQl_WithNoCachedKeys_ShouldMakeRequestAndReturnCachedEntry.
@Test
void cacheKeysToIdsUsingGraphQl_WithNoCachedKeys_ShouldMakeRequestAndReturnCachedEntry() {
// preparation
final ResourceKeyIdGraphQlResult resourceKeyIdGraphQlResult = mock(ResourceKeyIdGraphQlResult.class);
final ResourceKeyId mockResourceKeyId = mock(ResourceKeyId.class);
final String key = "testKey";
final String id = "testId";
when(mockResourceKeyId.getKey()).thenReturn(key);
when(mockResourceKeyId.getId()).thenReturn(id);
when(resourceKeyIdGraphQlResult.getResults()).thenReturn(singleton(mockResourceKeyId));
when(client.execute(any())).thenReturn(completedFuture(resourceKeyIdGraphQlResult));
// test
final Map<String, String> optional = service.cacheKeysToIds(singleton("testKey")).toCompletableFuture().join();
// assertions
assertThat(optional).containsExactly(MapEntry.entry(key, id));
verify(client, times(1)).execute(any(ResourceKeyIdGraphQlRequest.class));
}
Aggregations