/** * Creates a new instance of <code>{@link ObjectArrayAssert}</code>. * @param actual the actual value. * @return the created assertion object. */ public static <T> ObjectArrayAssert<T> assertThat(T[] actual) { return new ObjectArrayAssert<T>(actual); }
@Test public void testYouCanSplitAHaikuIntoLines() { String haiku = "happy purple frog/eating bugs in the marshes/get indigestion"; String[] splitHaiku = haikuReview.splitHaiku(haiku); assertThat(splitHaiku).hasSize(3); }
public void testSearchUsingTags() throws Throwable { // TODO: Ideally this should be mocked, so testing doesn't rely on external APIs. // Create a new client connected to the Danbooru API. final SearchClient client = createSearchClient(); // Retrieve a search result. final SearchResult result = client.search(getDefaultTag()); // Make sure we got results back. assertThat(result.getImages()).isNotEmpty(); // Verify metadata for each returned image. for (Image image : result.getImages()) { ImageTests.verifyImage(image); } // Check rests of the values. assertThat(result.getCurrentOffset()).isEqualTo(0); assertThat(result.getQuery()).hasSize(1); assertThat(result.getQuery()[0].getName()).isEqualTo(getDefaultTag()); assertThat(result.hasNextPage()).isTrue(); }
/** Tests the {@link io.github.tjg1.library.norilib.SearchResult#getImages()} method. */ public void testGetImages() throws Throwable { final SearchResult searchResult = getMockSearchResult(); assertThat(searchResult.getImages()).isNotEmpty(); }
@Test @Ignore public void testUsingProvidedPath() throws IOException { final File dir = createTempDirectory(); System.setProperty("org.kie.nio.git.dir", dir.toString()); JGitFileSystemProvider.loadConfig(); final JGitFileSystemProvider provider = new JGitFileSystemProvider(); final URI newRepo = URI.create("git://repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final String[] names = dir.list(); assertThat(names).isNotEmpty().contains(".niogit"); final String[] repos = new File(dir, ".niogit").list(); assertThat(repos).isNotEmpty().contains("repo-name.git"); System.setProperty("org.kie.nio.git.dir", ""); }
/** Verify that SearchResult can be written and read from Parcels correctly. */ public void testWriteToParcel() throws Throwable { final SearchResult original = getMockSearchResult(); final SearchResult unParceled; final Bundle bundle = new Bundle(); // Parcel and un-parcel the original SearchResult. bundle.putParcelable("search-result", original); unParceled = bundle.getParcelable("search-result"); // Verify un-parceled data. if (unParceled != null) { assertThat(unParceled.getImages()).containsOnly(original.getImages()); assertThat(unParceled.getCurrentOffset()).isEqualTo(original.getCurrentOffset()); assertThat(unParceled.getQuery()).containsOnly(original.getQuery()); assertThat(unParceled.hasNextPage()).isEqualTo(original.hasNextPage()); } }
@Test public void givenACorrectHaiku_ReturnASplitHaiku() { String input = HaikuReview.INPUT_TWO; String[] s = haikuReview.splitHaiku(input); assertThat(s).hasSize(3); }
assertThat(searchResults[0].getImages()).isNotEmpty();
assertThat(unParceled.sampleWidth).isEqualTo(original.sampleWidth); assertThat(unParceled.sampleHeight).isEqualTo(original.sampleHeight); assertThat(unParceled.tags).containsOnly(original.tags); assertThat(unParceled.id).isEqualTo(original.id); assertThat(unParceled.parentId).isEqualTo(original.parentId);
/** Test creating tag arrays from space-separated queries using the {@link Tag#arrayFromString(String) method. */ public void testArrayFromString() throws Throwable { final Tag[] tags = Tag.arrayFromString("duck quack", Tag.Type.CHARACTER); assertThat(tags).hasSize(2); assertThat(tags[0]).isEqualTo(new Tag("duck", Tag.Type.CHARACTER)); assertThat(tags[1]).isEqualTo(new Tag("quack", Tag.Type.CHARACTER)); } }
public void testSearchUsingTagsAndOffset() throws Throwable { // TODO: Ideally this should be mocked, so testing doesn't rely on external APIs. // Create a new client connected to the Danbooru API. final SearchClient client = createSearchClient(); // Retrieve search results. final SearchResult page1 = client.search(getDefaultTag(), 0); final SearchResult page2 = client.search(getDefaultTag(), 1); // Make sure that the results differ. assertThat(page1.getImages()).isNotEmpty(); assertThat(page2.getImages()).isNotEmpty(); assertThat(page2.getCurrentOffset()).isEqualTo(1); assertThat(page1.getImages()[0].id).isNotEqualTo(page2.getImages()[0].id); assertThat(page1.getImages()[0].searchPage).isEqualTo(page1.getCurrentOffset()); assertThat(page1.getImages()[0].searchPagePosition).isEqualTo(0); assertThat(page1.getImages()[1].searchPagePosition).isEqualTo(1); assertThat(page2.getImages()[0].searchPage).isEqualTo(page2.getCurrentOffset()); assertThat(page2.getImages()[0].searchPagePosition).isEqualTo(0); assertThat(page2.getImages()[1].searchPagePosition).isEqualTo(1); }
/** Tests the {@link io.github.tjg1.library.norilib.SearchResult#filter(Image.SafeSearchRating...)} method. */ public void testFilterWithSafeSearchRating() throws Throwable { final SearchResult searchResult = getMockSearchResult(); searchResult.filter(Image.SafeSearchRating.Q); assertThat(searchResult.getImages()).hasSize(1); assertThat(searchResult.getImages()[0].safeSearchRating).isEqualTo(Image.SafeSearchRating.Q); assertThat(searchResult.getImages()[0].searchPagePosition).isEqualTo(0); }
/** Tests the {@link SearchResult#filter(io.github.tjg1.library.norilib.Tag...)} method. */ public void testFilterWithTags() throws Throwable { final SearchResult searchResult = getMockSearchResult(); searchResult.filter(new Tag("duck")); assertThat(searchResult.getImages()).hasSize(1); assertThat(searchResult.getImages()[0].tags[0].getName()).isEqualTo("bird"); assertThat(searchResult.getImages()[0].searchPagePosition).isEqualTo(0); }
/** Tests the {@link io.github.tjg1.library.norilib.SearchResult#addImages(io.github.tjg1.library.norilib.Image[], int)} method. */ public void testAddImages() throws Throwable { final SearchResult searchResult = getMockSearchResult(); searchResult.addImages(new Image[]{ImageTests.getMockImage(Image.SafeSearchRating.E, new Tag("quack"))}, 20); assertThat(searchResult.getImages()).hasSize(3); assertThat(searchResult.getImages()[2].safeSearchRating).isEqualTo(Image.SafeSearchRating.E); assertThat(searchResult.getCurrentOffset()).isEqualTo(20); }