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));
}
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));
}
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);
}
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);
}
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);
}
Aggregations