Search in sources :

Example 1 with QuotaResponse

use of com.google.gerrit.server.quota.QuotaResponse in project gerrit by GerritCodeReview.

the class DefaultQuotaBackendIT method availableTokensForUserAndAccount.

@Test
public void availableTokensForUserAndAccount() {
    QuotaRequestContext ctx = QuotaRequestContext.builder().user(identifiedAdmin).account(user.id()).build();
    QuotaResponse r = QuotaResponse.ok(10L);
    when(quotaEnforcer.availableTokens("testGroup", ctx)).thenReturn(r);
    assertThat(quotaBackend.user(identifiedAdmin).account(user.id()).availableTokens("testGroup")).isEqualTo(singletonAggregation(r));
}
Also used : QuotaRequestContext(com.google.gerrit.server.quota.QuotaRequestContext) QuotaResponse(com.google.gerrit.server.quota.QuotaResponse) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with QuotaResponse

use of com.google.gerrit.server.quota.QuotaResponse in project gerrit by GerritCodeReview.

the class DefaultQuotaBackendIT method availableTokensForUserAndProject.

@Test
public void availableTokensForUserAndProject() {
    QuotaRequestContext ctx = QuotaRequestContext.builder().user(identifiedAdmin).project(project).build();
    QuotaResponse r = QuotaResponse.ok(10L);
    when(quotaEnforcer.availableTokens("testGroup", ctx)).thenReturn(r);
    assertThat(quotaBackend.user(identifiedAdmin).project(project).availableTokens("testGroup")).isEqualTo(singletonAggregation(r));
}
Also used : QuotaRequestContext(com.google.gerrit.server.quota.QuotaRequestContext) QuotaResponse(com.google.gerrit.server.quota.QuotaResponse) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with QuotaResponse

use of com.google.gerrit.server.quota.QuotaResponse in project gerrit by GerritCodeReview.

the class DefaultQuotaBackendIT method availableTokens.

@Test
public void availableTokens() {
    QuotaRequestContext ctx = QuotaRequestContext.builder().user(identifiedAdmin).build();
    QuotaResponse r = QuotaResponse.ok(10L);
    when(quotaEnforcer.availableTokens("testGroup", ctx)).thenReturn(r);
    assertThat(quotaBackend.user(identifiedAdmin).availableTokens("testGroup")).isEqualTo(singletonAggregation(r));
}
Also used : QuotaRequestContext(com.google.gerrit.server.quota.QuotaRequestContext) QuotaResponse(com.google.gerrit.server.quota.QuotaResponse) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with QuotaResponse

use of com.google.gerrit.server.quota.QuotaResponse in project gerrit by GerritCodeReview.

the class DefaultQuotaBackendIT method availableTokensForUserAndChange.

@Test
public void availableTokensForUserAndChange() throws Exception {
    Change.Id changeId = retrieveChangeId();
    QuotaRequestContext ctx = QuotaRequestContext.builder().user(identifiedAdmin).change(changeId).project(project).build();
    QuotaResponse r = QuotaResponse.ok(10L);
    when(quotaEnforcer.availableTokens("testGroup", ctx)).thenReturn(r);
    assertThat(quotaBackend.user(identifiedAdmin).change(changeId, project).availableTokens("testGroup")).isEqualTo(singletonAggregation(r));
}
Also used : Change(com.google.gerrit.entities.Change) QuotaRequestContext(com.google.gerrit.server.quota.QuotaRequestContext) QuotaResponse(com.google.gerrit.server.quota.QuotaResponse) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 QuotaRequestContext (com.google.gerrit.server.quota.QuotaRequestContext)4 QuotaResponse (com.google.gerrit.server.quota.QuotaResponse)4 Test (org.junit.Test)4 Change (com.google.gerrit.entities.Change)1