use of org.forgerock.openam.tokens.TokenType 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);
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CTSMonitoringStoreImplTest method shouldGetAverageOperationsPerPeriodForSpecificTokenType.
@Test
public void shouldGetAverageOperationsPerPeriodForSpecificTokenType() {
//Given
TokenType tokenType = TokenType.OAUTH;
CTSOperation operation = CTSOperation.READ;
given(tokenOperationsStore.getAverageOperationsPerPeriod(tokenType, operation)).willReturn(1D);
//When
double result = ctsOperationsMonitoringStore.getAverageOperationsPerPeriod(tokenType, operation);
//Then
assertEquals(result, 1D);
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CtsPersistenceOperationsMonitorTest method getTotalCountTestErrorInvalidToken.
@Test(expectedExceptions = NullPointerException.class)
public void getTotalCountTestErrorInvalidToken() throws CoreTokenException {
//given
final TokenType tokenType = null;
//when
opsMonitor.getTotalCount(tokenType);
//then
//throw exception
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CtsPersistenceOperationsMonitorTest method getAverageDurationTestWithMultipleResults.
@Test
public void getAverageDurationTestWithMultipleResults() throws CoreTokenException {
//given
final Long durationOne = (long) 100;
final Long durationTwo = (long) 50;
final Long durationAvg = (long) 75;
final TokenType tokenType = TokenType.SESSION;
final ArrayList<Long> results = new ArrayList<Long>();
results.add(durationOne);
results.add(durationTwo);
given(delegate.listDurationOfTokens(tokenType)).willReturn(results);
//when
final Long result = opsMonitor.getAverageDuration(tokenType);
//then
assertEquals(durationAvg, result);
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class TokenOperationsStoreTest method shouldGetOperationsCumulativeCountForSpecificTokenType.
@Test
public void shouldGetOperationsCumulativeCountForSpecificTokenType() {
//Given
TokenType tokenType = TokenType.OAUTH;
CTSOperation operation = CTSOperation.CREATE;
OperationStore typeOperationStore = mock(OperationStore.class);
tokenOperations.put(TokenType.OAUTH, typeOperationStore);
given(typeOperationStore.getCount(operation)).willReturn(1L);
//When
long result = tokenOperationsStore.getOperationsCumulativeCount(tokenType, operation);
//Then
assertEquals(result, 1L);
}
Aggregations