Search in sources :

Example 41 with CTSOperation

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

the class TokenOperationsStoreTest method shouldUpdateFailureCountForAllTokenTypes.

@Test
public void shouldUpdateFailureCountForAllTokenTypes() {
    // Given
    CTSOperation operation = CTSOperation.READ;
    long originalFailureCount = tokenOperationsStore.getOperationFailuresCumulativeCount(operation);
    tokenOperations.put(TokenType.REST, new OperationStore());
    tokenOperations.put(TokenType.OAUTH, new OperationStore());
    // When
    tokenOperationsStore.addTokenOperation(TokenType.REST, operation, false);
    tokenOperationsStore.addTokenOperation(TokenType.OAUTH, operation, false);
    // Then
    assertEquals(originalFailureCount + 2, tokenOperationsStore.getOperationFailuresCumulativeCount(operation));
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Test(org.testng.annotations.Test)

Example 42 with CTSOperation

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

the class OperationStoreTest method shouldAddTokenOperationForSpecificTokenTypeUsingDefaultOperationStoreFactory.

@Test
public void shouldAddTokenOperationForSpecificTokenTypeUsingDefaultOperationStoreFactory() {
    //Given
    OperationStore.OperationRateFactory operationRateFactory = new OperationStore.OperationRateFactory();
    OperationStore localOperationStore = new OperationStore(operationRateFactory, operationRate);
    CTSOperation operation = CTSOperation.CREATE;
    //When
    localOperationStore.add(operation);
    //Then
    assertTrue(operationRate.containsKey(CTSOperation.CREATE));
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Test(org.testng.annotations.Test)

Example 43 with CTSOperation

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

the class TokenOperationsStoreTest method shouldGetAverageFailureRateForOperation.

@Test
public void shouldGetAverageFailureRateForOperation() {
    // Given
    // Use mock failure store for this test for simplicity
    operationFailureStore = mock(OperationStore.class);
    tokenOperationsStore = new TokenOperationsStore(operationStoreFactory, tokenOperations, operationStore, operationFailureStore);
    CTSOperation operation = CTSOperation.READ;
    double failureRate = 3.14159;
    given(operationFailureStore.getAverageRate(operation)).willReturn(failureRate);
    // When
    double result = tokenOperationsStore.getAverageOperationFailuresPerPeriod(operation);
    // Then
    assertEquals(result, failureRate);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) Test(org.testng.annotations.Test)

Example 44 with CTSOperation

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

the class TokenOperationsStoreTest method shouldGetAverageOperationsPerPeriodForSpecificTokenType.

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

Example 45 with CTSOperation

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

the class TokenOperationsStoreTest method shouldGetAverageOperationsPerPeriod.

@Test
public void shouldGetAverageOperationsPerPeriod() {
    //Given
    CTSOperation operation = CTSOperation.CREATE;
    given(operationStore.getAverageRate(operation)).willReturn(1D);
    //When
    double result = tokenOperationsStore.getAverageOperationsPerPeriod(operation);
    //Then
    assertEquals(result, 1D);
}
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