Search in sources :

Example 16 with TokenType

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);
}
Also used : TokenType(org.forgerock.openam.tokens.TokenType) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 17 with TokenType

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
}
Also used : TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Example 18 with TokenType

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);
}
Also used : TokenType(org.forgerock.openam.tokens.TokenType) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 19 with TokenType

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);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Example 20 with TokenType

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);
}
Also used : CTSOperation(org.forgerock.openam.cts.CTSOperation) TokenType(org.forgerock.openam.tokens.TokenType) Test(org.testng.annotations.Test)

Aggregations

TokenType (org.forgerock.openam.tokens.TokenType)30 Test (org.testng.annotations.Test)22 CTSOperation (org.forgerock.openam.cts.CTSOperation)20 ArrayList (java.util.ArrayList)3 SnmpStatusException (com.sun.management.snmp.SnmpStatusException)2 Token (org.forgerock.openam.cts.api.tokens.Token)2 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)2 CoreTokenField (org.forgerock.openam.tokens.CoreTokenField)2 Calendar (java.util.Calendar)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Entry (org.forgerock.opendj.ldap.Entry)1 LinkedHashMapEntry (org.forgerock.opendj.ldap.LinkedHashMapEntry)1