Search in sources :

Example 21 with TokenType

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

Example 22 with TokenType

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

Example 23 with TokenType

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

Example 24 with TokenType

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

Example 25 with TokenType

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