Skip to content

Commit

Permalink
Fix issue with null priority and rewatch/reread value (#255)
Browse files Browse the repository at this point in the history
* handle null enums for list update

* add test cases

* update issue templates

* form changes

* Update pom.xml

* fix failing test case
  • Loading branch information
Katsute authored Nov 14, 2021
1 parent 29e7171 commit 4bfe862
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 51 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ body:
required: true
- label: I have checked that this issue is actually a bug and not a feature.
required: true
- label: I have checked that there are no other similar [discussions](https://github.com/Katsute/Mal4J/discussions).
required: true
- label: I have checked the [documentation](https://mal4j.katsute.dev/).
required: true
- label: I have checked the [FAQ](https://github.com/Katsute/Mal4J/blob/main/faq.md).
- label: I have checked the [known issues](https://github.com/Katsute/Mal4J/projects/10) for this library.
required: true
- label: I am running the latest release version.
- label: I have checked the [FAQ](https://github.com/Katsute/Mal4J/blob/main/faq.md).
required: true

- type: input
Expand Down
14 changes: 1 addition & 13 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ contact_links:
- name: Reporting an issue on the GitHub app
about: You must use a browser to use issue forms
url: https://github.com/Katsute/Mal4J/discussions/198
- name: Known Issues
about: Certain issues are caused by the MyAnimeList API and not this library, check here for a list of those issues
url: https://github.com/Katsute/Mal4J/projects/10
- name: Documentation
about: Check the documentation before posting an issue
url: https://docs.katsute.dev/mal4j
- name: FAQ
about: Check frequently asked questions before posting an issue
url: https://github.com/Katsute/Mal4J/blob/main/faq.md
- name: Discussions
url: https://github.com/Katsute/Mal4J/discussions
about: Check here before posting an issue
- name: Official MyAnimeList API Club
url: https://myanimelist.net/clubs.php?cid=13727
about: We do not maintain the MyAnimeList API, issues regarding the API itself should be posted in their official club
about: We do not maintain the MyAnimeList API, issues regarding the API itself should be posted in their official club
15 changes: 1 addition & 14 deletions .github/ISSUE_TEMPLATE/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ body:
required: true
- label: I have checked that this issue is actually a bug and not a feature.
required: true
- label: I am using the latest [documentation](https://mal4j.katsute.dev/).
required: true

- type: input
id: version
attributes:
label: Release Version
description: |
Release version or branch commit where the issue occured. Do not write 'latest'.
placeholder: |
ex: 2.2.0, 3cdf1c8
validations:
required: true

- type: input
id: location
Expand All @@ -44,6 +31,6 @@ body:
attributes:
label: Issue
description: |
Explain your issue, add any relevant stacktraces here.
Explain your issue.
validations:
required: true
13 changes: 7 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
### Prerequisites
*If checks are not passed then the pull request will be closed.*

- [ ] I have checked that no other similar pull request already exists.
- [ ] My code follows the general code style as the rest of the code.
- [ ] I have checked that no sensitive information is exposed.
- [ ] Build compiles.
- [ ] Build passes test cases.
- [ ] I have checked that no other similar pull request already exists.
- [ ] My code follows the general code style as the rest of the code.
- [ ] I have checked that no sensitive information is exposed.
- [ ] Build compiles.
- [ ] Build passes test cases.

### GitHub Copilot Disclaimer
*The use of GitHub Copilot is **strictly prohibited** on this repository.*
- [ ] This pull does not use GitHub Copilot.

- [ ] This pull does not use GitHub Copilot.

### Changes Made
*List any changes made and/or other relevant issues.*
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
target
*.iml

/src/test/java/resources/*.txt
# testing
/src/test/java/resources/*.txt
/anime-list-*.txt
/manga-list-*.txt
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ List<AnimePreview> search =
```

### 📋 List Modification

Easily update your Anime and Manga listings through update methods.

```java
Expand Down Expand Up @@ -128,7 +129,7 @@ Code generated with GitHub Copilot is **strictly prohibited** on this repository
- Have a suggestion or looking for inspiration? Check out our [discussions](https://github.com/Katsute/Mal4J/discussions).
- Want to further expand our project or site? [Fork](https://github.com/Katsute/Mal4J/fork) this repository and submit a [pull request](https://github.com/Katsute/Mal4J/pulls).

Tests will modify list status for <https://myanimelist.net/anime/13759> and <https://myanimelist.net/manga/28107>, make sure you fix your ratings after the test runs.
Tests will modify list status for <https://myanimelist.net/anime/13759> and <https://myanimelist.net/manga/28107>, make sure you fix your ratings after the test runs. The test cases will create a backup of your list in the 'anime-list.txt' and 'manga-list.txt' files.

Ignore test failures for these known issues: [**⚠ External Issues**](https://github.com/Katsute/Mal4J/projects/10)

Expand Down
2 changes: 1 addition & 1 deletion faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ The affinity method requires that both users have their Anime/Manga list public.

*This feature is experimental*

The affinity method may take several minutes to complete depending on the amount of listings. A callback can be used if you don't want to block the main thread.
The affinity method may take several minutes to complete depending on the amount of listings. A callback can be used if you don't want to block the main thread.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kttdevelopment</groupId>
<artifactId>mal4j</artifactId>
<version>2.6.0-SNAPSHOT</version>
<version>2.5.1</version>

<profiles>
<profile>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/kttdevelopment/mal4j/MyAnimeListImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @see MyAnimeList
* @see MyAnimeListService
* @since 1.0.0
* @version 2.3.0
* @version 2.5.1
* @author Katsute
*/
final class MyAnimeListImpl extends MyAnimeList {
Expand Down Expand Up @@ -314,9 +314,9 @@ public synchronized final AnimeListStatus update(){
MyAnimeListSchema.asYMD(startDate),
MyAnimeListSchema.asYMD(finishDate),
watchedEpisodes,
priority.value(),
priority != null ? priority.value() : null,
timesRewatched,
rewatchValue.value(),
rewatchValue != null ? rewatchValue.value() : null,
toCommaSeparatedString(tags),
comments
)
Expand Down Expand Up @@ -643,9 +643,9 @@ public synchronized final MangaListStatus update(){
MyAnimeListSchema.asYMD(finishDate),
volumesRead,
chaptersRead,
priority.value(),
priority != null ? priority.value() : null,
timesReread,
rereadValue.value(),
rereadValue != null ? rereadValue.value() : null,
toCommaSeparatedString(tags),
comments
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import dev.katsute.jcore.Workflow;
import org.junit.jupiter.api.*;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
Expand All @@ -17,8 +21,12 @@ public class TestAnimeListStatus {
private static MyAnimeList mal;

@BeforeAll
public static void beforeAll(){
public static void beforeAll() throws IOException{
mal = TestProvider.getMyAnimeList();

final String file = "anime-list-" + System.currentTimeMillis() + ".txt";
System.out.println("Running Anime list tests, saving backup of current list to '" + file + '\'');
Files.write(new File(file).toPath(), mal.getAnime(TestProvider.AnimeID).getListStatus().toString().getBytes(StandardCharsets.UTF_8));
}

@SuppressWarnings("SpellCheckingInspection")
Expand Down Expand Up @@ -62,6 +70,12 @@ public static void afterAll(){
Workflow.errorSupplier("Expected comments to match"));
}

@Test @Order(0)
public void testMinimalUpdate(){
Assertions.assertDoesNotThrow(() -> mal.updateAnimeListing(TestProvider.AnimeID).score(10).update(),
Workflow.errorSupplier("Updating a listing with only a score should not throw an exception"));
}

@Test @Order(1)
public void testDelete(){
mal.deleteAnimeListing(TestProvider.AnimeID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ public static void beforeAll(){

@Test
public void testSeason(){
final int year = 2019;
final List<AnimePreview> season =
mal.getAnimeSeason(2019, Season.Summer)
.withLimit(1)
mal.getAnimeSeason(year, Season.Summer)
.withField(Fields.Anime.start_season)
.search();
final AnimePreview anime = season.get(0);
Assertions.assertEquals(2019, anime.getStartSeason().getYear(),
Workflow.errorSupplier("Expected year to match"));

int thisYear = 0;
int otherYear = 0;

AnimePreview anime = null;
for(final AnimePreview iterator : season)
if(iterator.getStartSeason().getYear() == year){
thisYear++;
anime = iterator;
}else
otherYear++;

Assertions.assertTrue(thisYear > otherYear, Workflow.errorSupplier("Expected seasonal search to return mostly from selected year (search contained mostly results from other years)"));

Assertions.assertNotNull(anime, Workflow.errorSupplier("Expected seasonal search to return an Anime from selected year"));
Assertions.assertTrue(
anime.getStartSeason().getSeason() == Season.Summer || anime.getStartSeason().getSeason() == Season.Spring,
Workflow.errorSupplier("Anime start season was supposed to be either Summer or Spring but was " + anime.getStartSeason().getSeason().name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import dev.katsute.jcore.Workflow;
import org.junit.jupiter.api.*;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
Expand All @@ -17,8 +21,12 @@ public class TestMangaListStatus {
private static MyAnimeList mal;

@BeforeAll
public static void beforeAll(){
public static void beforeAll() throws IOException{
mal = TestProvider.getMyAnimeList();

final String file = "manga-list-" + System.currentTimeMillis() + ".txt";
System.out.println("Running Manga list tests, saving backup of current list to '" + file + '\'');
Files.write(new File(file).toPath(), mal.getManga(TestProvider.MangaID).getListStatus().toString().getBytes(StandardCharsets.UTF_8));
}

@AfterAll
Expand Down Expand Up @@ -64,6 +72,12 @@ public static void afterAll(){
Workflow.errorSupplier("Expected comments to match"));
}

@Test @Order(0)
public void testMinimalUpdate(){
Assertions.assertDoesNotThrow(() -> mal.updateMangaListing(TestProvider.MangaID).score(10).update(),
Workflow.errorSupplier("Updating a listing with only a score should not throw an exception"));
}

@Test @Order(1)
public void testDelete(){
mal.deleteMangaListing(TestProvider.MangaID);
Expand Down

0 comments on commit 4bfe862

Please sign in to comment.