Search in sources :

Example 21 with CTSOperation

use of org.forgerock.openam.cts.CTSOperation in project OpenAM by OpenRock.

the class TokenOperationsStoreTest method shouldGetMaximumOperationsPerPeriod.

@Test
public void shouldGetMaximumOperationsPerPeriod() {
    //Given
    CTSOperation operation = CTSOperation.CREATE;
    given(operationStore.getMaxRate(operation)).willReturn(1L);
    //When
    long result = tokenOperationsStore.getMaximumOperationsPerPeriod(operation);
    //Then
    assertEquals(result, 1L);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Test(org.testng.annotations.Test)

Example 22 with CTSOperation

use of org.forgerock.openam.cts.CTSOperation in project OpenAM by OpenRock.

the class TokenOperationsStoreTest method shouldGetMinimumOperationsPerPeriodForSpecificTokenType.

@Test
public void shouldGetMinimumOperationsPerPeriodForSpecificTokenType() {
    //Given
    TokenType tokenType = TokenType.OAUTH;
    CTSOperation operation = CTSOperation.CREATE;
    OperationStore typeOperationStore = mock(OperationStore.class);
    tokenOperations.put(TokenType.OAUTH, typeOperationStore);
    given(typeOperationStore.getMinRate(operation)).willReturn(1L);
    //When
    long result = tokenOperationsStore.getMinimumOperationsPerPeriod(tokenType, operation);
    //Then
    assertEquals(result, 1L);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Example 23 with CTSOperation

use of org.forgerock.openam.cts.CTSOperation in project OpenAM by OpenRock.

the class TokenOperationsStoreTest method shouldAddTokenOperationForSpecificTokenTypeToExistingOperationStore.

@Test
public void shouldAddTokenOperationForSpecificTokenTypeToExistingOperationStore() {
    //Given
    TokenType tokenType = TokenType.OAUTH;
    CTSOperation operation = CTSOperation.CREATE;
    OperationStore typeOperationStore = mock(OperationStore.class);
    tokenOperations.put(TokenType.OAUTH, typeOperationStore);
    //When
    tokenOperationsStore.addTokenOperation(tokenType, operation, true);
    //Then
    verifyZeroInteractions(operationStoreFactory);
    verify(typeOperationStore).add(operation);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Example 24 with CTSOperation

use of org.forgerock.openam.cts.CTSOperation in project OpenAM by OpenRock.

the class TokenOperationsStoreTest method shouldAddTokenOperationForSpecificTokenType.

@Test
public void shouldAddTokenOperationForSpecificTokenType() {
    //Given
    TokenType tokenType = TokenType.OAUTH;
    CTSOperation operation = CTSOperation.CREATE;
    OperationStore typeOperationStore = mock(OperationStore.class);
    given(operationStoreFactory.createOperationStore()).willReturn(typeOperationStore);
    //When
    tokenOperationsStore.addTokenOperation(tokenType, operation, true);
    //Then
    assertTrue(tokenOperations.containsKey(TokenType.OAUTH));
    verify(typeOperationStore).add(operation);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Example 25 with CTSOperation

use of org.forgerock.openam.cts.CTSOperation in project OpenAM by OpenRock.

the class TokenOperationsStoreTest method shouldGetOperationsCumulativeCount.

@Test
public void shouldGetOperationsCumulativeCount() {
    //Given
    CTSOperation operation = CTSOperation.CREATE;
    given(operationStore.getCount(operation)).willReturn(1L);
    //When
    long result = tokenOperationsStore.getOperationsCumulativeCount(operation);
    //Then
    assertEquals(result, 1L);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Test(org.testng.annotations.Test)

Aggregations

CTSOperation (org.forgerock.openam.cts.CTSOperation)47 Test (org.testng.annotations.Test)43 TokenType (org.forgerock.openam.tokens.TokenType)20 Token (org.forgerock.openam.cts.api.tokens.Token)2