Refine search
@Test public void joinWithFormatter() { Formatter<Integer> formatter = new Formatter<Integer>() { @Override public CharSequence format(Integer item) { return String.format("0x%d", item); } }; assertThat(listPhrase.join(asList(1, 2, 3), formatter)).isEqualTo("0x1, 0x2, and 0x3"); }
public ProcessVariableAssert exists() { isNotNull(); Assertions.assertThat(actual.getValue()) .overridingErrorMessage("Unable to find processInstance processVariable '%s'", actual.getName()) .isNotNull(); return this; }
@Test public void testRetainsSpans() { SpannableStringBuilder ssb = new SpannableStringBuilder("Hello {name}, you are {age} years old."); ssb.setSpan("bold", 5, 28, 0); CharSequence formatted = Phrase.from(ssb).put("name", "Abe").put("age", 20).format(); assertThat(formatted.toString()).isEqualTo("Hello Abe, you are 20 years old."); assertThat(formatted).isInstanceOf(Spannable.class); }
public StringAssert asString() { Assertions.assertThat(actual.getValue()) .overridingErrorMessage("Unable to convert processInstance processVariable '%s' to an instance of class '%s'", actual.getName(), String.class) .isInstanceOf(String.class); return Assertions.assertThat((String) actual.getValue()); }
@Test public void checkNewOutputStream() throws IOException { final File temp = File.createTempFile( "foo", "bar" ); final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), temp ); final OutputStream stream = fsProvider.newOutputStream( path ); assertThat( stream ).isNotNull(); stream.close(); }
@Test public void checkGetFileStore() { final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "c:\\path\\to\\file.txt", false ); assertThat( fsProvider.getFileStore( path ) ).isNotNull().isInstanceOf( SimpleWindowsFileStore.class ); assertThat( fsProvider.getFileStore( path ).name() ).isNotNull().isEqualTo( "c:\\" ); }
@Test public void testDeleteIfExists() throws IOException { final URI newRepo = URI.create( "git://deleteifexists1-test-repo" ); PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); final Path path = PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/path/to/myfile.txt" ) ); final OutputStream outStream = PROVIDER.newOutputStream( path ); assertThat( outStream ).isNotNull(); outStream.write( "my cool content".getBytes() ); outStream.close(); PROVIDER.newInputStream( path ).close(); assertThat( PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/non_existent_path" ) ) ) ).isFalse(); try { PROVIDER.deleteIfExists( PROVIDER.getPath( URI.create( "git://user_branch@deleteifexists1-test-repo/path/to/" ) ) ); failBecauseExceptionWasNotThrown( DirectoryNotEmptyException.class ); } catch ( DirectoryNotEmptyException ex ) { } assertThat( PROVIDER.deleteIfExists( path ) ).isTrue(); }
@Test public void testGetFileSystem() { final URI newRepo = URI.create( "git://new-repo-name" ); final FileSystem fs = PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); assertThat( fs ).isNotNull(); assertThat( PROVIDER.getFileSystem( newRepo ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://master@new-repo-name" ) ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://branch@new-repo-name" ) ) ).isEqualTo( fs ); assertThat( PROVIDER.getFileSystem( URI.create( "git://branch@new-repo-name?fetch" ) ) ).isEqualTo( fs ); }
@Test public void readAttributesInvalid() 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, MyAttrs.class ) ).isNull(); }
@Test public void simpleStateTest() { assertThat( fsProvider ).isNotNull(); assertThat( fsProvider.getScheme() ).isNotEmpty().isEqualTo( "file" ); final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "c:\\path\\to\\file.txt", false ); assertThat( path.getFileSystem() ).isNotNull().isInstanceOf( SimpleWindowsFileSystem.class ); }
@Test public void validateGetPath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final URI uri = URI.create( "file:///path/to/file.txt" ); final Path path = fsProvider.getPath( uri ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isTrue(); assertThat( path.getFileSystem() ).isEqualTo( fsProvider.getFileSystem( uri ) ); assertThat( path.getFileSystem().provider() ).isEqualTo( fsProvider ); assertThat( path.toString() ).isEqualTo( "/path/to/file.txt" ); }
@Test public void testCreateDirectory() throws Exception { final URI newRepo = URI.create( "git://xcreatedir-test-repo" ); PROVIDER.newFileSystem( newRepo, EMPTY_ENV ); final JGitPathImpl path = (JGitPathImpl) PROVIDER.getPath( URI.create( "git://master@xcreatedir-test-repo/some/path/to/" ) ); final Pair<PathType, ObjectId> result = JGitUtil.checkPath( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); assertThat( result.getK1() ).isEqualTo( PathType.NOT_FOUND ); PROVIDER.createDirectory( path ); final Pair<PathType, ObjectId> resultAfter = JGitUtil.checkPath( path.getFileSystem().gitRepo(), path.getRefTree(), path.getPath() ); assertThat( resultAfter.getK1() ).isEqualTo( PathType.DIRECTORY ); try { PROVIDER.createDirectory( path ); failBecauseExceptionWasNotThrown( FileAlreadyExistsException.class ); } catch ( FileAlreadyExistsException e ) { } }
/** Verify that Tags are read and written to Parcels correctly. */ public void testWriteToParcel() throws Throwable { final Tag original = new Tag("quack", Tag.Type.COPYRIGHT); final Bundle bundle = new Bundle(); final Tag unParceled; // Write a Tag to a parcel and create a new Tag from the parceled data. bundle.putParcelable("tag", original); unParceled = bundle.getParcelable("tag"); // Compare data between original and un-parceled tag. assertThat(unParceled.getName()).isEqualTo(original.getName()); assertThat(unParceled.getType()).isEqualTo(original.getType()); }
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */ @Test public void aggressiveClearingHandlesRead() throws Exception { FileUtils.deleteDirectory(cacheDir); assertThat(cache.get("a")).isNull(); }
@Test public void simpleTests() { final Path path = GeneralPathImpl.create( fileSystem, "something", false ); final FileStore fileStore = new SimpleWindowsFileStore( roots, path ); assertThat( fileStore.name() ).isNotNull().isEqualTo( "c:\\" ); assertThat( fileStore.type() ).isNull(); assertThat( fileStore.isReadOnly() ).isFalse(); assertThat( fileStore.getTotalSpace() ).isEqualTo( 0L ); assertThat( fileStore.getUsableSpace() ).isEqualTo( 0L ); assertThat( fileStore.supportsFileAttributeView( BasicFileAttributeView.class ) ).isTrue(); assertThat( fileStore.supportsFileAttributeView( MyFileAttributeView.class ) ).isFalse(); assertThat( fileStore.supportsFileAttributeView( MyAlsoInvalidFileAttributeView.class ) ).isFalse(); assertThat( fileStore.supportsFileAttributeView( "basic" ) ).isTrue(); assertThat( fileStore.supportsFileAttributeView( "any" ) ).isFalse(); assertThat( fileStore.supportsFileAttributeView( BasicFileAttributeView.class.getName() ) ).isFalse(); assertThat( fileStore.supportsFileAttributeView( MyAlsoInvalidFileAttributeView.class.getName() ) ).isFalse(); assertThat( fileStore.getFileStoreAttributeView( FileStoreAttributeView.class ) ).isNull(); assertThat( fileStore.getAttribute( "name" ) ).isNotNull().isEqualTo( fileStore.name() ); assertThat( fileStore.getAttribute( "totalSpace" ) ).isNotNull().isEqualTo( fileStore.getTotalSpace() ); assertThat( fileStore.getAttribute( "usableSpace" ) ).isNotNull().isEqualTo( fileStore.getUsableSpace() ); assertThat( fileStore.getAttribute( "readOnly" ) ).isNotNull().isEqualTo( fileStore.isReadOnly() ); }
@Test public void simpleTests() { final FileSystem fileSystem = new SimpleUnixFileSystem( fsProvider, "/" ); assertThat( fileSystem.isOpen() ).isTrue(); assertThat( fileSystem.isReadOnly() ).isFalse(); assertThat( fileSystem.getSeparator() ).isEqualTo( System.getProperty( "file.separator" ) ); assertThat( fileSystem.provider() ).isEqualTo( fsProvider ); assertThat( fileSystem.supportedFileAttributeViews() ).isNotEmpty().hasSize( 1 ).contains( "basic" ); assertThat( fileSystem.getPath( "/path/to/file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) ); assertThat( fileSystem.getPath( "/path/to/file.txt", null ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) ); assertThat( fileSystem.getPath( "/path", "to", "file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) ); try { fileSystem.close(); fail( "can't close this fileSystem" ); } catch ( UnsupportedOperationException ex ) { } assertThat( fileSystem.getFileStores() ).isNotNull().hasSize( 1 ); assertThat( fileSystem.getFileStores().iterator().next().name() ).isEqualTo( "/" ); assertThat( fileSystem.getRootDirectories() ).isNotNull().hasSize( 1 ); assertThat( fileSystem.getRootDirectories().iterator().next().toString() ).isEqualTo( "/" ); assertThat( fileSystem.getRootDirectories().iterator().next().isAbsolute() ).isTrue(); }
@Test public void givenDrmTypeNone_whenCreatingDrmSessionCreator_thenReturnsNoDrmSession() throws DrmSessionCreatorException { DrmSessionCreator drmSessionCreator = drmSessionCreatorFactory.createFor(DrmType.NONE, IGNORED_DRM_HANDLER); assertThat(drmSessionCreator).isInstanceOf(NoDrmSessionCreator.class); }
@Test public void test_that_a_Line_should_have_at_least_one_word() { Haiku.Line line = new Haiku.Line("hello"); assertThat(line).isNotNull(); }
public static void assertDataSetDefinition(final DataSet dataSet, final String uuid) { assertThat(dataSet.getUUID()).isEqualTo(uuid); assertThat(dataSet.getDefinition()).isNotNull(); assertThat(dataSet.getDefinition().getUUID()).isEqualTo(uuid); } }
@Test public void retrieveEntriesFromJournal() throws Exception { FileWriter writer = new FileWriter(mJournalFile); writer.write("DIRTY k1\nCLEAN k1 12\n"); writer.close(); LinkedHashMap<String, Entry> entries = mJournal.retrieveEntriesFromJournal(); assertThat(entries.size()).isEqualTo(1); assertThat(entries.get("k1")).isNotEqualTo(null); assertThat(entries.get("k1").isReadable()); }