List of usage examples for java.util.concurrent CompletableFuture completedFuture
public static <U> CompletableFuture<U> completedFuture(U value)
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testCreateNamespaceMockRootStorageContainerStore() throws Exception { String colName = "test-create-namespace-mock-root-storage-container-store"; CreateNamespaceResponse createResp = CreateNamespaceResponse.newBuilder() .setCode(StatusCode.NAMESPACE_EXISTS).build(); CreateNamespaceRequest request = createCreateNamespaceRequest(colName, namespaceConf); when(mockRangeStoreService.createNamespace(request)) .thenReturn(CompletableFuture.completedFuture(createResp)); CompletableFuture<CreateNamespaceResponse> createRespFuture = fromListenableFuture( rootRangeService.createNamespace(request)); assertTrue(createResp == createRespFuture.get()); verify(mockRangeStoreService, times(1)).createNamespace(request); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testDeleteNamespaceMockRootStorageContainerStore() throws Exception { String colName = "test-delete-namespace-no-root-storage-container-store"; DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder() .setCode(StatusCode.NAMESPACE_NOT_FOUND).build(); DeleteNamespaceRequest request = createDeleteNamespaceRequest(colName); when(mockRangeStoreService.deleteNamespace(request)) .thenReturn(CompletableFuture.completedFuture(deleteResp)); CompletableFuture<DeleteNamespaceResponse> deleteRespFuture = fromListenableFuture( rootRangeService.deleteNamespace(request)); verify(mockRangeStoreService, times(1)).deleteNamespace(request); assertTrue(deleteResp == deleteRespFuture.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testGetNamespaceMockRootStorageContainerStore() throws Exception { String colName = "test-get-namespace-no-root-storage-container-store"; GetNamespaceResponse getResp = GetNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_NOT_FOUND) .build();//from www. ja v a 2 s.c om GetNamespaceRequest request = createGetNamespaceRequest(colName); when(mockRangeStoreService.getNamespace(request)).thenReturn(CompletableFuture.completedFuture(getResp)); CompletableFuture<GetNamespaceResponse> getRespFuture = fromListenableFuture( rootRangeService.getNamespace(request)); verify(mockRangeStoreService, times(1)).getNamespace(request); assertTrue(getResp == getRespFuture.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testCreateStreamMockRootStorageContainerStore() throws Exception { String colName = "test-create-namespace-mock-root-storage-container-store"; String streamName = colName;//from ww w .j ava2s . com CreateStreamResponse createResp = CreateStreamResponse.newBuilder().setCode(StatusCode.STREAM_EXISTS) .build(); CreateStreamRequest createReq = createCreateStreamRequest(colName, streamName, DEFAULT_STREAM_CONF); when(mockRangeStoreService.createStream(createReq)) .thenReturn(CompletableFuture.completedFuture(createResp)); CompletableFuture<CreateStreamResponse> createRespFuture = fromListenableFuture( rootRangeService.createStream(createReq)); verify(mockRangeStoreService, times(1)).createStream(createReq); assertTrue(createResp == createRespFuture.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testDeleteStreamMockRootStorageContainerStore() throws Exception { String colName = "test-delete-namespace-no-root-storage-container-store"; String streamName = colName;/*from w w w . j a v a2 s . c om*/ DeleteStreamResponse deleteResp = DeleteStreamResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND) .build(); DeleteStreamRequest deleteReq = createDeleteStreamRequest(colName, streamName); when(mockRangeStoreService.deleteStream(deleteReq)) .thenReturn(CompletableFuture.completedFuture(deleteResp)); CompletableFuture<DeleteStreamResponse> deleteRespFuture = fromListenableFuture( rootRangeService.deleteStream(deleteReq)); verify(mockRangeStoreService, times(1)).deleteStream(deleteReq); assertTrue(deleteResp == deleteRespFuture.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testGetStreamMockRootStorageContainerStore() throws Exception { String colName = "test-get-namespace-no-root-storage-container-store"; String streamName = colName;/*from w ww. j a v a 2 s. c om*/ GetStreamResponse getResp = GetStreamResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build(); GetStreamRequest getReq = createGetStreamRequest(colName, streamName); when(mockRangeStoreService.getStream(getReq)).thenReturn(CompletableFuture.completedFuture(getResp)); CompletableFuture<GetStreamResponse> getRespFuture = fromListenableFuture( rootRangeService.getStream(getReq)); verify(mockRangeStoreService, times(1)).getStream(getReq); assertTrue(getResp == getRespFuture.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testGetActiveRangesMockManager() throws Exception { GetActiveRangesResponse resp = GetActiveRangesResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND) .build();//from w w w . j ava2s.c o m GetActiveRangesRequest request = createGetActiveRangesRequest(34L); when(mockRangeStoreService.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(resp)); CompletableFuture<GetActiveRangesResponse> future = fromListenableFuture( metaRangeService.getActiveRanges(request)); verify(mockRangeStoreService, times(1)).getActiveRanges(request); assertTrue(resp == future.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testRangeMockStorageContainer() throws Exception { RangeResponse response = createRangeResponse(StatusCode.SUCCESS); RangeRequest request = createRangeRequest(); when(mockRangeStoreService.range(request)).thenReturn(CompletableFuture.completedFuture(response)); CompletableFuture<RangeResponse> future = fromListenableFuture(tableService.range(request)); verify(mockRangeStoreService, times(1)).range(eq(request)); assertTrue(response == future.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testDeleteMockStorageContainer() throws Exception { DeleteRangeResponse response = createDeleteResponse(StatusCode.SUCCESS); DeleteRangeRequest request = createDeleteRequest(); when(mockRangeStoreService.delete(request)).thenReturn(CompletableFuture.completedFuture(response)); CompletableFuture<DeleteRangeResponse> future = fromListenableFuture(tableService.delete(request)); verify(mockRangeStoreService, times(1)).delete(eq(request)); assertTrue(response == future.get()); }
From source file:org.apache.bookkeeper.stream.storage.impl.TestStorageContainerStoreImpl.java
@Test public void testPutMockStorageContainer() throws Exception { PutResponse response = createPutResponse(StatusCode.SUCCESS); PutRequest request = createPutRequest(); when(mockRangeStoreService.put(request)).thenReturn(CompletableFuture.completedFuture(response)); CompletableFuture<PutResponse> future = fromListenableFuture(tableService.put(request)); verify(mockRangeStoreService, times(1)).put(eq(request)); assertTrue(response == future.get()); }