use of org.forgerock.openam.sm.datalayer.api.Task in project OpenAM by OpenRock.
the class TokenDataStoreTest method testReadNotExisting.
@Test(expectedExceptions = NotFoundException.class)
public void testReadNotExisting() throws Exception {
// Given
final Token token = new Token("123", TokenType.GENERIC);
Object returned = new Object();
final Task task = mock(Task.class);
when(adapter.fromToken(token)).thenReturn(returned);
when(taskFactory.read(anyString(), any(ResultHandler.class))).thenAnswer(new Answer<Task>() {
@Override
public Task answer(InvocationOnMock invocation) throws Throwable {
((ResultHandler) invocation.getArguments()[1]).processResults(null);
return task;
}
});
// When
store.read("123");
}
use of org.forgerock.openam.sm.datalayer.api.Task in project OpenAM by OpenRock.
the class TokenDataStoreTest method testDeleteExecutorError.
@Test(expectedExceptions = ServerException.class)
public void testDeleteExecutorError() throws Exception {
// Given
final Task task = mock(Task.class);
when(taskFactory.delete(anyString(), any(ResultHandler.class))).thenReturn(task);
doThrow(DataLayerException.class).when(taskExecutor).execute("123", task);
// When
store.delete("123");
// Then - exception
}
use of org.forgerock.openam.sm.datalayer.api.Task in project OpenAM by OpenRock.
the class TokenDataStoreTest method testReadError.
@Test(expectedExceptions = ServerException.class)
public void testReadError() throws Exception {
// Given
final Token token = new Token("123", TokenType.GENERIC);
Object returned = new Object();
final Task task = mock(Task.class);
when(adapter.fromToken(token)).thenReturn(returned);
when(taskFactory.read(anyString(), any(ResultHandler.class))).thenAnswer(new Answer<Task>() {
@Override
public Task answer(InvocationOnMock invocation) throws Throwable {
((ResultHandler) invocation.getArguments()[1]).processError(new Exception());
return task;
}
});
// When
store.read("123");
}
Aggregations