/** * Creates a new instance of <code>{@link MapAssert}</code>. * @param actual the actual value. * @return the created assertion object. */ public static <K, V> MapAssert<K, V> assertThat(Map<K, V> actual) { return new MapAssert<K, V>(actual); }
@Test public void zeroInjectionsInjectDoesNotThrowException() { class Example {} Example example = new Example(); bind(example, null); bindNavigationModel(example, null, null); assertThat(EXTRA_BINDERS).contains(entry(Example.class, NO_OP)); assertThat(NAVIGATION_MODEL_BINDERS).contains(entry(Example.class, NO_OP)); }
@Test public void checkReadAttributesMap() throws IOException { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final File tempFile = File.createTempFile( "foo", "bar" ); final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), tempFile ); assertThat( fsProvider.readAttributes( path, "*" ) ).isNotNull().hasSize( 9 ); assertThat( fsProvider.readAttributes( path, "basic:*" ) ).isNotNull().hasSize( 9 ); assertThat( fsProvider.readAttributes( path, "basic:isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( fsProvider.readAttributes( path, "basic:isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( fsProvider.readAttributes( path, "basic:isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( fsProvider.readAttributes( path, "basic:someThing" ) ).isNotNull().hasSize( 0 ); assertThat( fsProvider.readAttributes( path, "isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( fsProvider.readAttributes( path, "isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( fsProvider.readAttributes( path, "isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( fsProvider.readAttributes( path, "someThing" ) ).isNotNull().hasSize( 0 ); try { fsProvider.readAttributes( path, ":someThing" ); fail( "undefined view" ); } catch ( IllegalArgumentException ex ) { } try { fsProvider.readAttributes( path, "advanced:isRegularFile" ); fail( "undefined view" ); } catch ( UnsupportedOperationException ex ) { } }
@Test public void whenActionIsNotPerformedYet_thenMapContainsAction() { delayedActionExecutor = new DelayedActionExecutor(nonExecutingHandler, runnables); delayedActionExecutor.performAfterDelay(action, ANY_DELAY_IN_MILLIS); assertThat(runnables).hasSize(1); }
outStream3.close(); assertThat( PROVIDER.readAttributes( path, "*" ) ).isNotNull().hasSize( 10 ); assertThat( PROVIDER.readAttributes( path, "basic:*" ) ).isNotNull().hasSize( 10 ); assertThat( PROVIDER.readAttributes( path, "basic:isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( PROVIDER.readAttributes( path, "basic:isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( path, "basic:isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( path, "basic:someThing" ) ).isNotNull().hasSize( 0 ); assertThat( PROVIDER.readAttributes( path, "version:version" ) ).isNotNull().hasSize( 1 ); assertThat( PROVIDER.readAttributes( path, "isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( PROVIDER.readAttributes( path, "isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( path, "isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( path, "someThing" ) ).isNotNull().hasSize( 0 ); assertThat( PROVIDER.readAttributes( rootPath, "*" ) ).isNotNull().hasSize( 10 ); assertThat( PROVIDER.readAttributes( rootPath, "basic:*" ) ).isNotNull().hasSize( 10 ); assertThat( PROVIDER.readAttributes( rootPath, "basic:isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( PROVIDER.readAttributes( rootPath, "basic:isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( rootPath, "basic:isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( rootPath, "basic:someThing" ) ).isNotNull().hasSize( 0 ); assertThat( PROVIDER.readAttributes( rootPath, "isRegularFile" ) ).isNotNull().hasSize( 1 ); assertThat( PROVIDER.readAttributes( rootPath, "isRegularFile,isDirectory" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( rootPath, "isRegularFile,isDirectory,someThing" ) ).isNotNull().hasSize( 2 ); assertThat( PROVIDER.readAttributes( rootPath, "someThing" ) ).isNotNull().hasSize( 0 );
@Test public void givenMultipleQueuedActions_whenClearingActions_thenRemovesAllActions() { delayedActionExecutor = new DelayedActionExecutor(nonExecutingHandler, runnables); delayedActionExecutor.performAfterDelay(action, ANY_DELAY_IN_MILLIS); delayedActionExecutor.performAfterDelay(secondaryAction, ANY_DELAY_IN_MILLIS); delayedActionExecutor.clearAllActions(); assertThat(runnables).isEmpty(); verify(nonExecutingHandler, times(2)).removeCallbacks(any(Runnable.class)); }
@Test public void whenPerformingActionAfterDelay_thenRemovesActionFromMap() { delayedActionExecutor = new DelayedActionExecutor(immediatelyExecutingHandler, runnables); delayedActionExecutor.performAfterDelay(action, ANY_DELAY_IN_MILLIS); assertThat(runnables).isEmpty(); }