use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CtsPersistenceOperationsMonitorTest method getAverageDurationTest.
@Test
public void getAverageDurationTest() throws CoreTokenException {
//given
final Long duration = (long) 100;
final TokenType tokenType = TokenType.SESSION;
final ArrayList<Long> results = new ArrayList<Long>();
results.add(duration);
given(delegate.listDurationOfTokens(tokenType)).willReturn(results);
//when
final Long result = opsMonitor.getAverageDuration(tokenType);
//then
assertEquals(duration, result);
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CtsPersistenceOperationsMonitorTest method getAverageDurationTestErrorInvalidToken.
@Test(expectedExceptions = NullPointerException.class)
public void getAverageDurationTestErrorInvalidToken() throws CoreTokenException {
//given
final TokenType tokenType = null;
//when
opsMonitor.getAverageDuration(tokenType);
//then
//throw exception
}
use of org.forgerock.openam.tokens.TokenType in project OpenAM by OpenRock.
the class CtsPersistenceOperationsMonitorTest method getAverageDurationTestWithZeroResults.
@Test
public void getAverageDurationTestWithZeroResults() throws CoreTokenException {
//given
final Long durationAvg = (long) 0;
final TokenType tokenType = TokenType.SESSION;
final ArrayList<Long> results = new ArrayList<Long>();
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 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);
}
use of org.forgerock.openam.tokens.TokenType 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);
}
Aggregations