@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); }
@Test public void givenACorrectHaiku_ReturnASplitHaiku() { String input = HaikuReview.INPUT_TWO; String[] s = haikuReview.splitHaiku(input); assertThat(s).hasSize(3); }
/** 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)); } }
/** 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); }
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(); }