@Test public final void testLocateFallback() throws Exception { final FileLocator locator = mock(FileLocator.class); final FileLocator fallbackLocator = mock(FileLocator.class); when(locator.locate("some-file")).thenReturn(new File("non-existent-file")); new FallbackFileLocator(locator, fallbackLocator).locate("some-file"); verify(fallbackLocator).locate("some-file"); }
@Test public final void testLocateNoFallback() throws Exception { final FileLocator locator = mock(FileLocator.class); final FileLocator fallbackLocator = mock(FileLocator.class); when(locator.locate("some-file")).thenReturn(new File(".")); new FallbackFileLocator(locator, fallbackLocator).locate("some-file"); verify(fallbackLocator, never()).locate(anyString()); }