private ODataSingleProcessorService service;
@Before
public void before() {
try {
final ODataSingleProcessor processor = mock(ODataSingleProcessor.class);
final EdmProvider provider = mock(EdmProvider.class);
service = new ODataSingleProcessorService(provider, processor) {};
// FitStaticServiceFactory.setService(service);
// science fiction (return context after setContext)
// see http://www.planetgeek.ch/2010/07/20/mockito-answer-vs-return/
doAnswer(new Answer<Object>() {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
context = (ODataContext) invocation.getArguments()[0];
return null;
}
}).when(processor).setContext(any(ODataContext.class));
when(processor.getContext()).thenAnswer(new Answer<ODataContext>() {
@Override
public ODataContext answer(final InvocationOnMock invocation) throws Throwable {
return context;
}
});