/******************************************************************************************************************* * * ******************************************************************************************************************/ public ContextSampler (final @Nonnull Object owner) { contexts = Collections.unmodifiableList(contextManager.getContexts()); if (log.isTraceEnabled()) { log.trace(">>>> contexts for {} at construction time: {}", shortId(owner), shortIds(contexts)); } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dataProvider = "contextProvider") public void must_sample_Contexts_at_construction_time (final @Nonnull List<Object> contexts) { when(contextManager.getContexts()).thenReturn(contexts); fixture = new ContextSampler(new Object()); assertThat(fixture.getContexts(), is(contexts)); }
log.trace(">>>> contexts: {}", shortIds(contextManager.getContexts()));
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dataProvider = "contextProvider") public void must_delegate_runWithContexts_to_ContextManager (final @Nonnull List<Object> contexts) { when(contextManager.getContexts()).thenReturn(contexts); // final Class<List<Object>> listClass = (Class)List.class; // final Class<Task<Object, RuntimeException>> taskClass = (Class)Task.class; // when(contextManager.<Object>runWithContexts(CoreMatchers.any(listClass), // CoreMatchers.any((taskClass)))); final Task<String, RuntimeException> task = mock(Task.class); fixture = new ContextSampler(new Object()); reset(contextManager); final Object result = fixture.runWithContexts(task); verify(contextManager, times(1)).runWithContexts(eq(contexts), same(task)); verifyNoMoreInteractions(contextManager); // assertThat(result, is((Object)"result")); FIXME: need to stub }