use of io.pravega.controller.server.rest.generated.model.ScopesList in project pravega by pravega.
the class StreamMetaDataAuthFocusedTests method testListScopesReturnsFilteredResults.
@Test
public void testListScopesReturnsFilteredResults() throws ExecutionException, InterruptedException {
// Arrange
final String resourceURI = getURI() + "v1/scopes";
when(mockControllerService.listScopes(anyLong())).thenReturn(CompletableFuture.completedFuture(Arrays.asList("scope1", "scope2", "scope3")));
Invocation requestInvocation = this.invocationBuilder(resourceURI, USER_ACCESS_TO_SUBSET_OF_SCOPES, DEFAULT_PASSWORD).buildGet();
// Act
Response response = requestInvocation.invoke();
ScopesList scopes = response.readEntity(ScopesList.class);
// Assert
assertEquals(1, scopes.getScopes().size());
assertEquals("scope3", scopes.getScopes().get(0).getScopeName());
response.close();
}
use of io.pravega.controller.server.rest.generated.model.ScopesList in project pravega by pravega.
the class StreamMetaDataTests method testlistScopes.
/**
* Test for listScopes REST API.
*
* @throws ExecutionException
* @throws InterruptedException
*/
@Test(timeout = 30000)
public void testlistScopes() throws ExecutionException, InterruptedException {
final String resourceURI = getURI() + "v1/scopes";
// Test to list scopes.
List<String> scopesList = Arrays.asList("scope1", "scope2", "scope3");
when(mockControllerService.listScopes(anyLong())).thenReturn(CompletableFuture.completedFuture(scopesList));
Response response = addAuthHeaders(client.target(resourceURI).request()).buildGet().invoke();
assertEquals("List Scopes response code", 200, response.getStatus());
assertTrue(response.bufferEntity());
verifyScopes(response.readEntity(ScopesList.class));
response.close();
// Test for list scopes failure.
final CompletableFuture<List<String>> completableFuture = new CompletableFuture<>();
completableFuture.completeExceptionally(new Exception());
when(mockControllerService.listScopes(anyLong())).thenReturn(completableFuture);
response = addAuthHeaders(client.target(resourceURI).request()).buildGet().invoke();
assertEquals("List Scopes response code", 500, response.getStatus());
response.close();
}
Aggregations