use of org.forgerock.openam.sm.datalayer.api.ResultHandler in project OpenAM by OpenRock.
the class TokenDataStoreTest method testDeleteError.
@Test(expectedExceptions = ServerException.class)
public void testDeleteError() throws Exception {
// Given
final Task task = mock(Task.class);
when(taskFactory.delete(anyString(), any(ResultHandler.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ResultHandler) invocation.getArguments()[1]).processError(new Exception());
return task;
}
});
// When
store.delete("123");
// Then - exception
}
use of org.forgerock.openam.sm.datalayer.api.ResultHandler in project OpenAM by OpenRock.
the class TokenDataStoreTest method testCreateError.
@Test(expectedExceptions = ServerException.class)
public void testCreateError() throws Exception {
// Given
Token token = new Token("123", TokenType.GENERIC);
final Task task = mock(Task.class);
when(adapter.toToken(anyObject())).thenReturn(token);
when(taskFactory.create(any(Token.class), any(ResultHandler.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((ResultHandler) invocation.getArguments()[1]).processError(new Exception());
return task;
}
});
// When
store.create(new Object());
// Then - exception;
}
use of org.forgerock.openam.sm.datalayer.api.ResultHandler 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.ResultHandler 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